File size: 1,199 Bytes
a3f0c15
 
 
37812fb
a3f0c15
 
 
37812fb
 
a3f0c15
 
 
 
 
 
 
 
 
 
0ccb185
a3f0c15
ea2852b
0ccb185
aba61cc
 
37812fb
a3f0c15
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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