Git Product home page Git Product logo

pearson's Introduction

Pearson Build Status

Pearson correlation coefficient calculator

Pearson

Installation

You can install the pearson gem with rubygems:

gem install pearson

If you are using Bundler, you can include it into the Gemfile:

gem 'pearson', '~> 1.0'

Usage

scores = {
  'Jack' => {
    'The Godfather' => 2.5,
    'Gattaca' => 3.5,
    'Matrix' => 3.0,
    'American History X' => 3.5,
    'Back to the future' => 2.5
  },
  'Lisa' => {
    'The Godfather' => 1.5,
    'Gattaca' => 2.5,
    'Matrix' => 1.5,
    'Back to the future' => 5.0
  },
  'Tom' => {
    'The Godfather' => 3.5,
    'Gattaca' => 3.0,
    'American History X' => 1.5,
    'Back to the future' => 5.0
  },
  'Sarah' => {
    'The Godfather' => 3.0,
    'Gattaca' => 3.5,
    'Matrix' => 1.5,
    'American History X' => 5.0,
    'Back to the future' => 1.0
  },
  'Mike' => {
    'The Godfather' => 3.0,
    'Back to the future' => 4.0
  }
}

Example 1

Calculate the pearson correlation coefficient between two entities:

Pearson.coefficient(scores, 'Sarah', 'Lisa')
#=> -0.5297608986976613

Example 2

Calculate the closest entity from a given entity:

Pearson.closest_entities(scores, 'Jack', limit: 1)
#=> [['Sarah', 0.7010740719559754]]

Example 3

Calculate the best recommendations for an entity. These recommendations are based on the pearson correlation coefficient. The results are sorted by item ranking:

Pearson.recommendations(scores, 'Mike')
#=> [["Gattaca", 2.75], ["American History X", 1.5], ["Matrix", 1.5]]

pearson's People

Contributors

alainpilon avatar alfonsojimenez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pearson's Issues

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.