alpenglow.offline package¶
Subpackages¶
- alpenglow.offline.evaluation package
- alpenglow.offline.models package
- Submodules
- alpenglow.offline.models.ALSFactorModel module
- alpenglow.offline.models.AsymmetricFactorModel module
- alpenglow.offline.models.FactorModel module
- alpenglow.offline.models.NearestNeighborModel module
- alpenglow.offline.models.PopularityModel module
- alpenglow.offline.models.SvdppModel module
- Module contents
Submodules¶
alpenglow.offline.OfflineModel module¶
- class alpenglow.offline.OfflineModel.OfflineModel(**parameters)[source]¶
Bases:
alpenglow.ParameterDefaults.ParameterDefaults
OfflineModel is the base class for all traditional, scikit-learn style models in Alpenglow. Example usage:
data = pd.read_csv('data') train_data = data[data.time < (data.time.min()+250*86400)] test_data = data[ (data.time >= (data.time.min()+250*86400)) & (data.time < (data.time.min()+300*86400))] exp = ag.offline.models.FactorModel( learning_rate=0.07, negative_rate=70, number_of_iterations=9, ) exp.fit(data) test_users = list(set(test_data.user)&set(train_data.user)) recommendations = exp.recommend(users=test_users)
- fit(X, y=None, columns={})[source]¶
Fit the model to a dataset.
- Parameters
X (pandas.DataFrame) – The input data, must contain the columns user and item. May contain the score column as well.
y (pandas.Series or list) – The target values. If not set (and X doesn’t contain the score column), it is assumed to be constant 1 (implicit recommendation).
columns (dict) – Optionally the mapping of the input DataFrame’s columns’ names to the expected ones.
- predict(X)[source]¶
Predict the target values on X.
- Parameters
X (pandas.DataFrame) – The input data, must contain the columns user and item.
- Returns
List of predictions
- Return type
list
- recommend(users=None, k=100, exclude_known=True)[source]¶
Give toplist recommendations for users.
- Parameters
users (list) – List of users to give recommendation for.
k (int) – Size of toplists
exclude_known (bool) – Whether to exclude (user,item) pairs in the train dataset from the toplists.
- Returns
DataFrame of recommendations, with columns user, item and rank.
- Return type
pandas.DataFrame