IALSRecommender
- class rsdiv.recommenders.IALSRecommender(df_interaction: DataFrame, items: DataFrame, test_size: Union[float, int], random_split: bool = False, factors: int = 300, regularization: float = 0.03, alpha: float = 0.6, iterations: int = 10, random_state: Optional[int] = 42, toppop_mask: Optional[ndarray] = None)[source]
Bases:
BaseRecommenderiALS recommender based on implicit.
- Parameters
- bm25(X: coo_matrix, K1: int = 100, B: float = 0.8) csr_matrix[source]
Weighs each col of a sparse matrix X by BM25 weighting. Taken from nearest_neighbours.py of implicit
- recommend_single(user_string: str, top_k: int = 100) List[source]
Recommend for single user with top_k items.
- get_score_single_user(user_string: str, keep_indices: ndarray) Optional[ndarray][source]
Get the single user’s predictions scores for the filtered items. Return None for new users.
- Parameters
user_string (str) – Original user token string.
keep_indices (np.ndarray) – Items to be kept based on filters.
- Returns
Predictions for the given items. Return None for new users.
- Return type
Optional[np.ndarray]
- get_topk_single_user(user_string: str, keep_indices: ndarray, top_k: int) Tuple[ndarray, ndarray][source]
Get the recommended item ids for a given user id.
- get_interaction(df_interaction: DataFrame) Tuple[DataFrame, ndarray, ndarray]
The converter for input dataframe
- Parameters
df_interaction (pd.DataFrame) – user/item interaction matrix. columns should be [“userId”, “itemId”]