def execute(self): # Pre processing x_data = util.normalizeData(self.x_data) x_data = util.insertBias(x_data) y_data = self.y_data for i in range(self.realizations): self.initWeigths() x_data_aux, y_data_aux = util.shuffleData(x_data, y_data) x_train, x_test, y_train, y_test = util.splitData( x_data_aux, y_data_aux, self.train_size) self.train(x_train, y_train) acc, tpr, spc, ppv = self.test(x_test, y_test) self.hit_rate.append(acc) self.tpr.append(tpr) self.spc.append(spc) self.ppv.append(ppv) #util.plotColorMap(x_train, x_test, y_train, self.predict) self.acc = np.mean(self.hit_rate) self.std = np.std(self.hit_rate) self.tpr = np.mean(self.tpr) self.spc = np.mean(self.spc) self.ppv = np.mean(self.ppv) print('Hit rate: {}'.format(self.hit_rate)) print('Accuracy: {:.2f}'.format(self.acc * 100)) print('Minimum: {:.2f}'.format(np.amin(self.hit_rate) * 100)) print('Maximum: {:.2f}'.format(np.amax(self.hit_rate) * 100)) print('Standard Deviation: {:.2f}'.format(self.std)) print('Sensitivity: {:.2f}'.format(self.tpr * 100)) print('Specificity: {:.2f}'.format(self.spc * 100)) print('Precision: {:.2f}'.format(self.ppv * 100))
def execute(self): x_data = util.insertBias(self.x_data) y_data = self.y_data for i in range(self.realizations): x_data_aux, y_data_aux = util.shuffleData(x_data, y_data) x_train, x_test, y_train, y_test = util.splitData(x_data_aux, y_data_aux, self.train_size) best_hidden_layer = self.hidden_layer params = self.train(x_train, y_train, best_hidden_layer) mse, rmse = self.test(x_test, y_test, params) self.mse.append(mse) self.rmse.append(rmse) print('{} Realizations'.format(self.realizations)) print('MSE: {}'.format(np.mean(self.mse))) print('Std MSE: {}'.format(np.std(self.mse))) print('RMSE: {}'.format(np.mean(self.rmse))) print('Std RMSE: {}'.format(np.std(self.rmse)))
def execute(self): x_data = util.normalizeData(self.x_data) x_data = util.insertBias(x_data) y_data = self.y_data for i in range(self.realizations): x_data_aux, y_data_aux = util.shuffleData(x_data, y_data) x_train, x_test, y_train, y_test = util.splitData( x_data_aux, y_data_aux, self.train_size) if self.g_search: best_n_centers, best_width = self.grid_search(x_train, y_train) print('Best N Centers: ', best_n_centers) print('Best Width: ', best_width) else: best_n_centers = self.n_centers best_width = self.width params = self.train(x_train, y_train, best_n_centers, best_width) acc, tpr, spc, ppv = self.test(x_test, y_test, params, best_n_centers, best_width) self.hit_rate.append(acc) self.tpr.append(tpr) self.spc.append(spc) self.ppv.append(ppv) self.acc = np.mean(self.hit_rate) self.std = np.std(self.hit_rate) self.tpr = np.mean(self.tpr) self.spc = np.mean(self.spc) self.ppv = np.mean(self.ppv) print('Hit rate: {}'.format(self.hit_rate)) print('Accuracy: {:.2f}'.format(self.acc * 100)) print('Minimum: {:.2f}'.format(np.amin(self.hit_rate) * 100)) print('Maximum: {:.2f}'.format(np.amax(self.hit_rate) * 100)) print('Standard Deviation: {:.2f}'.format(self.std)) print('Sensitivity: {:.2f}'.format(self.tpr * 100)) print('Specificity: {:.2f}'.format(self.spc * 100)) print('Precision: {:.2f}'.format(self.ppv * 100))
def adaline(self): # Pre processing x_data = util.normalizeData(self.x_data) x_data = util.insertBias(x_data) y_data = self.y_data for i in range(self.realizations): self.initWeigths() x_data_aux, y_data_aux = util.shuffleData(x_data, y_data) x_train, x_test, y_train, y_test = util.splitData( x_data_aux, y_data_aux, self.train_size) self.train(x_train, y_train) mse, rmse = self.test(x_test, y_test) self.mse.append(mse) self.rmse.append(rmse) print('{} Realizations'.format(self.realizations)) print('MSE: {}'.format(np.mean(self.mse))) print('Std MSE: {}'.format(np.std(self.mse))) print('RMSE: {}'.format(np.mean(self.rmse))) print('Std RMSE: {}'.format(np.std(self.rmse)))