GithubHelp home page GithubHelp logo

mindis / librecommender Goto Github PK

View Code? Open in Web Editor NEW

This project forked from massquantity/librecommender

0.0 3.0 0.0 1.4 MB

Recommender System including multiple algorithms (TensorFlow Based)

License: MIT License

Python 99.77% Shell 0.23%

librecommender's Introduction

LibRecommender

Overview

LibRecommender is an easy-to-use recommender system focused on end-to-end recommendation. The main features are:

  • Implement a number of popular recommendation algorithms such as SVD, DeepFM, BPR etc.

  • A hybrid system, allow user to use either collaborative-filtering or content-based features.

  • Ease of memory usage, automatically convert categorical features to sparse representation.

  • Suitable for both explicit and implicit datasets, and negative sampling can be used for implicit dataset.

  • Making use of Cython or Tensorflow to accelerate model training.

  • Provide end-to-end workflow, i.e. data handling / preprocessing -> model training -> evaluate -> serving.

Usage

pure collaborative-filtering example :
from libreco.dataset import DatasetPure   # pure data, algorithm svd++
from libreco.algorithms import SVDpp

conf = {
    "data_path": "path/to/your/data",
    "length": "all",
}

dataset = DatasetPure()
dataset.build_dataset(**conf)

svd = SVDpp(n_factors=32, n_epochs=200, lr=0.001, batch_size=4096, task="rating")
svd.fit(dataset, verbose=1)
print(svd.predict(1, 2))	     # predict preference of user 1 to item 2
print(svd.recommend_user(1, 7))	 # recommend 7 items for user 1
include features example :
from libreco.dataset import DatasetFeat   # feat data, algorithm DeepFM
from libreco.algorithms import DeepFmFeat

conf = {
    "data_path": "path/to/your/data",
    "length": 500000,
    "user_col": 0,
    "item_col": 1,
    "label_col": 2,
    "numerical_col": [4],
    "categorical_col": [3, 5, 6, 7, 8],
    "merged_categorical_col": None,
    "user_feature_cols": [3, 4, 5],
    "item_feature_cols": [6, 7, 8],
    "convert_implicit": True,
    "build_negative": True,
    "num_neg": 2,
    "sep": ",",
}

dataset = DatasetFeat(include_features=True)
dataset.build_dataset(**conf)

dfm = DeepFmFeat(lr=0.0002, n_epochs=10000, reg=0.1, embed_size=50,
                 batch_size=2048, dropout_rate=0.0, task="ranking", neg_sampling=True)
dfm.fit(dataset, pre_sampling=False, verbose=1)
print(dfm.predict(1, 10))             # predict preference of user 1 to item 10
print(dfm.recommend_user(1, 7))   # recommend 7 items for user 1

Data Format

JUST normal data format, each line represents a sample. By default, model assumes that user, item, and label column index are 0, 1, and 2, respectively. But you need to specify user, item, and label column index if that’s not the case. For Example, the movielens-1m dataset:

1::1193::5::978300760
1::661::3::978302109
1::914::3::978301968
1::3408::4::978300275

leads to the following settings in conf dict : "user_col": 0, "item_col": 1, "label_col": 2, "sep": "::" .

Besides, if you want to use some other meta features (e.g., age, sex, category etc.), numerical and categorical column index must be assigned. For example, "numerical_col": [4], "categorical_col": [3, 5, 6, 7, 8], which means all features must be in a same table.

Installation & Dependencies

From pypi :   pip install LibRecommender

Required Dependencies:
  • Python >= 3.5.4 (3.5.2 will not work -.-)
  • tensorflow >= 1.14
  • numpy >= 1.15.4
  • pandas >= 0.23.4
  • scipy >= 1.2.1
  • scikit-learn >= 0.20.0

References

Algorithm Category Paper
userKNN / itemKNN pure Item-Based Collaborative Filtering Recommendation Algorithms
SVD pure Matrix Factorization Techniques for Recommender Systems
SVD ++ pure Factorization Meets the Neighborhood: a Multifaceted Collaborative Filtering Model
ALS pure 1. Matrix Completion via Alternating Least Square(ALS) /
2. Collaborative Filtering for Implicit Feedback Datasets /
3. Applications of the Conjugate Gradient Method for Implicit Feedback Collaborative Filtering
NCF pure Neural Collaborative Filtering
BPR pure BPR: Bayesian Personalized Ranking from Implicit Feedback
Wide & Deep feat Wide & Deep Learning for Recommender Systems
FM feat Factorization Machines
DeepFM feat DeepFM: A Factorization-Machine based Neural Network for CTR Prediction
YouTubeRec feat Deep Neural Networks for YouTube Recommendations

License

MIT


librecommender's People

Contributors

massquantity avatar

Watchers

James Cloos avatar  avatar paper2code - bot 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.