@@ -84,11 +84,13 @@ class BaseRecommender(object, metaclass=RecommenderMeta):
8484 config_class : Type [RecommenderConfig ]
8585 default_tune_range : List [ParameterRange ]
8686
87+ X_train_all : sps .csr_matrix
88+ """The matrix to feed into recommender."""
89+
8790 def __init__ (self , X_train_all : InteractionMatrix , ** kwargs : Any ) -> None :
8891 self .X_train_all : sps .csr_matrix = sps .csr_matrix (X_train_all ).astype (
8992 np .float64
9093 )
91- """The matrix to feed into recommender."""
9294
9395 self .n_users : int = self .X_train_all .shape [0 ]
9496 self .n_items : int = self .X_train_all .shape [1 ]
@@ -387,18 +389,18 @@ def get_score_cold_user_remove_seen(self, X: InteractionMatrix) -> DenseScoreArr
387389class BaseSimilarityRecommender (BaseRecommender ):
388390 """The computed item-item similarity. Might not be initialized before `learn()` is called."""
389391
390- W_ : Optional [Union [sps .csr_matrix , sps .csc_matrix , np .ndarray ]]
392+ _W : Optional [Union [sps .csr_matrix , sps .csc_matrix , np .ndarray ]]
391393
392394 def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
393395 super ().__init__ (* args , ** kwargs )
394- self .W_ = None
396+ self ._W = None
395397
396398 @property
397399 def W (self ) -> Union [sps .csr_matrix , sps .csc_matrix , np .ndarray ]:
398400 """The computed item-item similarity weight matrix."""
399- if self .W_ is None :
401+ if self ._W is None :
400402 raise RuntimeError ("W fetched before fit." )
401- return self .W_
403+ return self ._W
402404
403405 def get_score (self , user_indices : UserIndexArray ) -> DenseScoreArray :
404406 return _sparse_to_array (self .X_train_all [user_indices ].dot (self .W ))
0 commit comments