|
import streamlit as st |
|
from sklearn.metrics import roc_curve, auc |
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
|
|
|
|
st.title("ROC Paper Seizure") |
|
|
|
st.write(""" |
|
This application allows you to upload a CSV file containing true labels and predicted scores. |
|
It computes the Receiver Operating Characteristic (ROC) curve and the Area Under the Curve (AUC). |
|
""") |
|
|
|
|
|
uploaded_file = st.file_uploader("Upload your data (CSV with 'true_labels' and 'scores' columns)", type=["csv"]) |
|
|
|
if uploaded_file: |
|
try: |
|
|
|
data = np.genfromtxt(uploaded_file, delimiter=',', names=True) |
|
true_labels = data['true_labels'] |
|
scores = data['scores'] |
|
|
|
|
|
fpr, tpr, thresholds = roc_curve(true_labels, scores) |
|
roc_auc = auc(fpr, tpr) |
|
|
|
|
|
st.write(f"**AUC (Area Under the Curve):** {roc_auc:.3f}") |
|
|
|
|
|
fig, ax = plt.subplots() |
|
ax.plot(fpr, tpr, color='blue', lw=2, label=f"ROC curve (AUC = {roc_auc:.2f})") |
|
ax.plot([0, 1], [0, 1], color='gray', linestyle='--', lw=2) |
|
ax.set_xlim([0.0, 1.0]) |
|
ax.set_ylim([0.0, 1.05]) |
|
ax.set_xlabel('False Positive Rate') |
|
ax.set_ylabel('True Positive Rate') |
|
ax.set_title('Receiver Operating Characteristic') |
|
ax.legend(loc="lower right") |
|
|
|
st.pyplot(fig) |
|
|
|
except Exception as e: |
|
st.error(f"An error occurred while processing the file: {e}") |
|
|