Code Monkey home page Code Monkey logo

recompy's Introduction

Recompy

Recompy is a library for recommender systems. It provides an easy framework to train different models, calculate similarities and recommend items for both existing and new users.

Recompy is a fairly optimized and lightweight library. Its only dependency is numpy library which is downloaded automatically when you pip install recompy. This feature is useful if you decide to run recompy on server side.

Recompy lets you search parameter space for finding the best model for your data. It keeps best features in memory depending on the test set error. Early stopping is also available. When it is set to an integer, training will be stopped if test set error doesn't improve for the last given epochs.

Current version supports algorithms below:

  • FunkSVD
  • NearestNeighbour
  • NMF
  • SVD++
  • ALS

In upcoming version:

  • Approximate Nearest Neighbors for better performance
  • Framework refactors will come.

Recompy also comes bundled with MovieLens data which consists of 100.000 user, rating pair.

Installation

pip install recompy

Usage

from recompy import load_movie_data, FunkSVD

# get MovieLens data
data = load_movie_data()
# initialization of FunkSVD model
myFunk = FunkSVD()
# training of the model
myFunk.fit(data)

# Create new user. Key:Item ID, Value:Rating
new_user = {'1':5,
            '2':4,
            '4':3}
            
# To find the most similar user resulting from cosine similarity. Recommend 5 items using the most similar user 
myFunk.get_recommendation_for_new_user(new_user, similarity_measure = 'cosine_similarity', 
                                       howManyUsers = 1, howManyItems = 5)

Available Methods for FunkSVD

set_hyperparameters():

A method to set hyperparameters for searching parameter space. Arguments:

initialization_method : How to initialize user and item embeddings

  • random ( default )
  • he
  • normal

max_epoch : Epoch count to train model. Default is 5.
n_latent : Length of user and item embeddings. Default is 10
learning_rate : Learning rate of the model. Default is 0.01
regularization : Regularization rate of the model. DEfault is 0.1
early_stopping : Number of epochs to stop if test error doesn't improve. Default is False.
init_mean : Initialization mean if initialization method is normal.
init_std : Initialization standard deviation if initialization is normal\

fit():

Trains FunkSVD model.Arguments:

data : Training data as numpy array.
test_split : Split data into train and test set. Default is True. test_portion : Portion of test set. Default is 0.10. search_parameter_space : If true, data will not split into train and test sets again.

get_recommendation_for_existing_user():

Gets recommendations for existing user that are not rated by user. Arguments:

user_id : Existing user id

howMany : Count of recommended items to be returned. Default is 10.

get_recommendation_for_new_user():

Gets recommendations for new user depending on given similarity measure. Arguments:

user_ratings : A python dictionary of items and corresponding scores.

similarity_measure : Similarity measures can be:

  • cosine_similarity
  • pearson_correlation
  • adjusted_cosine_similarity
  • weighted_cosine_similarity
  • constrained_pearson_correlation
  • mean_squared_difference ( default )

howManyUsers : Count of most similar users to be used for recommendation. Default is 3

howManyItems : Count of recommended items to be returned. Default is 5.

get_similar_products():

Gets most similar items. Arguments:

item_id : Id of the item.

howMany : Count of similar items to be returned.

Note

This library is created as a part of AI Projects program @ inzva. You can see more at inzva.com

recompy's People

Contributors

canbul avatar emreeyukseel avatar moguzka avatar onurboyar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.