sklearn中mean_squared_error导入报错问题求助
解决ModuleNotFoundError: No module named 'mean_squarred_error'问题
你的问题核心是拼写错误,不管是导入语句还是函数调用,你都把正确的mean_squared_error拼错了:
- 导入时写成了
mean_squarred_error(多了一个字母r) - 调用函数时写成了
mean_sqaured_error(字母a和u顺序颠倒)
以下是两种正确的写法:
写法一:直接导入函数
from sklearn.metrics import mean_squared_error mean_squared_error(predictions["actual"], predictions["prediction"])
写法二:导入metrics模块后调用
from sklearn import metrics metrics.mean_squared_error(predictions["actual"], predictions["prediction"])
修正拼写错误后,导入错误和调用问题就能解决。
内容的提问来源于stack exchange,提问作者Persian Dolphin
相关产品推荐
相关产品推荐

