def testspiral():
	for leftout in xrange(1,11):
		print "Fold",leftout
		foo = FastKNN(10)
		for x in xrange(1,11):
			if x != leftout:
				somedata = open("spiral/spiralfold%d.txt" % x)
				pnts = list()
				clss = list()
				for line in somedata:
					pbbbt,x,y = line.split()
					x,y = float(x),float(y)
					pnts.append((x,y))
					clss.append(line.split()[0])
				somedata.close()
				pnts = numpy.array(pnts)
				foo.addEvidence(pnts,clss)
		somedata = open("spiral/spiralfold%d.txt" % leftout)
		correct = total = 0
		for line in somedata:
			pbbbt,x,y = line.split()
			x,y = float(x),float(y)
			guess=foo.query((x,y),10)
			#guess2 = foo.query((x,y),10,slow=True)
			#if guess != guess2:
			#	print "Crap!"
			#	print guess,guess2,(x,y,pbbbt)
			#print guess, pbbbt
			if guess == pbbbt:
				correct += 1
			total += 1
		print correct,"/",total,":",float(correct)/float(total)
		print "Average number of checks per query:", 
		print float(foo.num_checks)/float(total)
dataset/ETHPy150Open QuantSoftware/QuantSoftwareToolkit/QSTK/qstklearn/fastknn.py/testspiral/original