Abstract Partitioning class
Partitioning(skip_user_error=True)
Bases: ABC
Abstract class for partitioning technique. Each class must implement the split_single()
method which specify how
data for a single user will be split
PARAMETER | DESCRIPTION |
---|---|
skip_user_error |
If set to True, users for which data can't be split will be skipped and only a warning will be logged at the
end of the split process specifying n° of users skipped. Otherwise, a
TYPE:
|
Source code in clayrs/recsys/partitioning.py
28 29 |
|
split_all(ratings_to_split, user_list=None)
Concrete method that splits, for every user in the user column of ratings_to_split
, the original ratings
into train set and test set.
If a user_list
parameter is set, the method will do the splitting only for the users
specified inside the list (Users can be specified as strings or with their mapped integer).
The method returns two lists:
- The first contains all train set for each split (if the partitioning technique returns more than one split e.g. KFold)
- The second contains all test set for each split (if the partitioning technique returns more than one split e.g. KFold)
Obviously the two lists will have the same length, and to the train set in position \(i\) corresponds the truth set at position \(i\)
PARAMETER | DESCRIPTION |
---|---|
ratings_to_split |
TYPE:
|
user_list |
The Set of users for which splitting will be done. If set, splitting will be performed only
for users inside the list. Otherwise, splitting will be performed for all users in |
RAISES | DESCRIPTION |
---|---|
ValueError
|
if |
Source code in clayrs/recsys/partitioning.py
54 55 56 57 58 59 60 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
split_single(uir_user)
abstractmethod
Abstract method in which each partitioning technique must specify how to split data for a single user
PARAMETER | DESCRIPTION |
---|---|
uir_user |
uir matrix containing interactions of a single user |
RETURNS | DESCRIPTION |
---|---|
List[np.ndarray]
|
The first list contains a uir matrix for each split constituting the train set of the user |
List[np.ndarray]
|
The second list contains a uir matrix for each split constituting the test set of the user |
Source code in clayrs/recsys/partitioning.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|