Giter Site home page Giter Site logo

ialspp_python's Introduction

IALS++ Python Binding

This repository contains a Python binding for an adaptation of the code from the Google Research IALS repository. The code implements the model described in the paper iALS++: Speeding up Matrix Factorization with Subspace Optimization.

Table of Contents

Introduction

IALS++ is an efficient matrix factorization algorithm for collaborative filtering, designed to speed up the training process using subspace optimization techniques. This project provides a Python binding to the C++ implementation of IALS++, making it easier to integrate into Python-based data processing and machine learning workflows.

Features

  • Efficient matrix factorization using IALS++.
  • Python binding for easy integration with Python projects.
  • Functions to save and load the trained model.
  • Evaluation metrics for recommendation performance.

Installation

Make sure to install the necessary dependencies:

For MacOS:

brew install eigen
brew install nlohmann-json

For Debian-based Linux:

sudo apt update
sudo apt install libeigen3-dev nlohmann-json3-dev

Finally, you can install the package directly from the GitHub repository.

pip install git+https://github.com/issilva5/ialspp_python.git

Usage

Importing the Package

import ialspp

Loading Data

Create a Dataset object from your data file. The data must have two columns: user id and item id.

train_data = ialspp.Dataset('path/to/train.csv')
test_train_data = ialspp.Dataset('path/to/test_train.csv')
test_test_data = ialspp.Dataset('path/to/test_test.csv')

Creating and Training the Recommender

recommender = ialspp.IALSppRecommender(
    embedding_dim=16,
    num_users=train_data.max_user() + 1,
    num_items=train_data.max_item() + 1,
    regularization=0.0001,
    regularization_exp=1.0,
    unobserved_weight=0.1,
    stddev=0.1,
    block_size=128
)
p = recommender.Train(train_data)
print(recommender.ComputeLosses(train_data, p)) # Print losses information

Evaluating the Recommender

metrics = recommender.EvaluateDataset(test_train_data, test_test_data.by_user())
print(f"Rec20={metrics[0]:.4f}, Rec50={metrics[1]:.4f}, NDCG100={metrics[2]:.4f}")

Saving and Loading the Model

recommender.SaveModel('path/to/model.bin')
loaded_recommender = ialspp.LoadModel('path/to/model.bin')

Examples

For more detailed examples and use cases, please refer to the examples directory in the repository.

Contributing

We welcome contributions! Please read our contributing guidelines to get started.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for more details.

ialspp_python's People

Contributors

issilva5 avatar

Watchers

 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.