import ci.helper as helper a = helper.crossvalidation([[1,2,3,4,5],[2,2,3,4,5],[3,2,3,4,5],[4,2,3,4,5],[5,2,3,4,5]], 0.4) print a.getAllSet() print "" print a.getTrain(0) print a.getTrain(1) print "" print a.getTest(0) print a.getTest(1)
argmax = lambda array: max(izip(array, xrange(len(array))))[1] pttNet = [mlp.randNet([2, 5, 2], type=mlp.SIGMOID), mlp.randNet([2, 10, 2], type=mlp.SIGMOID), mlp.randNet([2, 15, 2], type=mlp.SIGMOID), mlp.randNet([2, 5, 5, 2], type=mlp.SIGMOID)] learningRate = [0.01, 0.05, 0.1, 0.2] epoch = 100 f = open("cross.pat", "r") fw = open("report/cross/report.txt", "w") lines = f.readlines() datas = [] for line in lines: words = line.split(" ") datas.append([float(word) for word in words]) floods = helper.crossvalidation(datas, 0.1, shuffer=True) plt.ion() plt.show() m_cor = 0.0 for pn in pttNet: for lr in learningRate: s_cor = 0.0 b_cor = 0.0 for i in range(0, floods.state): train = floods.getTrain(i) test = floods.getTest(i) print "Net Structure " + str(pn.getLayer()) + " Learning Rate and Momentum " + str(lr) + " Flood " + str(i+1)