#### END OF CONFIGURATION OPTION #### y_train_values = [item for sublist in y_train_values for item in sublist] y_train_predicted_values = [item for sublist in y_train_predicted_values for item in sublist] # remove the -1 values (the ones that are censored) tmp = [i for i in zip(y_train_values, y_train_predicted_values) if int(i[0]) != -1] y_train_values = [i[0] for i in tmp] y_train_predicted_values = [i[1] for i in tmp] y_test_values = [item for sublist in y_test_values for item in sublist] y_test_predicted_values = [item for sublist in y_test_predicted_values for item in sublist] current_train_res, current_test_res = calc_results_and_plot(y_train_values, y_train_predicted_values, y_test_values, y_test_predicted_values, algo_name='NeuralNetwork', visualize=PLOT, title=f'Epochs: {epochs}, Validation iterations: {number_iterations}', show=False) # print(current_train_res) # print(current_test_res) if RECORD: GRID_SEARCH_DIRECTORY = 'GridSearch_my_loss_factor_layers_neurons' if not os.path.exists(GRID_SEARCH_DIRECTORY): os.mkdir(GRID_SEARCH_DIRECTORY) if not os.path.exists(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str): os.mkdir(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str) np.save(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str+'/y_train_values.npy', y_train_values) np.save(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str+'/y_train_predicted_values.npy', y_train_predicted_values) np.save(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str+'/y_test_values.npy', y_test_values) np.save(GRID_SEARCH_DIRECTORY+'/'+current_configuration_str+'/y_test_predicted_values.npy', y_test_predicted_values)
y_train_predicted_values = y_train_dict[ 'alpha=0.01|n_estimators=20|min_child_weight=20|reg_lambda=20|max_depth=5'][ 'y_train_predicted_values'] y_train_values = y_train_dict[ 'alpha=0.01|n_estimators=20|min_child_weight=20|reg_lambda=20|max_depth=5'][ 'y_train_values'] y_test_values = y_test_dict[ 'alpha=0.01|n_estimators=20|min_child_weight=20|reg_lambda=20|max_depth=5'][ 'y_test_values'] y_test_predicted_values = y_test_dict[ 'alpha=0.01|n_estimators=20|min_child_weight=20|reg_lambda=20|max_depth=5'][ 'y_test_predicted_values'] calc_results_and_plot( y_train_values, y_train_predicted_values, y_test_values, y_test_predicted_values, 'NewAlg\n alpha=0.01|n_estimators=20|min_child_weight=20|reg_lambda=20|max_depth=5', visualize=True, title='NewAlg') print('**************\n') print(betas_values) print(removed_rows) # betas_as_x = [] # y_train_rho = [] # y_test_rho = [] # for beta, value in betas_values.items(): # betas_as_x.append(beta) # train = value[0] # test = value[1] # y_train_rho.append(
def calc_full_rho(configuration_stats, epoch_to_use=None, verbose_per_cv=False): total_test_values = [] total_test_predicted_values = [] total_train_values = [] total_train_predicted_values = [] total_train_rho = [] total_train_mse = [] totral_train_pearson_rho = [] total_test_rho = [] total_test_mse = [] total_test_pearson_rho = [] for idx, (test_iter_cv_iter, value) in enumerate(configuration_stats.items()): print(test_iter_cv_iter) test_real, test_predicted, train_real, train_predicted = get_data_from_last_epoch( test_iter_cv_iter, value['epoch_list'], -10) total_test_values += test_real.tolist() total_test_predicted_values += test_predicted.tolist() total_train_values += train_real.tolist() total_train_predicted_values += train_predicted.tolist() current_train, current_test = calc_results_and_plot( train_real, train_predicted, test_real, test_predicted, algo_name='XGBoost', visualize=False, title='', show=False) total_train_rho.append(value['train_rho']['rho']['mean']) total_train_mse.append(value['train_mse']['mse']['mean']) totral_train_pearson_rho.append( value['train_pearson_rho']['rho']['mean']) total_test_rho.append(value['test_rho']['rho']['mean']) total_test_mse.append(value['test_mse']['mse']['mean']) total_test_pearson_rho.append(value['test_pearson_rho']['rho']['mean']) if verbose_per_cv: print(f'\tTrain\n\t\t{current_train}') if (idx + 1) % len(configuration_stats) == 0: current_train_res, current_test_res = calc_results_and_plot( total_train_values, total_train_predicted_values, total_test_values, total_test_predicted_values, algo_name='XGBoost', visualize=False, title='', show=False) print(f'Total RHO') print(f'\tTrain\n\t\t{current_train_res}') print(f'\tTest\n\t\t{current_test_res}') total_test_values = [] total_test_predicted_values = [] total_train_values = [] total_train_predicted_values = [] if verbose_per_cv: print(f'\n\tTrain\n\t\t') print(f'rho: {get_stats_for_array(np.array(total_train_rho))}') print(f'mse: {get_stats_for_array(np.array(total_train_mse))}') print( f'pearson: {get_stats_for_array(np.array(totral_train_pearson_rho))}' ) print(f'\tTest\n\t\t') print(f'rho: {get_stats_for_array(np.array(total_test_rho))}') print(f'mse: {get_stats_for_array(np.array(total_test_mse))}') print( f'pearson: {get_stats_for_array(np.array(total_test_pearson_rho))}' ) print(f'\n')