Coder Social home page Coder Social logo

hj3938 / hapiger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grahamjenson/hapiger

0.0 1.0 0.0 6.2 MB

HapiGer is an http-wrapper around the Good Enough Recommendation engine using the Hapi.js framework

JavaScript 0.28% CoffeeScript 99.72%

hapiger's Introduction

HapiGER

HapiGER logo

Providing good recommendations can create greater user engagement and directly provide value by recommending items the customer might additionally like. However, many applications don't provide recommendations to users because of the difficulty in implementing a custom engine or the pain of using an off-the-shelf engine.

HapiGER is a recommendations service that uses the Good Enough Recommendations (GER), a scalable, simple recommendations engine, and the Hapi.js framework. It has been developed to be easy to integrate, easy to use and very scalable.

Project Site

Quick Start Guide


*** #### Install HapiGER

Install with npm

npm install -g hapiger

***

Start HapiGER

By default it will start with an in-memory event store (events are not persisted)

hapiger

There are also PostgreSQL and RethinkDB event stores for persistence and scaling


***

Give an Action Weight

Set the view action to have weight 1:

curl -X POST 'http://localhost:3456/default/actions' -d'{
    "name": "view", 
    "weight": 1
  }'

***

Create some Events

Alice views Harry Potter

curl -X POST 'http://localhost:3456/default/events' -d '{
    "person":"Alice", 
    "action": "view", 
    "thing":"Harry Potter"
  }' 

Then, Bob also views Harry Potter (now Bob has similar viewing habits to Alice)

curl -X POST 'http://localhost:3456/default/events' -d '{
    "person":"Bob", 
    "action": "view", 
    "thing":"Harry Potter"
  }'

Bob then buys The Hobbit

curl -X POST 'http://localhost:3456/default/events' -d '{
    "person":"Bob", 
    "action": "buy", 
    "thing":"The Hobbit"
  }'

***

Get Recommendations

What books should Alice buy?

curl -X GET 'http://localhost:3456/default/recommendations?person=Alice&action=buy'
{
  "recommendations":[
    {
      "thing":"The Hobbit",
      "weight":0.22119921692859512,
      "people":[
        "Bob"
      ],
      "last_actioned_at":"2015-02-05T05:56:42.862Z"
    }
  ],
  "confidence":0.00019020140391302825,
  "similar_people":{
    "Bob":1
  }
}

Alice should buy The Hobbit as it was recommended by Bob with a weight of about 0.2.

The confidence of these recommendations is pretty low because there are not many events in the system


***

How HapiGER Works (the Quick Version)

The HapiGER API calculates recommendations for Alice to buy by:

  1. Finding people that are like Alice by looking at her past events
  2. Calculating the similarities between Alice and those people
  3. Look at the recent things that those similar people buy
  4. Weight those things using the similarity of the people

If you would like to read more about how HapiGER works, here is the long version.


***

Event Stores

The "in-memory" memory event store is the default, this will not scale well or persist event so is not recommended for production.

The recommended event store is PostgreSQL, which can be used with:

hapiger --es pg --esoptions '{
    "connection":"postgres://localhost/hapiger"
  }'  

Options are passed to knex.

HapiGER also supports a RethinkDB event store:

hapiger --es rethinkdb --esoptions '{
    "host":"127.0.0.1",
    "port": 28015,
    "db":"hapiger"
  }'

Options passed to rethinkdbdash.


***

Compacting the Event Store

The event store needs to be regularly maintained by removing old, outdated, or superfluous events; this is called compacting. This can be done either synchronously or asynchronously (it can take a while):

curl -X POST 'http://localhost:3456/default/compact'
curl -X POST 'http://localhost:3456/default/compact_async'

***

Namespaces

Namespaces are used to separate events for different applications or categories of things. The default namespace is default, but you can create namespaces by:

curl -X POST 'http://localhost:3456/namespace' -d'{
    "namespace": "newnamespace"
  }'  

To delete a namespace (and all its events!):

curl -X DELETE 'http://localhost:3456/namespace/movies'

***

Configuration of HapiGER

There are many configuration variables for HapiGER to tune the generated recommendations, these can be viewed with hapiger --help. The impact of each of these options are described in the long version of how HapiGER works.


***

Clients

  1. Node.js client ger-client

Changelog

8/02/15 -- Updated readme and bumped version

hapiger's People

Contributors

grahamjenson avatar

Watchers

Jasonking avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.