fmm/oryx-recommend

用于Oryx推荐服务层的PHP客户端

安装: 20

依赖项: 0

建议者: 0

安全: 0

星星: 2

关注者: 1

分支: 0

类型:symfony-bundle

dev-master 2014-02-05 10:39 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:13:30 UTC


README

Oryx开源项目提供简单、实时的大规模机器学习/预测分析基础设施。它基于Apache Mahout库,代表了对Myrrixcloudera/ml项目的统一延续。您可以在这里查看。

此捆绑包帮助与Oryx协同过滤和推荐服务接口。它建立在Guzzle之上,并受到michelsalib的BCCMyrrixBundlebcc-myrrix项目启发。

安装和配置

安装Oryx

有关安装信息,请参阅Oryx文档,您可以在这里获取发行版。

安装捆绑包

通过Composer获取捆绑包

在命令行

composer require fmm/oryx-recommend

手动:将guzzle和fmm/oryx-recommend添加到您的composer.json

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

然后使用composer install安装依赖项。

将捆绑包添加到您的内核

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

设置配置

您必须配置Oryx端点配置

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

运行您的Oryx服务器和计算实例

创建一个名为oryx.conf的文件,包含以下信息

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

并使用以下行运行jar

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

用法

获取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");

开发

信息

代码是在Oryx 0.3.0下开发和测试的

待办事项

数据格式

目前,数据仅以csv字符串接收,应包含在Oryx的下一个版本中,并在捆绑包中添加支持。同时,让收到的csv数据无需解析。