import numpy as np import pandas as pd import streamlit as st from settings import TEST_COLUMN_NAME, BETTER_COLUMN_NAME, GROUND_TRUTH_FILE, ROW_NUMBER def validate_file(input_file): if len(input_file) != ROW_NUMBER: # row number for test data st.write("Incorrect number of rows--please make sure you have the same number as in the input file.") return if TEST_COLUMN_NAME not in input_file.columns.to_list(): st.write(f"No column named {TEST_COLUMN_NAME} in the file.") st.write(f"Found these columns:{input_file.columns}") return else: st.write("File loaded and confirmed.") return True def check_projections(checked_file): ground_truth = pd.read_csv(GROUND_TRUTH_FILE) ground_truth = ground_truth.rename({'RF_STUFF': 'pred_run_value'}, axis=1) ground_truth[TEST_COLUMN_NAME] = checked_file[TEST_COLUMN_NAME] rfstuff_mean_absolute_error = np.nanmedian(np.abs(ground_truth['pred_run_value'] - checked_file[TEST_COLUMN_NAME])) better_mean_absolute_error = np.nanmedian(np.abs(ground_truth['run_value'] - checked_file[BETTER_COLUMN_NAME])) return rfstuff_mean_absolute_error, better_mean_absolute_error