Code Monkey home page Code Monkey logo

fastfm-core's Introduction

Citing fastFM

The library fastFM is an academic project. The time and resources spent developing fastFM are therefore justifyed by the number of citations of the software. If you publish scienctific articles using fastFM, pleease cite the following article (bibtex entry citation.bib).

Bayer, I. "fastFM: A Library for Factorization Machines" Journal of Machine Learning Research 17, pp. 1-5 (2016)

fastFM: A Library for Factorization Machines

image

image

image

This repository contains the source code for the fastFM C library and the stand-alone comand line interface (cli). In general we recommend to use fastFM with the Python interface.

Usage

fastFM-core/bin/bin/fastfm data/train_regression data/test_regression \
--task regression   \
--rng-seed 1234     \
--init-var=0.11     \
--n-iter=123        \
--solver='mcmc'     \
--rank 7            \
--l2-reg=.22

Examples on how to use the other command line options options, including example data, can be found in fastFM-core/demo/Makefile. The demo/ folder contains examples showing how to use fastFM as C library.

+----------------+------------------+-----------------------------+ | Task | Solver | Loss | +================+==================+=============================+ | Regression | als, mcmc, sgd | Square Loss | +----------------+------------------+-----------------------------+ | Classification | als, mcmc, sgd | Probit(Map), Probit, Sigmoid| +----------------+------------------+-----------------------------+ | Ranking | sgd | BPR | +----------------+------------------+-----------------------------+ Supported solvers and tasks

Installation

OS X: Library compiles on OSX, however console interface doesn't.

# Install cblas (Linux only).
$ sudo apt-get install libatlas-base-dev

# Clone the repro including submodules (or clone + `git submodule update --init --recursive`)
$ git clone --recursive https://github.com/ibayer/fastFM-core.git

# Build library
$ cd fastFM-core/; make;

# Build command line interface (currently this works on linux only)
$ make cli

Tests

OS X: Recommended way to manage dependencies is Homebrew package manager. If you have brew installed, dependencies can be installed by running command brew install glib gsl argp-standalone.

# The tests require the glib and gsl library (Linux, for OSX see above).
$ sudo apt-get install libglib2.0-dev libgsl0-dev

$ cd fastFM-core/src/tests

# Build the tests
$ make

# Run all tests
$ make check

Contribution

  • Star this repository: keeps contributors motivated
  • Open a issue: report bugs or suggest improvements
  • Fix errors in the documentation: small changes matter
  • Contribute code

Contributions are very wellcome! Since this project lives on github we reommend to open a pull request (PR) for code contributions as early as possible. This is the fastest way to get feedback and allows Travis CI to run checks on your changes.

Development Guidlines

  • check coding style (google) lang-format-3.5 -style=google -i <YOUR_FILE.c/h>
  • static code analysis clang-tidy-3.5 -fix <YOUR_FILE.c/h> -- I.
  • run valgrind memory check on sparse_test.c make mem_check
  • run valgrind to check for errors valgrind -v ./a.out >& out

Contributors

  • takuti
  • altimin
  • ibayer

License: BSD

fastfm-core's People

Contributors

altimin avatar dselivanov avatar iramykytyn avatar takuti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fastfm-core's Issues

compile on Mac

Rockys-MacBook-Pro:fastFM rockyrock$ make
( cd fastFM-core ; /Applications/Xcode.app/Contents/Developer/usr/bin/make lib )
( cd src ; /Applications/Xcode.app/Contents/Developer/usr/bin/make lib )
c99 `pkg-config --cflags glib-2.0` -fPIC -g -Wall -O3 -I/include -I./src -I../externals/CXSparse/Include   -c -o kmath.o kmath.c
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c99: illegal option -- f
usage: c99 [-cEgs] [-D name[=value]] [-I directory] ... [-L directory] ...
       [-o outfile] [-O optlevel] [-U name]... [-W 64] operand ...
make[2]: *** [kmath.o] Error 1
make[1]: *** [lib] Error 2
make: *** [all] Error 2

@rakandirbas
Thanks for reporting this issue for fastFM (py). I think it's best to solve the issue for fastFM-core first and then move on to the python interface.

implement mcmc in python

Can I use numpy .random.normal or .gamma as the function ffm_rand_normal? I just code as the sparse_fit func but it not work ...

other solvers for BPR loss?

Is there any reason that only sgd solver is supported for BPR loss ? ALS or MCMC is not applicable for pairwise loss ?

Cannot build on Ubuntu/16.04

Hi. I would like to make some modification on fastfm but I couldn't compile this fastfm-core module. I'm using Ubuntu/16.04 with gcc 5.4.0 .

Here is my compile error log. Looks it is a OpenBlas problem though.

$ make                            
( cd externals/CXSparse ; make library )
make[1]: Entering directory '/home/du/workspace/fastFM/fastFM-core/externals/CXSparse'
( cd Lib ; make )
make[2]: Entering directory '/home/du/workspace/fastFM/fastFM-core/externals/CXSparse/Lib'
make[2]: Nothing to be done for 'default'.
make[2]: Leaving directory '/home/du/workspace/fastFM/fastFM-core/externals/CXSparse/Lib'
make[1]: Leaving directory '/home/du/workspace/fastFM/fastFM-core/externals/CXSparse'
( export USE_THREAD=0; cd externals/OpenBLAS ; make libs)
make[1]: Entering directory '/home/du/workspace/fastFM/fastFM-core/externals/OpenBLAS'
getarch_2nd.c: In function ‘main’:
getarch_2nd.c:12:35: error: ‘SGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function)
     printf("SGEMM_UNROLL_M=%d\n", SGEMM_DEFAULT_UNROLL_M);
                                   ^
getarch_2nd.c:12:35: note: each undeclared identifier is reported only once for each function it appears in
getarch_2nd.c:13:35: error: ‘SGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function)
     printf("SGEMM_UNROLL_N=%d\n", SGEMM_DEFAULT_UNROLL_N);
                                   ^
getarch_2nd.c:14:35: error: ‘DGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function)
     printf("DGEMM_UNROLL_M=%d\n", DGEMM_DEFAULT_UNROLL_M);
                                   ^
getarch_2nd.c:15:35: error: ‘DGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function)
     printf("DGEMM_UNROLL_N=%d\n", DGEMM_DEFAULT_UNROLL_N);
                                   ^
getarch_2nd.c:19:35: error: ‘CGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function)
     printf("CGEMM_UNROLL_M=%d\n", CGEMM_DEFAULT_UNROLL_M);
                                   ^
getarch_2nd.c:20:35: error: ‘CGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function)
     printf("CGEMM_UNROLL_N=%d\n", CGEMM_DEFAULT_UNROLL_N);
                                   ^
getarch_2nd.c:21:35: error: ‘ZGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function)
     printf("ZGEMM_UNROLL_M=%d\n", ZGEMM_DEFAULT_UNROLL_M);
                                   ^
getarch_2nd.c:22:35: error: ‘ZGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function)
     printf("ZGEMM_UNROLL_N=%d\n", ZGEMM_DEFAULT_UNROLL_N);
                                   ^
getarch_2nd.c:69:50: error: ‘SGEMM_DEFAULT_Q’ undeclared (first use in this function)
     printf("#define SLOCAL_BUFFER_SIZE\t%ld\n", (SGEMM_DEFAULT_Q * SGEMM_DEFAULT_UNROLL_N * 4 * 1 *  sizeof(float)));
                                                  ^
getarch_2nd.c:70:50: error: ‘DGEMM_DEFAULT_Q’ undeclared (first use in this function)
     printf("#define DLOCAL_BUFFER_SIZE\t%ld\n", (DGEMM_DEFAULT_Q * DGEMM_DEFAULT_UNROLL_N * 2 * 1 *  sizeof(double)));
                                                  ^
getarch_2nd.c:71:50: error: ‘CGEMM_DEFAULT_Q’ undeclared (first use in this function)
     printf("#define CLOCAL_BUFFER_SIZE\t%ld\n", (CGEMM_DEFAULT_Q * CGEMM_DEFAULT_UNROLL_N * 4 * 2 *  sizeof(float)));
                                                  ^
getarch_2nd.c:72:50: error: ‘ZGEMM_DEFAULT_Q’ undeclared (first use in this function)
     printf("#define ZLOCAL_BUFFER_SIZE\t%ld\n", (ZGEMM_DEFAULT_Q * ZGEMM_DEFAULT_UNROLL_N * 2 * 2 *  sizeof(double)));
                                                  ^
make[1]: *** [getarch_2nd] Error 1
Makefile:123: *** OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail..  Stop.
make[1]: Leaving directory '/home/du/workspace/fastFM/fastFM-core/externals/OpenBLAS'
Makefile:3: recipe for target 'lib' failed
make: *** [lib] Error 2

By the way, the doc says I have to install OpenBLAS with apt-get but the makefile code looks just using extrenals/OpenBLAS, not system OpenBLAS. Is this build procedure correct?

Remove unnecessary includes

Remove argp and glib includes from fastfm.h. This headers are not needed to build the library.
glib provides the testing framework. We need to check if it's used elsewhere. argp is only used for the command line interface.

Cannot save model (weight vector + matrix) from CLI?

I can only see an argument to save the (test) predictions themselves but not for saving the trained model weights (the vector and matrix). Did I miss something or is this something I should implement myself? Interested in a PR to the CLI if I do this?

Segmentation fault with "sgd" solver

Thanks for your work - FastFM is amazing (and in future I want to contribute to your project and create R bindings).
Currently however I'm using CLI interface. Both "mcmc" and "als" solvers work fine on my dataset, but "sgd" produces: "Segmentation fault (core dumped)". Here are files to reproduce error. I use following command:

./bin/fastfm train_1e6.svmlight train_1e6.svmlight --task='classification' --n-iter=10 --solver='sgd' --rank 5

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.