Files
  • main.py
  • data1.txt
  • data2.txt
  • data3.txt
  • data4.txt
  • target1.txt
  • target2.txt
  • target3.txt
  • target4.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sklearn 
import numpy as np
from sklearn.neighbors import KNeighborsClassifier

print "running... "

f = open("data4.txt")
data = np.loadtxt(fname = f, delimiter = ',')
print "file 1 loaded"
f = open("target4.txt")
target = np.loadtxt(fname = f, delimiter = ',')


print "files loaded"

#iris = datasets.load_iris()
#print iris
X = data
y = target[:,1]

print "data set"

#regr = linear_model.LinearRegression()

knn = KNeighborsClassifier(n_neighbors=3)


knn.fit(X,y)
#regr.fit(X,y)

print "fit completed"

print knn.predict([[49,66,49,118,50,56,102,120,85,76,85,81,84,98,52,55,119,103,115,114,102,84,50,85,84,49,105,49,89,89,77,97,54,81],[49,52,104,116,97,120,69,103,99,112,98,56,115,54,78,117,65,78,74,99,67,87,118,57,113,54,98,116,115,90,56,71,119,118],[49,77,117,88,111,67,83,102,109,55,102,66,72,66,84,104,69,80,53,112,65,112,49,104,86,76,86,113,78,68,65,99,90,117],[49,54,99,72,49,65,99,86,55,122,71,121,116,65,112,75,54,102,71,104,120,107,71,69,75,53,100,53,106,87,75,84,109,118],[49,54,99,72,49,65,99,86,55,122,71,121,116,65,112,75,54,102,71,104,120,107,71,69,75,53,100,53,106,87,75,84,109,118]])