ImportError:无法导入名称“ evaluate”(来自意外导入评估)

时间:2019-11-30 00:19:37

标签: python-3.x scikit-learn anaconda recommender-systems

from surprise import Reader, Dataset, SVD
from surprise import evaluate
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-12-6d771df269b8> in <module>()
----> 1 from surprise import evaluate

ImportError: cannot import name 'evaluate'

从意外导入的Reader,Dataset,SVD的第一行可以正常工作。 仅仅是这样,它就不能从Surprise包中导入评估。

我已经使用conda安装了scikit-surprise。 我认为它已成功安装。

2 个答案:

答案 0 :(得分:5)

从2020年1月起,改为执行以下操作...

from surprise import SVD
from surprise import Dataset
from surprise.model_selection import cross_validate

# Load the dataset (download it if needed)
data = Dataset.load_builtin('ml-100k')

# Use the famous SVD algorithm
algo = SVD()

# Run 5-fold cross-validation and then print results
cross_validate(algo, data, measures=['RMSE', 'MAE'], cv=5, verbose=True)

答案 1 :(得分:1)

根据文档,powershell.exe -window minimized -noexit -file "%USERPROFILE%\Desktop\UNB\script\UNBILLING.ps1" 方法为deprecated in version 1.0.5(功能上由model_selection.cross_validate()代替),并且为removed in version 1.1.0,很可能是您已经安装的方法。