irspack.split.UserTrainTestInteractionPair
- class irspack.split.UserTrainTestInteractionPair(user_ids, X_train, X_test, item_ids=None)[source]
Bases:
objectA class to hold users’ train & test (if any) interactions and their ids.
- Parameters:
user_ids (Union[List[Any], ndarray]) – List of user ids. Its
i-th element should correspond toi-th row ofX_train.X_train (csr_matrix) – The train part of interactions.
X_test (csr_matrix) – The test part of interactions (if any). If
None, an empty matrix with the shape ofX_trainwill be created. Defaults to None.item_ids (Optional[Union[List[Any], ndarray]]) –
- Raises:
ValueError – when
X_trainanduser_idshave inconsistent size.ValueError – when
X_trainandX_testhave inconsistent size.
- __init__(user_ids, X_train, X_test, item_ids=None)[source]
- Parameters:
user_ids (Union[List[Any], ndarray]) –
X_train (Union[csr_matrix, csc_matrix]) –
X_test (Optional[Union[csr_matrix, csc_matrix]]) –
item_ids (Optional[Union[List[Any], ndarray]]) –
Methods
__init__(user_ids, X_train, X_test[, item_ids])concat(other)Concatenate the users data.
df_test()df_train()Attributes
The train part of users' interactions.
The test part of users' interactions.
The number of users
The number of items
If
X_testis notNone, equal toX_train + X_test.Otherwise equals X_train.- X_all: csr_matrix
If
X_testis notNone, equal toX_train + X_test.Otherwise equals X_train.
- X_test: csr_matrix
The test part of users’ interactions.
- X_train: csr_matrix
The train part of users’ interactions.
- concat(other)[source]
Concatenate the users data. user_id will be
self.user_ids + self.item_ids.- Returns:
[description]
- Return type:
[type]
- Parameters:
other (UserTrainTestInteractionPair) –
- ValueError:
when
selfandotherhave unequaln_items.
- n_items: int
The number of items
- n_users: int
The number of users