Skip to content
Extraits de code Groupes Projets
Valider aa44f259 rédigé par Adrien Payen's avatar Adrien Payen
Parcourir les fichiers

Merge branch 'Project' of https://forge.uclouvain.be/recommender_system/recomsys into Project

parents 6e2d84ee 817df132
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -7,6 +7,7 @@ from collections import defaultdict ...@@ -7,6 +7,7 @@ from collections import defaultdict
# Third-party imports # Third-party imports
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import pearsonr from scipy.stats import pearsonr
from sklearn.ensemble import AdaBoostRegressor, GradientBoostingRegressor, RandomForestRegressor from sklearn.ensemble import AdaBoostRegressor, GradientBoostingRegressor, RandomForestRegressor
...@@ -23,7 +24,6 @@ from sklearn.svm import SVR ...@@ -23,7 +24,6 @@ from sklearn.svm import SVR
from sklearn.tree import DecisionTreeRegressor from sklearn.tree import DecisionTreeRegressor
from surprise import AlgoBase, KNNWithMeans, accuracy, PredictionImpossible from surprise import AlgoBase, KNNWithMeans, accuracy, PredictionImpossible
from xgboost import XGBRegressor from xgboost import XGBRegressor
from lightgbm import LGBMRegressor
# Local imports # Local imports
from constants import Constant as C from constants import Constant as C
...@@ -345,6 +345,19 @@ class RecommenderSystem_KNN : ...@@ -345,6 +345,19 @@ class RecommenderSystem_KNN :
predictions = self.model.test(self.testset) predictions = self.model.test(self.testset)
self.rmse = accuracy.rmse(predictions) self.rmse = accuracy.rmse(predictions)
def evaluate_rmse(self, testset):
"""
Evaluate the RMSE of the model on a test set.
Args:
testset (list): List of testset entries containing (user, item, rating).
Returns:
float: RMSE of the model.
"""
predictions = self.model.test(self.testset)
return accuracy.rmse(predictions, verbose=True)
def evaluate_mae(self): def evaluate_mae(self):
""" """
Evaluate the MAE of the model on the test set. Evaluate the MAE of the model on the test set.
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter