Spaces:
Running
Running
File size: 4,509 Bytes
bafdc7e 86607a2 7e568f5 8e2d7d0 c104620 86607a2 bfdd3c9 bafdc7e 86607a2 cf25467 86607a2 bafdc7e 5fd4442 3922c93 1635fe8 5fd4442 e63fda8 3922c93 ce70707 bafdc7e 3922c93 bafdc7e 069113a bafdc7e 5d57412 5657e82 c104620 9602d77 e0d40a6 9602d77 5d57412 ce5d5ba 9602d77 e0d40a6 9602d77 1955778 8e2d7d0 bafdc7e 86607a2 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
import os
import streamlit as st
import pandas as pd
from io import StringIO
from util.evaluation import statistical_tests,calculate_correlations,calculate_divergences
from util.plot import create_score_plot,create_rank_plots,create_correlation_heatmaps
import plotly.express as px
def check_password():
def password_entered():
if password_input == os.getenv('PASSWORD'):
st.session_state['password_correct'] = True
else:
st.error("Incorrect Password, please try again.")
password_input = st.text_input("Enter Password:", type="password")
submit_button = st.button("Submit", on_click=password_entered)
if submit_button and not st.session_state.get('password_correct', False):
st.error("Please enter a valid password to access the demo.")
def app():
st.title('Result Evaluation')
if not st.session_state.get('password_correct', False):
check_password()
else:
st.sidebar.success("Password Verified. Proceed with the demo.")
# 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)
st.write('Uploaded Data:', df)
if st.button('Evaluate Data'):
with st.spinner('Evaluating data...'):
statistical_results = statistical_tests(df)
#correlation_results = calculate_correlations(df)
#divergence_results = calculate_divergences(df)
flat_statistical_results = {f"{key1}": value1 for key1, value1 in statistical_results.items()}
#flat_correlation_results = {f"Correlation_{key1}": value1 for key1, value1 in correlation_results.items()}
#flat_divergence_results = {f"Divergence_{key1}": value1 for key1, value1 in divergence_results.items()}
results_combined = {**flat_statistical_results} #,**flat_correlation_results}#, **flat_divergence_results}
results_df = pd.DataFrame(list(results_combined.items()), columns=['Metric', 'Value'])
st.write('Test Results:', results_df)
score_fig = create_score_plot(df)
st.plotly_chart(score_fig)
rank_fig = create_rank_plots(df)
st.plotly_chart(rank_fig)
hist_fig = px.histogram(df.melt(id_vars=['Role'],
value_vars=['Privilege_Avg_Score', 'Protect_Avg_Score',
'Neutral_Avg_Score']),
x='value', color='variable', facet_col='variable',
title='Distribution of Scores')
st.plotly_chart(hist_fig)
hist_rank_fig = px.histogram(
df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
x='value', color='variable', facet_col='variable', title='Distribution of Ranks')
st.plotly_chart(hist_rank_fig)
box_fig = px.box(df.melt(id_vars=['Role'], value_vars=['Privilege_Avg_Score', 'Protect_Avg_Score',
'Neutral_Avg_Score']),
x='variable', y='value', color='variable', title='Spread of Scores')
st.plotly_chart(box_fig)
box_rank_fig = px.box(
df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
x='variable', y='value', color='variable', title='Spread of Ranks')
st.plotly_chart(box_rank_fig)
heatmaps = create_correlation_heatmaps(df)
for title, fig in heatmaps.items():
st.plotly_chart(fig)
st.download_button(
label="Download Evaluation Results",
data=results_df.to_csv(index=False).encode('utf-8'),
file_name='evaluation_results.csv',
mime='text/csv',
)
if __name__ == "__main__":
app()
|