elliot.recommender.knn.user_knn package

Submodules

elliot.recommender.knn.user_knn.aiolli_ferrari module

Created on 23/10/17 @author: Maurizio Ferrari Dacrema

class elliot.recommender.knn.user_knn.aiolli_ferrari.AiolliSimilarity(data, maxk=40, shrink=100, similarity='cosine', implicit=False, normalize=True, asymmetric_alpha=0.5, tversky_alpha=1.0, tversky_beta=1.0, row_weights=None)[source]

Bases: object

get_model_state()[source]
get_user_recs(u, mask, k)[source]
initialize()[source]
load_weights(path)[source]
save_weights(path)[source]
set_model_state(saving_dict)[source]
class elliot.recommender.knn.user_knn.aiolli_ferrari.Compute_Similarity(dataMatrix, topK=100, shrink=0, normalize=True, asymmetric_alpha=0.5, tversky_alpha=1.0, tversky_beta=1.0, similarity='cosine', row_weights=None)[source]

Bases: object

applyAdjustedCosine()[source]

Remove from every data point the average for the corresponding row :return:

applyPearsonCorrelation()[source]

Remove from every data point the average for the corresponding column :return:

compute_similarity(start_col=None, end_col=None, block_size=100)[source]

Compute the similarity for the given dataset :param self: :param start_col: column to begin with :param end_col: column to stop before, end_col is excluded :return:

useOnlyBooleanInteractions()[source]
elliot.recommender.knn.user_knn.aiolli_ferrari.check_matrix(X, format='csc', dtype=<class 'numpy.float32'>)[source]

This function takes a matrix as input and transforms it into the specified format. The matrix in input can be either sparse or ndarray. If the matrix in input has already the desired format, it is returned as-is the dtype parameter is always applied and the default is np.float32 :param X: :param format: :param dtype: :return:

elliot.recommender.knn.user_knn.user_knn module

Module description:

class elliot.recommender.knn.user_knn.user_knn.UserKNN(data, config, params, *args, **kwargs)[source]

Bases: elliot.recommender.recommender_utils_mixin.RecMixin, elliot.recommender.base_recommender_model.BaseRecommenderModel

GroupLens: An Open Architecture for Collaborative Filtering of Netnews

For further details, please refer to the paper

Parameters
  • neighbors – Number of item neighbors

  • similarity – Similarity function

  • implementation – Implementation type (‘aiolli’, ‘classical’)

To include the recommendation model, add it to the config file adopting the following pattern:

models:
  UserKNN:
    meta:
      save_recs: True
    neighbors: 40
    similarity: cosine
    implementation: aiolli
get_recommendations(k: int = 10)[source]
get_single_recommendation(mask, k, *args)[source]
property name
train()[source]

elliot.recommender.knn.user_knn.user_knn_similarity module

class elliot.recommender.knn.user_knn.user_knn_similarity.Similarity(data, num_neighbors, similarity, implicit)[source]

Bases: object

Simple kNN class

get_model_state()[source]
get_user_recs(u, mask, k)[source]
initialize()[source]

This function initialize the data model

load_weights(path)[source]
process_similarity(similarity)[source]
save_weights(path)[source]
set_model_state(saving_dict)[source]

Module contents