README.md in libmf-0.3.0 vs README.md in libmf-0.4.0
- old
+ new
@@ -2,11 +2,11 @@
[LIBMF](https://github.com/cjlin1/libmf) - large-scale sparse matrix factorization - for Ruby
Check out [Disco](https://github.com/ankane/disco) for higher-level collaborative filtering
-[![Build Status](https://github.com/ankane/libmf-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/libmf-ruby/actions)
+[![Build Status](https://github.com/ankane/libmf-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/libmf-ruby/actions)
## Installation
Add this line to your application’s Gemfile:
@@ -166,9 +166,30 @@
Calculate AUC (for one-class MF)
```ruby
model.auc(data, transpose)
+```
+
+## Example
+
+Download the [MovieLens 100K dataset](https://grouplens.org/datasets/movielens/100k/) and use:
+
+```ruby
+require "csv"
+
+train_set = Libmf::Matrix.new
+valid_set = Libmf::Matrix.new
+
+CSV.foreach("u.data", col_sep: "\t").with_index do |row, i|
+ data = i < 80000 ? train_set : valid_set
+ data.push(row[0].to_i, row[1].to_i, row[2].to_f)
+end
+
+model = Libmf::Model.new(factors: 20)
+model.fit(train_set, eval_set: valid_set)
+
+puts model.rmse(valid_set)
```
## Performance
For performance, read data directly from files