Skip to content

Instantly share code, notes, and snippets.

View masayang's full-sized avatar

Masa Nakamura masayang

View GitHub Profile
@masayang
masayang / djangoeb.js
Created November 3, 2012 01:04
CloudFormation script for Django/ElasticBeansTalk with Jenkins environment
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Template: This template installs a single-instance with dev environment for elastic beanstalk as well as Jenkins server. This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"EC2Tag" : {
"Description" : "EC2 tag name",
"Type" : "String"
},
@masayang
masayang / usarrests.csv
Created October 13, 2012 23:31
Ward Clustering
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 5 in line 1.
"Murder","Assault","UrbanPop","Rape"
Alabama,13.2,236,58,21.2
Alaska,10,263,48,44.5
Arizona,8.1,294,80,31
Arkansas,8.8,190,50,19.5
California,9,276,91,40.6
Colorado,7.9,204,78,38.7
Connecticut,3.3,110,77,11.1
Delaware,5.9,238,72,15.8
Florida,15.4,335,80,31.9
@masayang
masayang / km_unsupervised.py
Created October 13, 2012 03:18
K-Means Clustering(Unsupervised)
import numpy as np
import matplotlib.pyplot as plt
from sklearn import cluster
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
x3 = np.genfromtxt("class3.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])
@masayang
masayang / km_supervised.py
Created October 13, 2012 02:57
K-Means Clustering(Supervised)
import numpy as np
import matplotlib.pyplot as plt
from sklearn import cluster
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
x3 = np.genfromtxt("class3.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])
@masayang
masayang / kn_unsupervised.py
Created October 12, 2012 22:57
K-Neighbors Unsupervised
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import NearestNeighbors
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
x3 = np.genfromtxt("class3.csv", delimiter = ",")
y1 = np.zerosimport numpy as np
import matplotlib.pyplot as plt
@masayang
masayang / kn_10.py
Created October 12, 2012 22:13
K-Neighbors Supervised
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
x3 = np.genfromtxt("class3.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])
@masayang
masayang / poly_svc.py
Created October 12, 2012 21:06
SVC kernels
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
x3 = np.genfromtxt("class3.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])
@masayang
masayang / class3.csv
Created October 11, 2012 21:46
LinearSVM
3.944800674823166098e+00 4.996271186415386367e+00
5.547242838038199508e+00 5.414293869669647208e+00
4.620646723315672943e+00 4.911930531086467155e+00
4.846418245516238343e+00 3.584170537988319083e+00
4.990222033288614689e+00 5.167624961159549279e+00
5.832925679378353045e+00 6.730998187374821917e+00
4.269651750644930743e+00 5.684499994023479275e+00
6.382861274845375021e+00 5.195463145627869039e+00
5.236782210357330491e+00 3.926700967069445269e+00
4.672536804208451855e+00 4.868250521526301888e+00
@masayang
masayang / randomforest_simple.py
Created October 11, 2012 01:33
Random Forest(max_depth = 3)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])
@masayang
masayang / decisiontree_depth3.py
Created October 10, 2012 23:40
Decision Trees
import numpy as np
import matplotlib.pyplot as plt
from sklearn import tree
x1 = np.genfromtxt("class1.csv", delimiter = ",")
x2 = np.genfromtxt("class2.csv", delimiter = ",")
y1 = np.zeros(x1.shape[0])
y2 = np.ones(x2.shape[0])