def main(): for kfold in range(10): inputdata, outputdata = Readcsv() trainin, trainout, testin, testout = fold(inputdata, outputdata) data = np.array(inputdata) out = np.array(outputdata) wout, biout, win, biin = train(trainin, trainout) target = test(wout, biout, win, biin, testin) print(checkerror(target, testout))
import arff import numpy as np import math from preprocessing import preprocessing, getoutputData, test, train dataset = arff.load(open('Autism-Child-Data.arff', 'rb')) data = np.array(dataset['data']) #Input array x = preprocessing(data, 21) #Output y = train(x) y = getoutputData(y) #Sigmoid Function def sigmoid(x): return 1 / (1 + np.exp(-x)) #Derivative of Sigmoid Function def derivatives_sigmoid(x): return x * (1 - x) #Variable initialization epoch = 5000 #Setting training iterations lr = 0.1 #Setting learning rate inputlayer_neurons = x.shape[1] #number of features in data set hiddenlayer_neurons = 3 #number of hidden layers neurons output_neurons = 1 #number of neurons at output layer
df_items = pd.read_csv('D:/TSE/python/missplaceclass/test_items.csv') print('Building Tokenizer...') tokenizer = preprocessing.get_tokenizer(df) score = np.zeros(shape=(0)) label = np.zeros(shape=(0)) target_correct = 0 for i in range(len(projects)): #len(projects) project = projects[i] print('*' * 80) print(project) ss = time.time() models = preprocessing.train(df[df.projectname != project], tokenizer, project) print('###########################', time.time() - ss) #models=preprocessing.load_models(project) ss = time.time() tscore, tlabel, t_target_correct = preprocessing.test( df_classes, df_items[df_items.projectname == project], tokenizer, models) print('###########################', time.time() - ss) score = np.concatenate((score, tscore.reshape(-1)), axis=0) label = np.concatenate((label, tlabel.reshape(-1)), axis=0) target_correct += t_target_correct print('*' * 80) print('Final') preprocessing.eval(score, label, target_correct)
import math from preprocessing import preprocessing, getoutputData, test, train np.set_printoptions(threshold='nan') dataset = arff.load(open('Autism-Child-Data.arff', 'rb')) data = np.array(dataset['data']) X = preprocessing(data, 21) def sigmoid(x, deriv=False): if (deriv == True): return x * (1 - x) return 1 / (1 + np.exp(-x)) y = train(X) # y = [[float(n) for n in m] for m in y] o = getoutputData(X, 10) z = test(X) p = getoutputData(z, 282) weight_input = 2 * np.random.random((17, 5)) - 1 weight_hidden = 2 * np.random.random((6, 1)) - 1 print o learning_rate = [[0.01]] print "Start : " # code for i in xrange(1, 1500, 1):