Skip to content

A php client for the Oryx recommendation service and computation layers build on top of Guzzle

Notifications You must be signed in to change notification settings

cberez/FMMOryxBundle

Repository files navigation

Oryx Bundle

The Oryx open source project provides simple, real-time large-scale machine learning / predictive analytics infrastructure. It is built on the Apache Mahout libraries and represents a unified continuation of the Myrrix and cloudera/ml projects. You can check it out here.

This bundle helps to interface with the Oryx Collaborative filtering and Recommendation services. It is built on top of Guzzle and inspired by michelsalib's BCCMyrrixBundle and bcc-myrrix projects.

Installation & configuration

Install Oryx

See the Oryx doc for installation, you can get releases here.

Install the bundle

Get the Bundle via Composer

In the command line :

composer require fmm/oryx-recommend

Manually : add guzzle and fmm/oryx-recommend to your composer.json :

{
  "require": 
  {
    "guzzle/guzzle": "dev-master",
    "fmm/oryx-recommend": "dev-master"
  }
}

and then install the dependencies with composer install.

Add the bundle to your kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new FMM\OryxBundle\FMMOryxBundle(),
        // ...
    );
}

Set the configuration

You have to configure the Oryx endpoint configuration :

// app/config/config.yml
fmm_oryx:
    host: localhost # The Oryx host
    port: 8080      # The Oryx port
    username: test  # The Oryx username
    password: 1234  # The Oryx password

Run your Oryx server and computation instances

Create a file called oryx.conf with the following informations :

model=${als-model}
model.local-computation=false
model.local-data=false
model.instance-dir=/user/name/repo
model.features=25
model.lambda=0.065
serving-layer.api.port=8091
computation-layer.api.port=8092

And run the jars with the following lines :

java -Dconfig.file=oryx.conf -jar oryx-computation-x.y.z.jar
java -Dconfig.file=oryx.conf -jar oryx-serving-x.y.z.jar

Usage

Get an instance of OryxService :

// Get an instance
$oryx = $this->get('fmm_oryx.service');

// Set a user/item association between user #22, item #888 of strength 0.8
$oryx->setPreference(22, 888, 0.8);

// Refresh the index
$oryx->refresh();

// Get recommendations as csv
$csv = $oryx->getRecommendation(22); // example : 325,0.5\n98,0.44

// Parse it and get an array of strings "id,strength"
$recommendations = str_getcsv($csv, "\n");

DEVELOPMENT

Info

The code was developped and tested with Oryx 0.3.0

TODO

Data format

For now, data is received only as a csv string, json should be included in Oryx' next version and support added to the bundle. Also make it so that we don't have to parse the received csv data.

About

A php client for the Oryx recommendation service and computation layers build on top of Guzzle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages