endroid/prediction-io-bundle

Endroid PredictionIO Bundle for Symfony

Installs: 1 784

Dependents: 0

Stars: 12

Watchers: 6

Forks: 2

Language: PHP

2.0.6 2015-07-04 20:11 UTC

README

By endroid

Build Status Latest Stable Version Total Downloads License

This bundle provides easy integration with PredictionIO. PredictionIO is an open source machine learning server for software developers to create predictive features, such as personalization, recommendation and content discovery. Based on Apache Mahout scalable machine learning libraries.

The bundle registers the Endroid PredictionIO client as a service in your Symfony project. This client can then be used to register actions between users and items and to retrieve recommendations provided by any PredictionIO server. Applications range from showing recommended products in a web shop to discovering relevant experts in a social collaboration network.

knpbundles.com

Requirements

Installation

Use Composer to install the bundle.

$ composer require endroid/prediction-io-bundle

Then enable the bundle via the kernel.

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Endroid\Bundle\PredictionIOBundle\EndroidPredictionIOBundle(),
    );
}

Configuration

config.yml

endroid_prediction_io:
    event_server:
        url: %prediction_io.event_server.url%
    apps:
        app_one:
            key: %prediction_io.app_one.key%
            engines:
                complementarypurchase:
                    url: http://localhost:8000
                productranking:
                    url: http://localhost:8001
                viewedthenbought:
                    url: http://localhost:8002
                recommendation:
                    url: http://localhost:8003
                similarproduct:
                    url: http://localhost:8004
                leadscoring:
                    url: http://localhost:8005
        app_two:
            key: %prediction_io.app_two.key%
            engines:
                complementarypurchase:
                    url: http://localhost:8006
                leadscoring:
                    url: http://localhost:8007

Usage

After installation and configuration, the client can be directly referenced from within your controllers.

<?php

use Endroid\PredictionIO\EventClient;
use Endroid\PredictionIO\EngineClient;

/** @var EventClient $eventClient */
$eventClient = $this->get('endroid.prediction_io.app_one.event_client');
/** @var EngineClient $recommendationEngineClient */
$recommendationEngineClient = $this->get('endroid.prediction_io.app_one.recommendation.engine_client');
/** @var EngineClient $similarProductEngineClient */
$similarProductEngineClient = $this->get('endroid.prediction_io.app_one.similarproduct.engine_client');

// Populate with users and items
$eventClient->createUser($userId);
$eventClient->createItem($itemId);

// Record actions
$client->recordUserActionOnItem('view', $userId, $itemId);

// Return recommendations
$recommendedItems = $recommendationEngineClient->getRecommendedItems($userId, $itemCount);
$similarItems = $similarProductEngineClient->getSimilarItems($itemId, $itemCount);

Vagrant box

PredictionIO provides a Vagrant box containing an out-of-the-box PredictionIO server. You can also read the PredictionIO installation instructions.

Versioning

Semantic versioning (semver) is applied as much as possible.

License

This bundle is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.