Project

libffm

0.0
No release in over a year
Field-aware factorization machines for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 4.0.2
 Project Readme

LIBFFM Ruby

LIBFFM - field-aware factorization machines - for Ruby

Build Status

Installation

Add this line to your application’s Gemfile:

gem "libffm"

Getting Started

Prep your data in LIBFFM format

0 0:0:1 1:1:1
1 0:2:1 1:3:1

Create a model

model = Libffm::Model.new
model.fit("train.txt")

Make predictions

model.predict("test.txt")

Save the model to a file

model.save_model("model.bin")

Load the model from a file

model.load_model("model.bin")

Pass a validation set

model.fit("train.txt", eval_set: "validation.txt")

Parameters

Pass parameters - default values below

Libffm::Model.new(
  eta: 0.2,                # learning rate
  lambda: 0.00002,         # regularization parameter
  nr_iters: 15,            # number of iterations
  k: 4,                    # number of latent factors
  normalization: true,     # use instance-wise normalization
  auto_stop: false         # stop at the iteration that achieves the best validation loss
)

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone --recursive https://github.com/ankane/libffm-ruby.git
cd libffm-ruby
bundle install
bundle exec rake compile
bundle exec rake test