This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @fileoverview Pearson correlation score algorithm. | |
| * @author [email protected] (Matt West) | |
| * @license Copyright 2013 Matt West. | |
| * Licensed under MIT (http://opensource.org/licenses/MIT). | |
| */ | |
| /** | |
| * Calculate the person correlation score between two items in a dataset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pearson(prefs, p1, p2): | |
| si={} | |
| for item in prefs[p1]: | |
| if item in prefs[p2]: si[item]=1 | |
| n=len(si) | |
| if n==0: return 0 | |
| sum1=sum([prefs[p1][it] for it in si]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pearson(x,y) | |
| n=x.length | |
| sumx=x.inject(0) {|r,i| r + i} | |
| sumy=y.inject(0) {|r,i| r + i} | |
| sumxSq=x.inject(0) {|r,i| r + i**2} | |
| sumySq=y.inject(0) {|r,i| r + i**2} | |
| prods=[]; x.each_with_index{|this_x,i| prods << this_x*y[i]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| type Film struct { | |
| Film string | |
| P1 int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A dictionary of movie critics and their ratings of a small | |
| # set of movies | |
| critics={'Lisa Rose': {'Lady in the Water': 2.5, 'Snakes on a Plane': 3.5, | |
| 'Just My Luck': 3.0, 'Superman Returns': 3.5, 'You, Me and Dupree': 2.5, | |
| 'The Night Listener': 3.0}, | |
| 'Gene Seymour': {'Lady in the Water': 3.0, 'Snakes on a Plane': 3.5, | |
| 'Just My Luck': 1.5, 'Superman Returns': 5.0, 'The Night Listener': 3.0, | |
| 'You, Me and Dupree': 3.5}, | |
| 'Michael Phillips': {'Lady in the Water': 2.5, 'Snakes on a Plane': 3.0, | |
| 'Superman Returns': 3.5, 'The Night Listener': 4.0}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Returns a distance-based similarity score for p1 vs p2 | |
| def euclidean_distance(prefs, p1, p2) | |
| si = [] # Empty array for films that can be compared (both user's have rated) | |
| prefs[p1].each do |item| # Loop through each rating for p1 | |
| prefs[p2].each do |p2_film| # Loop through each rating for p2 | |
| if item[0] == p2_film[0] # If both people have rated this film add it to the films array | |
| si << item[0] | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @fileoverview Utility for parsing the parameters from a URL. | |
| * @author [email protected] (Matt West) | |
| * @license Copyright 2013 Matt West. | |
| * Licensed under MIT (http://opensource.org/licenses/MIT). | |
| */ | |
| /** | |
| * Parse the params from a given url and returns an object consisting of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en-US" prefix="og: http://ogp.me/ns#"> | |
| <head> | |
| <meta charset="utf-8"> | |
| {% if is_home %} | |
| <title>{{ site.name }}</title> | |
| {% elif is_post %} | |
| <title>{{ post.title }} by {{ site.author }} of Koji Labs</title> | |
| {% elif is_link %} | |
| <title>{{ link.title }} | {{ site.name }}</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme", | |
| "dictionary": "Packages/Language - English/en_GB.dic", | |
| "font_size": 11, | |
| "ignored_packages": [ | |
| "Vintage" | |
| ], | |
| "afn_use_project_root": true, | |
| "afn_proj_root": "../", | |
| "afn_valid_scopes": [ |