Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ibayer/fastFM
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.1
Choose a base ref
...
head repository: ibayer/fastFM
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
95 changes: 95 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
language: c

matrix:
include:
- os: osx
env:
- TRAVIS_PYTHON_VERSION="2.7"
- DEPLOYABLE="true"
- os: osx
env:
- TRAVIS_PYTHON_VERSION="3.5"
- DEPLOYABLE="true"
- os: osx
env:
- TRAVIS_PYTHON_VERSION="3.6"
- DEPLOYABLE="true"
- os: linux
env:
- TRAVIS_PYTHON_VERSION="2.7"
- os: linux
env:
- TRAVIS_PYTHON_VERSION="3.5"
- os: linux
env:
- TRAVIS_PYTHON_VERSION="3.6"
#- services: docker
# sudo: required
# env:
# - DEPLOY_TARGET="manylinux1"
# - DEPLOYABLE="true"

dist: trusty

before_install:
- |
# Skip if manylinux1
if [ "$DEPLOY_TARGET" = "manylinux1" ]; then
echo "Skip before_install step..."
else
# fastFM-core depends on cblas
if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; sudo apt-get install -y libopenblas-dev; fi
if [[ "$TRAVIS_PYTHON_VERSION" =~ "^2" ]]; then
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh -O miniconda.sh;
fi
else
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
fi
fi
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
# Useful for debugging any issues with conda
conda info -a
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION cython numpy pandas scipy scikit-learn nose
source activate test-environment
fi
install:
- |
git submodule update --init --recursive
if [ "$DEPLOY_TARGET" = "manylinux1" ]; then
:
else
make
python setup.py bdist_wheel
pip install dist/*.whl
fi
script:
- |
if [ "$DEPLOY_TARGET" = "manylinux1" ]; then
#build for 64-bit
docker run --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/.travis/build-wheels.sh
else
nosetests
fi
deploy:
provider: releases
api_key:
secure: AJcZoe2+OiMJ4VlSkASAeMc/ii0ZRnj2PFaaL7zlSbx1THMpY/49U5BSyqX1PQioPSlTV3ZsIXI3u7KyqoXIQSXWzAuaBzpLTLS85fGSuTvUuexmaJtKU92OC143tuVVLCPnjC992+1uyctjrxMSqgoaUolfYkEftt5RGrMIKl2duGfDXrPXIueHSl8FQGXkmlY6NqkRx2v5kxsAjFcurvwTNU8ptJ84jVKjrE6t1IB61vp2eUcqVR/z6Lwau6mdvIybglnbH4lCMXP98zEIibLA8vbn3XxrC+0uU7Kjz37K6/CsJEPNL5tujJDMRKAupnrkgPsAGTpsAn6O6uLUz0ISgcen8R6KJ7cBli+cq08OZ3JLLoJpqkni62YVSQV+uYkQk9b5Pu09vUTOozJMnOqLSj9hVIswyxGiFPcTFskMgqMdx15M59gd0YpXH633YqwBgRmWNsctp4BKnTaE3iGW6aZc8lrXxpL7qcVAosjmpjLp3jiPXVSRdYf0yHl6pDUj5ZVyu27kAn1/I9JL0nH19zjXF2tUlEjuT9ydHwnhmsgBN/V+JhZxi7ZeEbOZfY1MfekKM/NwSRehVEp/J0XWqWg+kIXRU/rqY1/w0vLVNFeQirpEjUp39eCBydXeS3Bik8uANW2UTxojJo3LBfLLoAT8ZWFb3YrIBAYkzjc=
file_glob: true
file: dist/fastFM-*.whl
skip_cleanup: true
on:
tags: true
condision: $DEPLOYEABLE = "true"
39 changes: 39 additions & 0 deletions .travis/build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#
#Author: Likhith Chitneni
#License: BSD 3 Clause license - https://opensource.org/licenses/BSD-3-Clause
#

set -e -x

# Install any system packages required here
#yum install -y $PACKAGE_TO_BE_INSTALLED

#Remove Python 2.6 and 3.3 since numpy requires >=2.7 or >=3.4
rm -rf /opt/python/cpython-2.6.9-*
rm -rf /opt/python/cp33-cp33m

#Make fastFM-core
cd /io/fastFM-core
make clean && make
cd /

#Compile wheels
for PYBIN in /opt/python/*/bin; do
"${PYBIN}/pip" install -r /io/requirements.txt
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
done

# Bundle external shared libraries into the wheels
for whl in wheelhouse/*.whl; do
auditwheel repair "$whl" -w /io/wheelhouse/
done

# Install packages and test
for PYBIN in /opt/python/*/bin; do
"${PYBIN}/pip" install fastFM --no-index -f /io/wheelhouse
"${PYBIN}/pip" install nose
(cd "$HOME"; "${PYBIN}/nosetests" /io/fastFM/tests)
done

mv /io/wheelhouse /io/dist
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include README.rst
include fastFM/ffm.c
include fastFM/ffm.pxy
include fastFM/cffm.pxd
recursive-include fastFM-core/include *
include fastFM-core/bin/libfastfm.a
include fastFM-core/externals/CXSparse/Lib/libcxsparse.a
recursive-include fastFM-core/externals/CXSparse/Include *
recursive-include fastFM-core/externals/CXSparse/SuiteSparse_config *
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PYTHON ?= python

all:
( cd fastFM-core ; $(MAKE) lib )
python setup.py build_ext --inplace
$(PYTHON) setup.py build_ext --inplace

.PHONY : clean
clean:
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
Citing fastFM
=============

The library fastFM is an academic project. The time and resources spent
developing fastFM are therefore justified by the number of citations of
the software. If you publish scientific articles using fastFM, please
cite the following article (bibtex entry
[citation.bib](http://jmlr.org/papers/v17/15-355.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](https://travis-ci.org/ibayer/fastFM.svg?branch=master)](https://travis-ci.org/ibayer/fastFM)
[![image](https://img.shields.io/badge/platform-OSX%7CLinux-lightgrey.svg)](https://travis-ci.org/ibayer/fastFM)
[![image](https://img.shields.io/pypi/l/Django.svg)](https://travis-ci.org/ibayer/fastFM)

This repository allows you to use Factorization Machines in **Python**
(2.7 & 3.x) with the well known **scikit-learn API**. All performance
critical code has been written in C and wrapped with Cython. fastFM
provides stochastic gradient descent (SGD) and coordinate descent (CD)
optimization routines as well as Markov Chain Monte Carlo (MCMC) for
Bayesian inference. The solvers can be used for regression,
classification and ranking problems. Detailed usage instructions can be
found in the [online documentation](http://ibayer.github.io/fastFM) and
on [arXiv](http://arxiv.org/abs/1505.00641).

Supported Operating Systems
---------------------------

fastFM has a continuous integration / testing servers (Travis) for
**Linux (Ubuntu 14.04 LTS)** and **OS X Mavericks**. Other OSs are not
actively supported.

Usage
-----

``` {.python}
from fastFM import als
fm = als.FMRegression(n_iter=1000, init_stdev=0.1, rank=2, l2_reg_w=0.1, l2_reg_V=0.5)
fm.fit(X_train, y_train)
y_pred = fm.predict(X_test)
```

Tutorials and other information are available
[here](http://arxiv.org/abs/1505.00641). The C code is available as
[subrepository](https://github.com/ibayer/fastFM-core) and provides a
stand alone command line interface. If you still have **questions**
after reading the documentation please open an issue at GitHub.

| 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
------------

**binary install (64bit only)**

`pip install fastFM`

**source install**

*Please make sure, that Python and OS bit version agree, e.g. 32bit
Python on 64bit OS won\'t work.*

``` {.bash}
# Install cblas and python-dev header (Linux only).
# - cblas can be installed with libatlas-base-dev or libopenblas-dev (Ubuntu)
$ sudo apt-get install python-dev libopenblas-dev
# Clone the repo including submodules (or clone + `git submodule update --init --recursive`)
$ git clone --recursive https://github.com/ibayer/fastFM.git
# Enter the root directory
$ cd fastFM
# Install Python dependencies (Cython>=0.22, numpy, pandas, scipy, scikit-learn)
$ pip install -r ./requirements.txt
# Compile the C extension.
$ make # build with default python version (python)
$ PYTHON=python3 make # build with custom python version (python3)
# Install fastFM
$ pip install .
```

Tests
-----

The Python tests (`pip install nose`) can be run with:
`nosetests fastFM/fastFM/tests`

Please refer to the fastFM-core README for instruction on how to run the
C tests at `fastFM/fastFM-core/src/tests`.

Contribution
------------

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

**Contributions are very welcome!** Since this project lives on GitHub
we recommend 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](https://travis-ci.org/ibayer/fastFM) to run checks on your changes.

Most information you need to setup your **development environment** can
be learned by adapting the great instructions on
<https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md>
. Please ensure that your contribution conforms to the
[PEP8](http://www.python.org/dev/peps/pep-0008/) Coding Style and
includes unit tests where appropriate. More valuable guidelines that
apply to fastFM can be found at
<http://scikit-learn.org/stable/developers/contributing.html#coding-guidelines>
.

**Contributors**

- [aaossa](https://github.com/aaossa/)
- [altimin](https://github.com/altimin)
- [bdaskalov](https://github.com/bdaskalov)
- [chezou](https://github.com/chezou)
- [macks22](https://github.com/macks22)
- [takuti](https://github.com/takuti)
- [ibayer](https://github.com/ibayer)

License: BSD
------------

<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.palaimon.io/matomo.php?idsite=2&amp;rec=1" style="border:0" alt="" />
<!-- End Matomo -->
70 changes: 0 additions & 70 deletions README.rst

This file was deleted.

5 changes: 4 additions & 1 deletion doc/api.rst
Original file line number Diff line number Diff line change
@@ -7,22 +7,25 @@ The MCMC module

.. automodule:: fastFM.mcmc
:members:
:inherited-members: predict

The ALS module
---------------

.. automodule:: fastFM.als
:members:
:inherited-members: predict

The SGD module
--------------

.. automodule:: fastFM.sgd
:members:

:inherited-members: predict

The Ranking module
------------------

.. automodule:: fastFM.bpr
:members:
:inherited-members: predict
Loading