コード例 #1
0
ファイル: Task4.py プロジェクト: githubharald/stat-me
# transform data points
transformedIn=featureTransform(numPoints, pointsIn)
transformedOut=featureTransform(numPoints, pointsOut)
transformedAll=np.concatenate((transformedIn,transformedOut),axis=0)


#print transformedAll
#print yAll

print "Trained:"
print "--------"

# learn w
maxEpoches=1000 # increase this value and you get better results. But you have to wait 3 days for it ...
w=perco.perco(transformedAll,yAll,maxEpoches)
print 'w= ', np.ndarray.tolist(w)


# test how good our classifier works ...
okCtr=0
nokCtr=0
for i in range(0,2*numPoints):
	x=np.reshape(transformedAll[i,:],[np.size(transformedAll,1),1])
	classified=perco.classify(x,w)
	if yAll[i] == classified:
		okCtr=okCtr+1
	else:
		nokCtr=nokCtr+1

# plot statictis ...