DRecPy.Recommender.Baseline package¶
DRecPy.Recommender.Baseline.base_knn module¶
-
class
DRecPy.Recommender.Baseline.base_knn.
BaseKNN
(k=20, m=5, sim_metric='adjusted_cosine', aggregation='weighted_mean', shrinkage=100, use_averages=False, **kwds)¶ Bases:
DRecPy.Recommender.recommender_abc.RecommenderABC
,abc.ABC
Base Collaborative Filtering recommender abstract class.
This class implements the skeleton methods for building a basic neighbour-based CF. The following methods are still required to be implemented: _fit(): should fit the model. _predict_default(): should return the default prediction value that is used when a minimum number of neighbours is not found. Only used when use_averages=True.
-
k
¶ An integer representing the number of neighbours used to make a prediction. Default: 20.
-
m
¶ An integer representing the minimum number of co-rated users/items required to validate the similarity value (if not valid, sim. value is set to 0). Default: 5.
-
sim_metric
¶ Optional string representing the name of the similarity metric to use. Supported: ‘adjusted_cosine’, ‘cosine’, ‘cosine_cf’, ‘jaccard’, ‘msd’, ‘pearson’. Default: ‘adjusted_cosine’.
-
aggregation
¶ Optional string representing the name of the aggregation approach to use. Supported: ‘mean’, ‘weighted_mean’. Default: ‘weighted_mean’.
-
shrinkage
¶ Optional integer representing the discounting factor for computing the similarity between items / users (discounts less when #co-ratings increases). Default: 100.
-
use_averages
¶ Optional boolean indicating whether to use item (for UserKNN) or user (for ItemKNN) averages when no neighbours are found. Default: True.
-
DRecPy.Recommender.Baseline.item_knn module¶
-
class
DRecPy.Recommender.Baseline.item_knn.
ItemKNN
(**kwds)¶ Bases:
DRecPy.Recommender.Baseline.base_knn.BaseKNN
Item-based KNN Collaborative Filtering recommender model.
Implementation of a basic item neighbour-based CF.
- Public Methods:
- fit(), predict(), recommend(), rank().
Attributes: See parent object BaseKNN obj:DRecPy.Recommender.Baseline.BaseKNN
DRecPy.Recommender.Baseline.user_knn module¶
-
class
DRecPy.Recommender.Baseline.user_knn.
UserKNN
(**kwds)¶ Bases:
DRecPy.Recommender.Baseline.base_knn.BaseKNN
User-based KNN Collaborative Filtering recommender model.
Implementation of a basic user neighbour-based CF.
- Public Methods:
- fit(), predict(), recommend(), rank().
Attributes: See parent object BaseKNN