accuracy module¶
The surprise.accuracy
module provides tools for computing accuracy
metrics on a set of predictions.
Available accuracy metrics:
rmse 
Compute RMSE (Root Mean Squared Error). 
mse 
Compute MSE (Mean Squared Error). 
mae 
Compute MAE (Mean Absolute Error). 
fcp 
Compute FCP (Fraction of Concordant Pairs). 

surprise.accuracy.
fcp
(predictions, verbose=True)¶ Compute FCP (Fraction of Concordant Pairs).
Computed as described in paper Collaborative Filtering on Ordinal User Feedback by Koren and Sill, section 5.2.
Parameters:  predictions (
list
ofPrediction
) – A list of predictions, as returned by thetest()
method.  verbose – If True, will print computed value. Default is
True
.
Returns: The Fraction of Concordant Pairs.
Raises: ValueError
– Whenpredictions
is empty. predictions (

surprise.accuracy.
mae
(predictions, verbose=True)¶ Compute MAE (Mean Absolute Error).
\[\text{MAE} = \frac{1}{\hat{R}} \sum_{\hat{r}_{ui} \in \hat{R}}r_{ui}  \hat{r}_{ui}\]Parameters:  predictions (
list
ofPrediction
) – A list of predictions, as returned by thetest()
method.  verbose – If True, will print computed value. Default is
True
.
Returns: The Mean Absolute Error of predictions.
Raises: ValueError
– Whenpredictions
is empty. predictions (

surprise.accuracy.
mse
(predictions, verbose=True)¶ Compute MSE (Mean Squared Error).
\[\text{MSE} = \frac{1}{\hat{R}} \sum_{\hat{r}_{ui} \in \hat{R}}(r_{ui}  \hat{r}_{ui})^2.\]Parameters:  predictions (
list
ofPrediction
) – A list of predictions, as returned by thetest()
method.  verbose – If True, will print computed value. Default is
True
.
Returns: The Mean Squared Error of predictions.
Raises: ValueError
– Whenpredictions
is empty. predictions (

surprise.accuracy.
rmse
(predictions, verbose=True)¶ Compute RMSE (Root Mean Squared Error).
\[\text{RMSE} = \sqrt{\frac{1}{\hat{R}} \sum_{\hat{r}_{ui} \in \hat{R}}(r_{ui}  \hat{r}_{ui})^2}.\]Parameters:  predictions (
list
ofPrediction
) – A list of predictions, as returned by thetest()
method.  verbose – If True, will print computed value. Default is
True
.
Returns: The Root Mean Squared Error of predictions.
Raises: ValueError
– Whenpredictions
is empty. predictions (