Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'evaluate' ( from surprise import evaluate )

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'

The first line, from surprise import Reader, Dataset, SVD works fine. Just that, it's not able to import the evaluate from the surprise package.

I have installed the scikit-surprise using conda. I think it was installed successfully.

like image 216
Tushar Avatar asked Nov 30 '19 00:11

Tushar


2 Answers

As of January 2020, do something like the following instead...

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)

like image 188
Kris Stern Avatar answered Oct 10 '22 06:10

Kris Stern


According to the documentation, the evaluate() method was deprecated in version 1.0.5 (functionally replaced by model_selection.cross_validate()) and was removed in version 1.1.0, which is likely what you have installed.

like image 23
merv Avatar answered Oct 10 '22 06:10

merv