Abstract methodology class
Methodology(only_greater_eq=None)
Bases: ABC
Class which, given a train set and a test set, has the task to calculate which items must be used in order to generate a recommendation list
The methodologies here implemented follow the 'Precision-Oriented Evaluation of Recommender Systems: An Algorithmic Comparison' paper
Source code in clayrs/recsys/methodology.py
23 24 25 26 27 28 29 30 31 |
|
filter_all(train_set, test_set, result_as_dict=False, ids_as_str=True)
Concrete method which calculates for all users of the test set which items must be used in order to generate a recommendation list
It takes in input a train set and a test set and returns a single DataFrame or a python dictionary containing, for every user, all items which must be recommended based on the methodology chosen.
PARAMETER | DESCRIPTION |
---|---|
train_set |
TYPE:
|
test_set |
TYPE:
|
result_as_dict |
If True the output of the method will be a generator of a dictionary that contains
users as keys and numpy arrays with items as values. If
TYPE:
|
ids_as_str |
If True, the result will contain users and items represented with their string id. Otherwise, will be present with their mapped integer
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[pd.DataFrame, Union[Dict[str, np.ndarray], Dict[int, np.ndarray]]]
|
A DataFrame or a python dictionary which contains all items which must be recommended to every user based on the methodology chosen. |
Source code in clayrs/recsys/methodology.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
filter_single(user_idx, train_set, test_set)
abstractmethod
Abstract method in which must be specified how to calculate which items must be part of the recommendation list of a single user
Source code in clayrs/recsys/methodology.py
114 115 116 117 118 119 120 |
|
setup(train_set, test_set)
abstractmethod
Method to call before calling filter_all()
or filter_single()
.
It is used to set up numpy arrays which will filter items according to the methodology chosen.
This method has side effect, meaning that it will return a Methodology
object which has been set up but will
also change the Methodology
object that has called this method
PARAMETER | DESCRIPTION |
---|---|
train_set |
TYPE:
|
test_set |
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Methodology
|
The set-up Methodology object |
Source code in clayrs/recsys/methodology.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|