NameError: name 'r2_score' is not defined
时间: 2023-09-16 12:12:11 浏览: 907
请求/响应类型的数据交换-python中对错误nameerror: name ‘xxx’ is not defined进行总结
This error occurs when you try to use the function `r2_score` from the `sklearn.metrics` module, but the module has not been imported or the function has not been defined in the code.
To fix this error, you need to import the `sklearn.metrics` module using the following statement:
```
from sklearn.metrics import r2_score
```
Make sure to add this import statement at the beginning of your code.
阅读全文