def fitness(kr): return 1 / (jst.mse(inps, kr, num_input, num_hidden, num_output) + 0.0001)
def fitness(kr): return 1/(jst.mse(inps,kr,num_hidden)+0.1)
inps = loader.loadCsv(file_data_testing) inps = loader.stringifyVar(inps,loader.normalizeVar(loader.getVar(inps))) weights = jst.decodeWeights(loader.loadCsv(file_weights),num_input,num_hidden,num_output) match = 0 tp1 = 0 pp1 = 0 tn1 = 0 pn1 = 0 for i in range(len(inps)): if(jst.correct(inps[i],weights)): match += 1 if(jst.truePositive1(inps[i],weights)): tp1 += 1 if(jst.trueNegative1(inps[i],weights)): tn1 += 1 if(jst.predictPositive1(inps[i],weights)): pp1 += 1 if(jst.predictNegative1(inps[i],weights)): pn1 += 1 presisi1 = (tp1*1.0)/((tp1+(pp1-tp1))+0.0000001) recall1 = (tp1*1.0)/((tp1+(pn1-tn1))+0.0000001) presisi0 = (tn1*1.0)/((tn1+(pn1-tn1))+0.0000001) recall0 = (tn1*1.0)/((tn1+(pp1-tp1))+0.0000001) measure1 = 2*(presisi1*recall1)/((presisi1+recall1)+0.0000001) measure0 = 2*(presisi0*recall0)/((presisi0+recall0)+0.0000001) print measure0, measure1 print "Jumlah klasifikasi yang sesuai = "+str(match)+"/"+str(len(inps)) print "MSE = "+str(jst.mse(inps,loader.loadCsv(file_weights),num_input,num_hidden,num_output)) print "Persentase kecocokan = "+str((match*100)/len(inps))+"%"