job-fair / pages /4_Evaluation_Multiple.py
Zekun Wu
update
c4190b1
raw
history blame
1.74 kB
import streamlit as st
import pandas as pd
from io import StringIO
from util.analysis import statistical_tests, result_evaluation
def app():
st.title('Result Evaluation')
# Allow users to upload a CSV file with processed results
uploaded_file = st.file_uploader("Upload your processed CSV file", type="csv")
if uploaded_file is not None:
data = StringIO(uploaded_file.getvalue().decode('utf-8'))
df = pd.read_csv(data)
# Add ranks for each score within each row
ranks = df[['Privilege_Avg_Score', 'Protect_Avg_Score', 'Neutral_Avg_Score']].rank(axis=1, ascending=False)
df['Privilege_Rank'] = ranks['Privilege_Avg_Score']
df['Protect_Rank'] = ranks['Protect_Avg_Score']
df['Neutral_Rank'] = ranks['Neutral_Avg_Score']
st.write('Uploaded Data:', df)
# Display button to perform evaluation if data is uploaded
if st.button('Evaluate Data'):
with st.spinner('Evaluating data...'):
test_results = statistical_tests(df, "multiple")
st.write('Test Results:', test_results)
evaluation_results = result_evaluation(test_results, "multiple")
st.write('Evaluation Results:', evaluation_results)
# Allow downloading of the evaluation results
results_df = pd.DataFrame.from_dict(evaluation_results, orient='index', columns=['Value'])
st.download_button(
label="Download Evaluation Results",
data=results_df.to_csv().encode('utf-8'),
file_name='evaluation_results.csv',
mime='text/csv',
)
if __name__ == "__main__":
app()