def testgendata():
    fname = 'test2.dat'
    querys = 1000
    d = 2
    k=3
    bnds = ((-10,10),)*d
    clsses = (0,1)
    data = getflatcsv(fname)
    kdt = kdtknn(k,method='mode')
    kdt.addEvidence(data)
    kdt.rebuildKDT()
    stime = time.time()
    for x in xrange(querys):
        pnt = numpy.array(gendata.gensingle(d,bnds,clsses))
        reslt = kdt.query(numpy.array([pnt[:-1]]))
        print pnt,"->",reslt
    etime = time.time()
    print stime-etime,'/',querys,'=',(etime-stime)/float(querys),'avg wallclock time per query'
    #foo.addEvidence(data[:,:-1],data[:,-1])
    #foo.num_checks = 0
    #for x in xrange(querys):
    #    pnt = numpy.array(gendata.gensingle(d,bnds,clsses))
    #    foo.query(pnt[:-1],3)
    #    if x % 50 == 0:
    #        print float(foo.num_checks)/float(x+1),
    #        print x,"/",querys
    #print "Average # queries:", float(foo.num_checks)/float(querys)
dataset/ETHPy150Open tucker777/QSTK/qstklearn/kdtknn.py/testgendata/swapped operands of `-`