linkthrow/laravel-5-predictionio

Laravel 5 对 PredictionIO v0.9.* 的包装

dev-master 2016-07-29 14:34 UTC

This package is not auto-updated.

Last update: 2024-09-18 19:23:02 UTC


README

*基于 michaeljhopkins

The Laravel PredictionIO 库提供了一个客户端,该客户端提供了对 PredictionIO 推荐引擎的轻松访问。PredictionIO 是一个开源的机器学习服务器,软件开发者可以创建预测功能,如个性化、推荐和内容发现。

通过一组简单的调用,将所有服务器功能暴露给您的应用程序。您可以为用户和物品添加,在这些用户和物品之间注册动作,并通过任何 PredictionIO 推荐引擎检索从这个信息中推导出的推荐。应用程序范围从在在线商店中显示推荐产品到在社交协作网络中发现相关专家。

安装

  • 安装库和依赖项
$ composer require "linkthrow/laravel-5-predictionio"
  • app/config/app.php 中添加 提供者
    LinkThrow\LaravelPredictionIO\Provider\PredictionIOServiceProvider::class
  • app/config/app.php 中添加 别名
    'EngineClient'      => LinkThrow\LaravelPredictionIO\Facades\EngineFacade::class,
        'EventClient'       => LinkThrow\LaravelPredictionIO\Facades\EventFacade::class,
	'predictionio' => [
		'key' => '0250b3f85ce33284f77c77f36b41010ef2c4fc5c',
		'url' => 'https://:7200'
	],

从您的应用程序设置用户记录

// assume you have a user with user ID 5
$response = EventClient::setUser(5);

从您的应用程序设置物品记录

// assume you have a book with ID 'bookId1' and we assign 1 as the type ID for book
$response = EventClient::setItem('bookId1', array('itypes' => 1));

从您的应用程序导入用户动作(查看)

// assume this user has viewed this book item
EventClient::recordUserActionOnItem('view', 5, 'bookId1');

检索预测结果

// assume you have created an itemrank engine on localhost:8000
// we try to get ranking of 5 items (item IDs: 1, 2, 3, 4, 5) for a user (user ID 7)

$response = EngineClient::sendQuery(array('uid'=>7, 'iids'=>array(1,2,3,4,5)));

print_r($response);

许可证

此项目使用 DBAD 许可。祝您玩得开心。