File size: 1,670 Bytes
86607a2
 
 
0ba415f
86607a2
 
cf25467
86607a2
 
 
 
 
 
 
 
860deeb
86607a2
860deeb
86607a2
 
 
 
 
 
 
40d7b09
f0d28e4
40d7b09
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
import streamlit as st
import pandas as pd
from io import StringIO
from util.evaluation 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[['Counterfactual_Avg_Score', 'Neutral_Avg_Score']].rank(axis=1, ascending=False)

        df['Counterfactual_Rank'] = ranks['Counterfactual_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,"single")
                st.write('Test Results:', test_results)
                evaluation_results = result_evaluation(test_results,"single")
                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()