Giter Club home page Giter Club logo

quackin's Introduction

Quackin

travis crates

Release the quackin! ๐Ÿฆ†

Quackin is a recommender systems framework written in Rust. This is a young project, which means two things:

  • There will be a lot of breaking changes until version 1.0
  • Is a perfect project for your contributions ;)

Quackin was concieved as a framework for collaborative filtering recommender systems. But it is open to new ideas. If you want to contribute in some way open or start working on an issue or ping me at [email protected].

One of the difficulties for developing this crate is that the Rust's machine learning and data mining ecosystem is on an early stage, then there is no standard libraries for anything yet. Nevertheless, I believe that we should take advantage of the control and speed that Rust offers to provide a competitive alternative to frameworks written in languages with a more developed ecosystem like Python or Java.

Getting started

We will write a simple movie recommender engine using Quackin over one of the movielens dataset. Download ml-latest-small.zip from here, and then extract the ratings.csv file.

Loading data into Quackin

First we need to load the movielens dataset into Rust. This dataset has the following columns: userId, movieId, rating and timestamp. We must tell quackin that this file has this columns in this specific order. Also, we need to specify if this file has headers or not and which delimiter is separating the values`.

use quackin::data::{Record, ReadOptions, read_custom_records};
quackin::data::Field::*;

let options = ReadOptions::custom(vec![UserID, ItemID, Rating, Other], true, ',').unwrap();
//                                                             ^^^^^   ^^^^  ^^^
//                                                             |       |     |
//                             we don't care about the timestamp.      |     |
//                                                 this file has headers.    |
//                                                    use comma as a delimiter.

Whew, thats a lot of boilerplate for just loading the dataset. But this was the hardest part of the process. Now lets load the dataset:

let records = read_custom_records("/path/to/movielens", options);

Thats it! now let's build a recommender

Creating a recommender

We will use a traditional K-nearest neighbors algorithm to build a basic recommender. For each user we will take the 50 nearest users to him, using a cosine similarity

use quackin::recommender::{KnnUserRecommender, Recommender};
use quackin::metrics::similarity::cosine;

let recommender = KnnUserRecommender::from_records(&records, cosine, 50);

Now we can ask predictions from the recommender. For example, the user with user ID 1 gave a rating of 4 to the classic science fiction movie "Tron". What would our recommender predict about this?

println!("{:?}", recommender.predict("1", "2105"));
// Ok(3.504942020280084)

Not bad! we aren't that far from the real rating. Now you can start recommending movies to everyone!

quackin's People

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.