Input : Net Training and Testing Data
	Output : PGCM Matrix
	'''
	PGCM_0 = {}
	N = len(train_X[0]) - 1
	print "Number of Features ", N
	for i in xrange(1, N+1): 
		for j in xrange(i + 1, N+1):
			(new_tr_X, new_tr_y, new_ts_X, new_ts_y) = makeData(
			train_X, train_y, test_X, test_y, i, j)
			classifier = mushrooms_bfgs.train_decision_tree(
									new_tr_X, new_tr_y)
			PGCM_0[(i,j)] = nltk.classify.accuracy(classifier, 
							mushrooms_bfgs.test_decision_tree(
							new_ts_X, new_ts_y))*100
			print "Finding Accuracy for", i, j
	return PGCM_0

if __name__ == "__main__":
	timeStart = datetime.datetime.now()
	(train_X, train_y, test_X, test_y) = mushrooms_bfgs.initialize(float(1)/2)
	print "Number of Training Data =",len(train_y)
	print "Number of Testing Data =",len(test_y)
	PGCM_0 = makePairs(train_X, train_y, test_X, test_y)
	print "Total time taken = ", datetime.datetime.now() - timeStart
	f = open("PGCM_0", 'w')
	f.write(str(PGCM_0))
	f.close()
	print "Written to PGCM File"
	
Esempio n. 2
0
	Input : Net Training and Testing Data
	Output : PGCM Matrix
	'''
	PGCM_0 = {}
	N = len(train_X[0]) - 1
	print ("Number of Features ", N)
	for i in xrange(1, N+1): 
		for j in xrange(i + 1, N+1):
			(new_tr_X, new_tr_y, new_ts_X, new_ts_y) = makeData(
			train_X, train_y, test_X, test_y, i, j)
			classifier = mushrooms_bfgs.train_decision_tree(
									new_tr_X, new_tr_y)
			PGCM_0[(i,j)] = nltk.classify.accuracy(classifier, 
							mushrooms_bfgs.test_decision_tree(
							new_ts_X, new_ts_y))*100
			print ("Finding Accuracy for", i, j)
	return PGCM_0

if __name__ == "__main__":
	timeStart = datetime.datetime.now()
	(train_X, train_y, test_X, test_y) = mushrooms_bfgs.initialize(float(1)/2)
	print ("Number of Training Data =",len(train_y))
	print ("Number of Testing Data =",len(test_y))
	PGCM_0 = makePairs(train_X, train_y, test_X, test_y)
	print ("Total time taken = ", datetime.datetime.now() - timeStart)
	f = open("PGCM_0", 'w')
	f.write(str(PGCM_0))
	f.close()
	print ("Written to PGCM File")
	
    z_stat_for_symbiotic, p_val_for_symbiotic = stats.ranksums(
        Symbiotic_output, Original_input)
    z_stat_for_GA, p_val_for_GA = stats.ranksums(Modified_GA_output,
                                                 Original_input)
    print(p_val_for_symbiotic, p_val_for_GA)
    if max(p_val_for_GA, p_val_for_symbiotic) < 1e-300:
        return -1
    if (p_val_for_GA > p_val_for_symbiotic):
        print("Forest one is better")
        return 1
    else:
        print("Symbiotic is better")
        return 0


if __name__ == '__main__':
    (train_X, train_y, test_X,
     test_y) = mushrooms_bfgs.initialize(float(80) / 100)
    (train_X_Sym,
     test_X_Sym) = mushrooms_bfgs.featureRemoval(train_X, test_X, [3])
    (train_X_For,
     test_X_For) = mushrooms_bfgs.featureRemoval(train_X, test_X, [16])
    #~ print train_X[0], train_X_Sym[0], train_X_For[0]
    if WilcoxonTest(train_X.ravel(), train_X_Sym.ravel(), train_X_For.ravel()):
        newData_Tr = train_X_For
        newData_Ts = test_X_For
    else:
        newData_Tr = train_X_Sym
        newData_Ts = test_X_Sym
    #~ print WilcoxonTest([1,2,3,4], [1,2,3,5],[0,9,10,11])
Esempio n. 4
0
	Input : Net Training and Testing Data
	Output : PGCM Matrix
	'''
    PGCM_0 = {}
    N = len(train_X[0]) - 1
    print "Number of Features ", N
    for i in xrange(1, N + 1):
        for j in xrange(i + 1, N + 1):
            (new_tr_X, new_tr_y, new_ts_X,
             new_ts_y) = makeData(train_X, train_y, test_X, test_y, i, j)
            classifier = mushrooms_bfgs.train_decision_tree(new_tr_X, new_tr_y)
            PGCM_0[(i, j)] = nltk.classify.accuracy(
                classifier,
                mushrooms_bfgs.test_decision_tree(new_ts_X, new_ts_y)) * 100
            print "Finding Accuracy for", i, j
    return PGCM_0


if __name__ == "__main__":
    timeStart = datetime.datetime.now()
    (train_X, train_y, test_X,
     test_y) = mushrooms_bfgs.initialize(float(1) / 2)
    print "Number of Training Data =", len(train_y)
    print "Number of Testing Data =", len(test_y)
    PGCM_0 = makePairs(train_X, train_y, test_X, test_y)
    print "Total time taken = ", datetime.datetime.now() - timeStart
    f = open("PGCM_0", 'w')
    f.write(str(PGCM_0))
    f.close()
    print "Written to PGCM File"