Code Monkey home page Code Monkey logo

gorse's Introduction

gorse: Go Recommender System Engine

Build Build (AVX2) Coverage Document Report
Build Status Build Status codecov GoDoc Go Report Card

gorse is a a transparent recommender system engine over SQL database based on collaborative filtering written in Go.

Install

go get github.com/zhenghaoz/gorse/...

Build

go build github.com/zhenghaoz/gorse/cmd/gorse

If the CPU of your device supports AVX2 and FMA3 instructions, use the avx2 build tag to enable AVX2 support.

go build -tags='avx2' github.com/zhenghaoz/gorse/cmd/gorse

Usage

It's easy to setup a recomendation service with gorse.

  • Step 1: initialize the database.
./gorse init user:pass@host/database

It connects to a SQL database and creates several tables. user:pass@host/database is the database used to store data of gorse.

  • Step 2: Import ratings and Items.
./gorse data user:pass@host/database \
	--import-ratings-csv u.data \
	--import-items-csv u.item

It imports ratings and items from CSV files. u.data is the CSV file of ratings in MovieLens 100K dataset and u.item is the CSV file of items in MovieLens 100K dataset.

  • Step 3: Start a server.
./gorse server -c config.toml

Load configurations from config.toml and start a recommendation server. It may take a while to generate all recommendations.

# This section declares settings for the server.
[server]
host = "127.0.0.1"      # server host
port = 8080             # server port

# This section declares setting for the database.
[database]
driver = "mysql"        # database driver
access = "gorse:password@/gorse"# database access

# This section declares settings for recommendation.
[recommend]
model = "svd"           # recommendation model
cache_size = 100        # the number of cached recommendations
update_threshold = 10   # update model when more than 10 ratings are added
check_period = 1        # check for update every one minute
similarity = "pearson"  # similarity metric for neighbors

# This section declares hyperparameters for the recommendation model.
[params]
optimizer = "bpr"       # the optimizer to oprimize matrix factorization model
n_factors = 10          # the number of latent factors
reg = 0.01              # regularization strength
lr = 0.05               # learning rate
n_epochs = 100          # the number of learning epochs
init_mean = 0.0         # the mean of initial latent factors initilaized by Gaussian distribution
init_std = 0.001        # the standard deviation of initial latent factors initilaized by Gaussian distribution
  • Step 4: Send requests.
curl 127.0.0.1:8080/recommends/1?number=5

Request 5 recommended items for the 1-th user. See more APIs in wiki.

{
  "Failed": false,
  "Items": [284, 448, 763, 276, 313]
}

Document

  • Visit GoDoc for detailed documentation of codes.
  • Visit Wiki for tutorial, examples and high-level introduction.

Contributors

Any kind of contribution is expected: report a bug, give a advice or even create a pull request.

Acknowledgments

gorse was inspired by following projects:

Limitations

gorse has limitations and might not be applicable to some scenarios:

  • No Scalability: Since gorse is a recommendation service on a single host, it's unable to handle large data. The bottleneck might be memory size or the performance of SQL database.
  • No Feature Engineering: gorse only uses interactions between items and users while features of items, users and contexts are ignored. This is not the best practice in real world.
  • Naive Policy: There are lots of considerations on a recommender system such as the freshness of items, the variation of users' preferences ,etc. They are not included in gorse.

gorse's People

Contributors

deslum avatar zhenghaoz avatar

Watchers

 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.