File size: 2,306 Bytes
3540b28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ce45a2
3540b28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from statsmodels.stats.proportion import proportion_confint

# Set seaborn style
sns.set_theme(style="whitegrid")

# Set page config
st.set_page_config(page_title="Model Performance Dashboard", layout="wide")

# Title
st.title("๐Ÿ“Š Model Performance Dashboard")

# Load data
log_file = "/tmp/corrections_log.csv"

if not log_file:
    st.warning("โš ๏ธ No data available.")
else:
    df = pd.read_csv(log_file)

    if df.empty:
        st.info("โ„น๏ธ No logs recorded yet.")
    else:
        # Layout columns
        col1, col2 = st.columns(2)

        with col1:
            st.subheader("๐Ÿ”น Role Prediction Distribution")
            role_counts = df["model_prediction"].value_counts().sort_values(ascending=False)
            fig, ax = plt.subplots(figsize=(8, 5))
            palette = sns.color_palette("Set2", len(role_counts))
            sns.barplot(x=role_counts.values, y=role_counts.index, ax=ax, palette=palette)
            ax.set_xlabel("Count", fontsize=12)
            ax.set_ylabel("Predicted Role", fontsize=12)
            ax.set_title("Role Predictions Frequency", fontsize=14, weight='bold')
            sns.despine(left=True, bottom=True)
            st.pyplot(fig)

        with col2:
            correct_preds = df[df["model_prediction"] == df["corrected_prediction"]]
            accuracy = len(correct_preds) / len(df) * 100
            lower, upper = proportion_confint(count=len(correct_preds), nobs=len(df), alpha=0.05, method="wilson")

            st.subheader("โœ… Model Accuracy Overview")
            st.metric(label="Accuracy", value=f"{accuracy:.2f} %")
            st.markdown(
                f"""
                <div style="font-size:16px;">
                ๐Ÿ“Œ <strong>95% Confidence Interval:</strong><br>
                {lower*100:.2f}% to {upper*100:.2f}%
                </div>
                """,
                unsafe_allow_html=True
            )

        # Spacer
        st.markdown("---")

        # Logged data preview
        st.subheader("๐Ÿ“„ Recent Feedback Logs")
        st.dataframe(
            df[["timestamp", "model_prediction", "corrected_prediction"]].tail(10),
            use_container_width=True,
            height=300
        )