Created
March 11, 2013 15:24
-
-
Save yoneken/5135000 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
from svm import * | |
from svmutil import * | |
import numpy as np | |
import scipy as sp | |
from pylab import * | |
s_data = np.genfromtxt('CodeIQ_auth.txt', delimiter=' ') | |
data = np.genfromtxt('CodeIQ_mycoins.txt', delimiter=' ') | |
prob = svm_problem(s_data[:,2],s_data[:,:2].tolist()) | |
param = svm_parameter('-t 1 -c 3') | |
learn = svm_train(prob, param) | |
p_labels, p_acc, p_vals = svm_predict(sp.ones(len(data)), data[:,:2].tolist(), learn) | |
my_reals = [] | |
for i,p_label in enumerate(p_labels): | |
print p_label | |
if p_label==1: | |
my_reals += [data[i]] | |
# make figure | |
fakes = np.array([[x[0],x[1]] for x in s_data if x[2]==0]) | |
reals = np.array([[x[0],x[1]] for x in s_data if x[2]==1]) | |
plot(fakes[:,0],fakes[:,1], 'b.') | |
plot(reals[:,0],reals[:,1], 'g.') | |
plot(data[:,0],data[:,1], 'kx') | |
plot([x[0] for x in my_reals],[x[1] for x in my_reals], 'rx') | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment