Download the PHP package graphaware/reco4php without Composer

On this page you can find all versions of the php package graphaware/reco4php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package reco4php

GraphAware Reco4PHP

Neo4j based Recommendation Engine Framework for PHP

GraphAware Reco4PHP is a library for building complex recommendation engines atop Neo4j.

Build Status

Features:

Requirements:

The library imposes a specific recommendation engine architecture, which has emerged from our experience building recommendation engines and solves the architectural challenge to run recommendation engines remotely via Cypher. In return it handles all the plumbing so that you only write the recommendation business logic specific to your use case.

Recommendation Engine Architecture

Discovery Engines and Recommendations

The purpose of a recommendation engine is to recommend something, should be users you should follow, products you should buy, articles you should read.

The first part in the recommendation process is to find items to recommend, it is called the discovery process.

In Reco4PHP, a DiscoveryEngine is responsible for discovering items to recommend in one possible way.

Generally, recommender systems will contains multiple discovery engines, if you would write the who you should follow on github recommendation engine, you might end up with the non-exhaustive list of Discovery Engines :

Each Discovery Engine will produce a set of Recommendations which contains the discovered Item as well as the score for this item (more below).

Filters and BlackLists

The purpose of Filters is to compare the original input to the discovered item and decide whether or not this item should be recommended to the user. A very straightforward filter could be ExcludeSelf which would exclude the item if it is the same node as the input, which can relatively happen in a densely connected graph.

BlackLists on the other hand are a set of predefined nodes that should not be recommended to the user. An example could be to create a BlackList with the already purchased items by the user if you would recommend him products he should buy.

PostProcessors

PostProcessors are providing the ability to post process the recommendation after it has passed the filters and blacklisting process.

For example, if you would reward a recommended person if he/she lives in the same city than you, it wouldn't make sense to load all people from the database that live in this city in the discovery phase (this could be millions if you take London as an example).

You would then create a RewardSameCity post processor that would adapt the score of the produced recommendation if the input node and the recommended item are living in the same city.

Summary

To summarize, a typical recommendation engine will be a set of :

Let's start it !

Usage by example

We will use the small dataset available from MovieLens containing movies, users and ratings as well as genres.

The dataset is publicly available here : http://grouplens.org/datasets/movielens/. The data set to download is in the MovieLens Latest Datasets section and is named ml-latest-small.zip.

Once downloaded and extracted the archive, you can run the following Cypher statements for importing the dataset, just adapt the file urls to match your actual path to the files :

For the purpose of the example, we will assume we are recommending movies for the User with ID 460.

Installation

Require the dependency with composer :

Usage

Discovery

In order to recommend movies people should watch, you have decided that we should find potential recommendations in the following way :

As told before, the reco4php recommendation engine framework makes all the plumbing so you only have to concentrate on the business logic, that's why it provides base class that you should extend and just implement the methods of the upper interfaces, here is how you would create your first discovery engine :

The discoveryMethod method should return a Statement object containing the query for finding recommendations, the name method should return a string describing the name of your engine (this is mostly for logging purposes).

The query here has some logic, we don't want to return as candidates all the movies found, as in the initial dataset it would be 10k+, so imagine what it would be on a 100M dataset. So we are summing the score of the ratings and returning the most rated ones, limit the results to 500 potential recommendations.

The base class assumes that the recommended node will have the identifier reco and the score of the produced recommendation the identifier score. The score is not mandatory, and it will be given a default score of 1.

All these defaults are customizable by overriding the methods from the base class (see the Customization section).

This discovery engine will then produce a set of 500 scored Recommendation objects that you can use in your filters or post processors.

Filtering

As an example of a filter, we will filter the movies that were produced before the year 1999. The year is written in the movie title, so we will use a regex for extracting the year in the filter.

The Filter interfaces forces you to implement the doInclude method which should return a boolean. You have access to the recommended node as well as the input in the method arguments.

Blacklist

Of course we do not want to recommend movies that the current user has already rated, for this we will create a Blacklist building a set of these already rated movie nodes.

You really just need to add the logic for matching the nodes that should be blacklisted, the framework takes care for filtering the recommended nodes against the blacklists provided.

Post Processors

Post Processors are meant to add additional scoring to the recommended items. In our example, we could reward a produced recommendation if it has more than 10 ratings :

Wiring all together

Now that our components are created, we need to build effectively our recommendation engine :

As in your recommender service, you might have multiple recommendation engines serving different recommendations, the last step is to create this service and register each RecommendationEngine you have created. You'll need to provide also a connection to your Neo4j database, in your application this could look like this :

Inspecting recommendations

The recommend() method on a recommendation engine will returns you a Recommendations object which contains a set of Recommendation that holds the recommended item and their score.

Each score is inserted so you can easily inspect why such recommendation has been produced, example :

License

This library is released under the Apache v2 License, please read the attached LICENSE file.

Commercial support or custom development/extension available upon request to [email protected].


All versions of reco4php with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
graphaware/neo4j-php-client Version ^4.0
symfony/event-dispatcher Version ^2.7 || ^3.0
psr/log Version ^1.0
symfony/stopwatch Version ^2.7 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package graphaware/reco4php contains the following files

Loading the files please wait ....