Skip to content

Instantly share code, notes, and snippets.

View ilovejs's full-sized avatar
🐡
mememe, hv a good fish !

Michael Zhuang ilovejs

🐡
mememe, hv a good fish !
  • Sydney
  • 10:41 (UTC +10:00)
View GitHub Profile

Movie Recommendations with k-Nearest Neighbors and Cosine Similarity


Introduction

The k-nearest neighbors (k-NN) algorithm is among the simplest algorithms in the data mining field. Distances / similarities are calculated between each element in the data set using some distance / similarity metric ^[1]^ that the researcher chooses (there are many distance / similarity metrics), where the distance / similarity between any two elements is calculated based on the two elements' attributes. A data element’s k-NN are the k closest data elements according to this distance / similarity.


1. A distance metric measures distance; the higher the distance the further apart the neighbors. A similarity metric measures similarity; the higher the similarity the closer the neighbors.
@mythz
mythz / OrmLiteLeftJoin.cs
Created June 26, 2014 09:59
Left Join in OrmLite
using System;
using ServiceStack.OrmLite;
using ServiceStack.Text;
namespace ConsoleApplication2
{
public class TableA
{
public int Id { get; set; }
public string Name { get; set; }
namespace FSHelloSceneKit
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open MonoTouch.SceneKit
type FSHelloSceneKitViewController () =
inherit UIViewController()
Require Import NArith.
Fixpoint sum_of (f : nat -> nat) (n : nat) : nat :=
match n with
| O => f O
| S m => f (S m) + sum_of f m
end.
Lemma sum_of_pow : forall n,
S (sum_of (NPeano.pow 2) n) = NPeano.pow 2 (S n).
@gmorpheme
gmorpheme / cont.clj
Last active August 29, 2015 14:14
Translation of Chapter 3 of Lisp in Small Pieces into Clojure
(ns ^{:doc "Loose translation of evaluator from chapter three
of Lisp in Small Pieces into Clojure."}
lispic.chapter3.cont
(:refer-clojure :exclude [invoke])
(:require [clojure.test :refer [deftest is]]))
(declare evaluate wrong)
(defn wrong [& args]
(println args)
@WillSewell
WillSewell / gist:bb4e8db17acd38c30c51
Created April 2, 2015 16:20
Old Pusher "webhook-channel-vacated" integration test
AsyncTest.define("webhook-channel-vacated #{params[:cluster_name]}", checks: 4, timeout: params[:timeout] ) { |t|
channel_name = "channel-existence-#{rand(1000000)}"
params[:webhooks]["/#{params[:cluster_name]}/webhook-channel-vacated"]=Proc.new do |post|
next unless channel_name == (post["events"][0]["channel"] rescue nil)
begin
event_name = post["events"][0]["name"]
pattern = {
"time_ms" => matches{|x| x.kind_of?(Integer)},
"events" => [{ "channel" => channel_name, "name" => event_name }]
import os
import errno
import urllib
import re
from urlparse import urlparse
from hashlib import md5
import httplib2
from lxml import html
@hyone
hyone / hyone-4clojure-solution69.clj
Created June 30, 2011 14:20 — forked from anonymous/hyone-4clojure-solution69.clj
4clojure #69 - Merge with a Function
;; hyone's solution to Merge with a Function
;; https://4clojure.com/problem/69
(fn my-merge-with [f & maps]
(reduce
(fn [a b]
(reduce
(fn [x [k v]]
(assoc x k (if (b k) (f v (b k)) v)))
b a))
@mrluanma
mrluanma / requests_oauth_weibo.py
Created March 7, 2012 02:08
Sina weibo OAuth 1.0a example using requests-oauth https://github.com/maraujop/requests-oauth
# -*- encoding: utf-8 -*-
import os
import urlparse
import requests
from oauth_hook import OAuthHook
REQUEST_TOKEN_URL = 'http://api.t.sina.com.cn/oauth/request_token'
ACCESS_TOKEN_URL = 'http://api.t.sina.com.cn/oauth/access_token'
AUTHORIZE_URL = 'http://api.t.sina.com.cn/oauth/authorize'
@skeptomai
skeptomai / gist:3628738
Created September 5, 2012 01:06
Goodreader sync files
196200_A Programming Language.pdf
1996-The Log-Structured Merge-Tree (LSM-Tree).pdf
6.05.HowToBeCreative.pdf
A tour of Scheme in Gambit.pdf
ABCDs of Paxos.pdf
AMQP Spec 0.8.pdf
Abstract Computing Machines.pdf
Adam's Advice and Reading List for High Tech Startup Entrepeneurs.pdf
Advanced Programming in the Unix Environment.pdf
Advanced encryption standard.PDF