Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

association

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

association

An association lib that will find an things closest associations and give helper methods to do some other interesting things

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Association

Description: General machine learning helper library that exposes a nearest neighbor algorithm that can be configured to use one of two included types of mesurement. The lib includes two methods to either compare objects as a whole to see what two share the closest similarity or compare the keys from all objects to get the inverse. Supports pearson correlation algo AND euclidean distance algo

Example:

This example will be based off of a group of people rateing movies:

My ratings:

var jordan = {
'Lord of the Rings':4.1,
'The dark night':1.7,
'Sin city':5,
'Friday night lights':2.4
};
==========================

Alec ratings:

var alec = {
'Lord of the Rings':4,
'The dark night':1,
'Sin city':4,
'Friday night lights':4,
'silence of the lambs':5,
'dawn of the dead':6
};
==========================

Randy ratings:

var randy = {
'Lord of the Rings':5,
'The dark night':5,
'Sin city':5,
'Friday night lights':2,
'silence of the lambs':3.9,
'dawn of the dead':5,
'night of the living dead':6
};
==========================

User map:

var userMap = {
alec:alec,
randy:randy
}

With this information we can run a compareAll to see who shares my views in movies.

var association = require('./index.js')
var a = new association({
	formula: 'pearson' // this can also be euclidean
});

a.compareAll(2,userMap,jordan)	

This will return the following(if you use pearson algo)

[ { key: 'alec', score: 0.7033391716221717 },
{ key: 'randy', score: 0.3956282840374718 } ]	

This shows that my movie views match up best with alec.

I can also use this information to get recommendations of movies I have not seen yet.

var association = require('./index.js')
var a = new association({
	formula: 'pearson' // this can also be euclidean
});

a.getRecommendations(a.compareAll(2,userMap,jordan),userMap,jordan)

This will return the following:

[ { key: 'night of the living dead', score: 6 },
{ key: 'dawn of the dead', score: 5.64 },
{ key: 'silence of the lambs', score: 4.603999999999999 } ]

This shows that I will like night of the living dead the most of movies I have not viewed yet followed by dawn of the dead and then silence of the lambs.

Overview:

Methods:

compareAll(num,mapOfMap,baseMap);
	params:
	
		num: the number of returns in the array by the algo
		mapOfMap: the map containing all the maps that will be used 
		for the algo, example map of users movie ratings.
		baseMap: the base map that things will find relation to.
		example: my movie ratings
		
	return:			
		ranking of keys in mapOfMap by comparing objects. //correlation
		
getReccommendations(simObj,mapOfMap,baseMap);
	params:
		
		simObj: the correlation returned by compareAll
		mapOfMap: the map containing all the maps that will be used 
		for the algo, example map of users movie ratings.
		baseMap: the base map that things will find relation to.
		example: my movie ratings
	
	return:			
		ranking of items not included in base map by similarity to existing items.
		

Keywords

FAQs

Package last updated on 26 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc