-
Notifications
You must be signed in to change notification settings - Fork 5
/
trying_train.py
50 lines (44 loc) · 1.18 KB
/
trying_train.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import matplotlib.pyplot as plot
from sklearn import datasets
import numpy as np
from sklearn import svm
import pandas as pd
from pandas import DataFrame, read_csv
filename = 'C://Users//Apoorva//Desktop//A_Z Handwritten Data//A_Z Handwritten Data.csv'
chunksize =1
x= []
y= []
i=1
gaps = pd.read_csv(filename, chunksize=chunksize)
for chunk in gaps:
i = i+1
df = pd.DataFrame(chunk)
for s in range(1):
x.append(df.iloc[s,0])
listP = []
for t in range(1,28):
listP.append(df.iloc[s,t])
y.append(listP)
if i>500000:
break
#a = pd.DataFrame(x)
#b = pd.DataFrame(y)
a=np.array(x, 'int8')
b=np.array(y, 'float64')
print(a)
print(b)
digits = datasets.load_digits()
print((digits.data)) # learning data
clf = svm.SVC(gamma=0.001, C=100)
#print(type(digits.data))
# training
#x, y = digits.data[:-1], digits.target[:-1]
# tained upto -1....-1 for last element
#fit(data,target)
clf.fit(b, a)
my_data = b
#print('Prediction of last element:', clf.predict(digits.data[[-1]]))
print('Prediction of last element:', clf.predict(my_data))
print(my_data)
plot.imshow(digits.images[-1], cmap=plot.cm.gray_r, interpolation="nearest")
plot.show()