Pushpak21 commited on
Commit
79cc816
·
verified ·
1 Parent(s): 24f9aea

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +2 -1
  2. predictor/error_summary_table.py +33 -0
app.py CHANGED
@@ -106,7 +106,8 @@ with tab2:
106
  )
107
 
108
  st.dataframe(df)
 
109
  plot_actual_vs_predicted_scatter(df)
110
-
111
  except Exception as e:
112
  st.error(f"⚠️ Error while processing the file: {e}")
 
106
  )
107
 
108
  st.dataframe(df)
109
+ error_summary_table(df)
110
  plot_actual_vs_predicted_scatter(df)
111
+
112
  except Exception as e:
113
  st.error(f"⚠️ Error while processing the file: {e}")
predictor/error_summary_table.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import altair as alt
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+ def error_summary_table(df: pd.DataFrame):
7
+ if "Product_Store_Sales_Total" not in df.columns or "Predicted_Sales" not in df.columns:
8
+ st.warning("Required columns missing for error summary.")
9
+ return
10
+
11
+ plot_df = df[["Product_Store_Sales_Total", "Predicted_Sales"]].dropna().copy()
12
+ plot_df["Error"] = abs(plot_df["Product_Store_Sales_Total"] - plot_df["Predicted_Sales"])
13
+
14
+ # Define thresholds
15
+ conditions = [
16
+ (plot_df["Error"] <= 500),
17
+ (plot_df["Error"] > 500) & (plot_df["Error"] <= 1500),
18
+ (plot_df["Error"] > 1500)
19
+ ]
20
+ labels = ["Accurate (<=500)", "Moderate (501-1500)", "High Error (>1500)"]
21
+ plot_df["Error_Category"] = pd.cut(
22
+ plot_df["Error"],
23
+ bins=[-float('inf'), 500, 1500, float('inf')],
24
+ labels=labels
25
+ )
26
+
27
+ summary = plot_df["Error_Category"].value_counts().reset_index()
28
+ summary.columns = ["Error Category", "Number of Records"]
29
+
30
+ st.subheader("🔍 Error Summary")
31
+ st.table(summary)
32
+
33
+ return summary