def main(): import os data_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '/data/' #data_file = data_dir + 'input_data_full.csv' #data_file = data_dir + 'InputData_small.csv' #results_file = data_dir + 'consumer_spending.csv' #results_file = data_dir + 'Fake_Results.csv' data = dh.get_all_data(LOAD_FROM_FILE, LOAD_DELTAS, data_dir) results = data[target_col] num_data_items = data.shape[0] season_info = np.zeros([num_data_items,4]) j = 0 for i in range(num_data_items): season_info[i,j] = 1 j += 1 if j > 3: j = 0 seasons_df = pd.DataFrame(data=season_info, columns=['SEASON_1', 'SEASON_2', 'SEASON_3', 'SEASON_4']) seasons_df.index = data.index if USE_SEASONS: data = pd.concat([data, seasons_df], axis=1) if DO_VALIDATION: model = valid.do_validation(data, results, MODEL_TYPE, USE_ENSEMBLE) if DO_TEST: run_tests(model, data, results) elif DO_FUTURE_FORECAST: model = mh.get_model_fixed(MODEL_TYPE) do_fwd_prediction(model,data,results) else: model = mh.get_model_fixed(MODEL_TYPE) #do_fwd_prediction(model,data,results) run_tests(model, data, results) end = timer() print('finished in: ' + str(end - start)) ph.show_plots()
def DisplayFactors(): use_deltas = True data = dh.get_all_data(LOAD_FROM_FILE, use_deltas) titles = data.columns data = data[data.index < START_TEST_DATE] check_one_forecast_gap(data, 1) [corr_1fwd, corr_1fwd_delta] = check_one_forecast_gap(data, 1, use_deltas) [corr_4fwd, corr_4fwd_delta] = check_one_forecast_gap(data, 4, use_deltas) for i in range(corr_1fwd.shape[0]): if use_deltas: print(titles[i] + ' & pch & ' + str(round(corr_1fwd[i, 0], 4)) + ' & ' + str(round(corr_1fwd_delta[i, 0], 4)) + ' & ' + str(round(corr_4fwd[i, 0], 4)) + ' & ' + str(round(corr_4fwd_delta[i, 0], 4)) + ' \\\\') else: print(titles[i] + ' & pch & ' + str(round(corr_1fwd[i, 0], 4)) + ' & ' + str(round(corr_4fwd[i, 0], 4)) + '\\\\') ph.draw_hist( corr_1fwd, '1 Period Forward Correlations Between Input Variables and Target', 'Correlation Coefficient') plt.show()