LIBFFM Rust
LIBFFM - field-aware factorization machines - in Rust
Getting Started
LIBFFM Rust is available as a Rust library and a command line tool.
Rust Library
Installation
Add this line to your application’s Cargo.toml under [dependencies]:
= "0.2"
How to Use
Prep your data in LIBFFM format
0 0:0:1 1:1:1
1 0:2:1 1:3:1
Train a model
let model = train.unwrap;
Use a validation set and early stopping to prevent overfitting
let model = params
.auto_stop
.train_eval
.unwrap;
Make predictions
let = model.predict.unwrap;
Save the model to a file
model.save.unwrap;
Load a model from a file
let model = load.unwrap;
Training Options
let model = params
.learning_rate // learning rate
.lambda // regularization parameter
.iterations // number of iterations
.factors // number of latent factors
.quiet // quiet mode (no output)
.normalization // use instance-wise normalization
.auto_stop // stop at the iteration that achieves the best validation loss
.on_disk // on-disk training
.train; // train or train_eval
Command Line Tool
Installation
Run:
How to Use
Prep your data in LIBFFM format
0 0:0:1 1:1:1
1 0:2:1 1:3:1
Train a model
Use a validation set and early stopping to prevent overfitting
Make predictions
Training Options
FLAGS:
--auto-stop Stop at the iteration that achieves the best validation loss (must be used with -p)
--in-memory Enable in-memory training
--no-norm Disable instance-wise normalization
--quiet Quiet mode (no output)
OPTIONS:
-r <eta> Set learning rate [default: 0.2]
-k <factor> Set number of latent factors [default: 4]
-t <iteration> Set number of iterations [default: 15]
-l <lambda> Set regularization parameter [default: 0.00002]
-s <nr-threads> Set number of threads [default: 1]
-p <va-path> Set path to the validation set
Credits
This library was ported from the LIBFFM C++ library and is available under the same license.
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development: