Spaces:
Running
Running
import streamlit as st | |
import pandas as pd | |
from io import StringIO | |
from util.evaluation import statistical_tests, result_evaluation,calculate_correlations,calculate_divergences | |
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) | |
if st.button('Evaluate Data'): | |
with st.spinner('Evaluating data...'): | |
# Existing statistical tests | |
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) | |
# New correlation calculations | |
correlation_results = calculate_correlations(df) | |
st.write('Correlation Results:', correlation_results) | |
# New divergence calculations | |
divergence_results = calculate_divergences(df) | |
st.write('Divergence Results:', divergence_results) | |
# Allow downloading of the evaluation results | |
results_combined = {**evaluation_results, **correlation_results, **divergence_results} | |
results_df = pd.DataFrame.from_dict(results_combined, 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() | |