def run(data_filenames, fold_filename, alpha): fold_filepath = '{!s}/folds/{!s}'.format(dir_path, fold_filename) layers_config = [] df_train_input, df_train_output, df_test_input, df_test_output = data_rw.loadData( data_filenames, fold_filepath) model = getModel(nDInput=df_train_input.shape[1], nDOutput=df_train_output.shape[1], alpha=alpha) keras_util.fitModel(model, df_train_input.as_matrix(), df_train_output.as_matrix(), layers_config, alpha, "lasso", dir_path, fold_filename) # Save test predictions: test_pred = model.predict(df_test_input.as_matrix()) df_test_pred = pd.DataFrame(data=test_pred, columns=df_test_output.columns, index=None) data_rw.savePreds(df_test_pred, dir_path, fold_filename, layers_config, alpha, "lasso") # Save training predictions: train_pred = model.predict(df_train_input.as_matrix()) df_train_pred = pd.DataFrame(data=train_pred, columns=df_train_output.columns, index=None) data_rw.savePreds(df_train_pred, dir_path, fold_filename, layers_config, alpha, "train_lasso")
def run(data_filenames, fold_filename, alpha, nDepth, ge_range_all): fold_filepath = '{!s}/folds/{!s}'.format(dir_path, fold_filename) df_train_input, df_train_output, df_test_input, df_test_output = data_rw.loadData(data_filenames, fold_filepath) nM = df_train_input.shape[0] model = getModel(nDInput = df_train_input.shape[1], nDOutput = df_train_output.shape[1], alpha = alpha, nDepth = nDepth) if ge_range_all: model = keras_util.apply_range(model, ge_range_all, df_train_output.columns) train_input_ext = np.repeat(df_train_input.as_matrix()[:, np.newaxis, :], nDepth, axis=1) keras_util.fitModel(model, train_input_ext, df_train_output.as_matrix(), [nDepth], alpha, "biRnn", dir_path, fold_filename) test_input_ext = np.repeat(df_test_input.as_matrix()[:, np.newaxis, :], nDepth, axis=1) # Save test predictions: test_pred = model.predict(test_input_ext) df_test_pred = pd.DataFrame(data = test_pred, columns=df_test_output.columns, index=None) data_rw.savePreds(df_test_pred, dir_path, fold_filename, [nDepth], alpha, "biRnn") # Save training predictions: train_pred = model.predict(train_input_ext) df_train_pred = pd.DataFrame(data = train_pred, columns=df_train_output.columns, index=None) data_rw.savePreds(df_train_pred, dir_path, fold_filename, [nDepth], alpha, "train_biRnn")