Recommender Documentation

Recommender

class xframes.toolkit.recommend.MatrixFactorizationModel(model, ratings, user_col, item_col, rating_col)[source]

Recommender model.

__init__(model, ratings, user_col, item_col, rating_col)[source]
item_features()[source]

The item features.

Underlying model parameters.

classmethod load(path)[source]

Load a model that was saved previously.

Parameters:

path : str

The path where the model files are stored. This is the same path that was passed to save. There are three files/directories based on this path, with extensions ‘.model’, ‘.ratings’, and ‘.metadata’.

Returns:

out : MatrixFactorizationModel

A model that can be used to predict ratings.

predict(user, item)[source]

Predict the rating given by a user to an item.

Parameters:

user : int

The user to predict.

item : int

The item to rate.

Returns:

out : float

The predicted rating.

predict_all(user)[source]

Predict ratings for all items.

Parameters:

user : int

The user to make predictions for.

Returns:

out : XFrame

Each row of the frame consists of a user id, an item id, and a predicted rating.

recommend_top_k(user, k=10)[source]

Recommend some items for a user.

Parameters:

user : int

The user to make recommendations for.

Returns:

out : XFrame

A XFrame containing the highest predictions for the user. The items that the user has explicitly rated are excluded.

save(path)[source]

Save a model.

The model can be saved, then reloaded later to provide recommendations.

Parameters:

path : str

The path where the model will be saved. This should refer to a file, not to a directory. Three items will be stored here: the underlying model parameters, the original ratings, and the column names. These are stored with suffix ‘.model’, ‘.ratings’, and ‘.metadata’.

user_features()[source]

The user features.

Underlying model parameters.

xframes.toolkit.recommend.create(data, user_col, item_col, rating_col, recommender_type='ALS', rank=50, iterations=10, lambda_=0.01, seed=0, **kwargs)[source]

Create a recommendation model.

Parameters:

data : XFrame

A table containing the user ratings. This table must contin three columns corresponding to the users, the items, and the ratings. The table may contain other columns as well: these are not used.

user_col : string

The column name of the users.

item_col : string

The column name of the items.

rating_col : string

The column name of the ratings. This must be a number.

recommender_type : string, optional

The type of recommender. Optons are: * ALS * ALS-implicit

rank : int, optional

See ALSBuilder.train

iterations : int, optional

See ALSBuilder.train

lambda_ : float, optional

See ALSBuilder.train

other : various, optional

See optional arguments to pyspark.mllib.recommendations.train.