Skip to content

Instantly share code, notes, and snippets.

@frenchbread
Created November 17, 2015 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frenchbread/02fd82d385fa7eb77872 to your computer and use it in GitHub Desktop.
Save frenchbread/02fd82d385fa7eb77872 to your computer and use it in GitHub Desktop.
from scipy.spatial import distance
import numpy as np
from sklearn.svm import SVC
file = 'iris.txt'
f = open(file)
data = []
for line in f:
split_line=line.split()
new_line=[float(x) for x in split_line[:-1]]
new_line=[float(x) for x in split_line[:-2]]
data.append(new_line)
f.close()
n1 = data[0]
n51 = data[50]
n101 = data[100]
n150 = data[149]
dst = distance.euclidean(n1, n150)
#a = np.array(data)
x=[l[0] for l in data]
y=[l[1] for l in data]
z=[l[2] for l in data]
clf = svm.SVC(kernel='linear')
clf.fit(x,y)
print(clf.predict(x))
# print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment