LovnishVerma commited on
Commit
3cb671d
·
verified ·
1 Parent(s): 30fc09f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -24
app.py CHANGED
@@ -63,29 +63,9 @@ st.markdown("""
63
  # 3. ENHANCED DATA LOADING
64
  @st.cache_data(ttl=300)
65
  def load_data():
66
- try:
67
- df = pd.read_csv('analyzed_aadhaar_data.csv')
68
- st.toast("✅ Data loaded successfully", icon="✅")
69
- except FileNotFoundError:
70
- st.toast("📊 Generating sample data...", icon="ℹ️")
71
- dates = pd.date_range(start="2024-10-01", periods=300, freq='D')
72
- districts = ['North District', 'South Region', 'East Zone', 'West End', 'Central Hub',
73
- 'Rural A', 'Urban B', 'Coastal District', 'Mountain Region', 'Valley Area']
74
- df = pd.DataFrame({
75
- 'date': np.random.choice(dates, 300),
76
- 'state': np.random.choice([
77
- 'Maharashtra', 'Uttar Pradesh', 'Bihar', 'Karnataka', 'Delhi', 'West Bengal',
78
- 'Kerala', 'Assam', 'Rajasthan', 'Gujarat', 'Tamil Nadu', 'Madhya Pradesh',
79
- 'Telangana', 'Punjab', 'Haryana', 'Andhra Pradesh', 'Odisha', 'Chhattisgarh'
80
- ], 300),
81
- 'district': np.random.choice(districts, 300),
82
- 'pincode': np.random.randint(110001, 800000, 300),
83
- 'RISK_SCORE': np.random.beta(2, 5, 300) * 100,
84
- 'total_activity': np.random.gamma(4, 50, 300).astype(int),
85
- 'enrol_adult': np.random.gamma(3, 30, 300).astype(int),
86
- 'ratio_deviation': np.random.normal(0, 0.2, 300),
87
- 'is_weekend': np.random.choice([0, 1], 300, p=[0.72, 0.28])
88
- })
89
 
90
  if 'date' in df.columns: df['date'] = pd.to_datetime(df['date'])
91
 
@@ -147,7 +127,10 @@ def load_data():
147
  df['risk_category'] = pd.cut(df['RISK_SCORE'], bins=[-1, 50, 75, 85, 100], labels=['Low', 'Medium', 'High', 'Critical'])
148
  return df
149
 
150
- with st.spinner('Loading S.T.A.R.K AI System...'): df = load_data()
 
 
 
151
 
152
  # 4. SIDEBAR & FILTERS
153
  with st.sidebar:
 
63
  # 3. ENHANCED DATA LOADING
64
  @st.cache_data(ttl=300)
65
  def load_data():
66
+ # Strictly load data from CSV
67
+ df = pd.read_csv('analyzed_aadhaar_data.csv')
68
+ # Removed st.toast from inside cached function to prevent CacheReplayClosureError
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  if 'date' in df.columns: df['date'] = pd.to_datetime(df['date'])
71
 
 
127
  df['risk_category'] = pd.cut(df['RISK_SCORE'], bins=[-1, 50, 75, 85, 100], labels=['Low', 'Medium', 'High', 'Critical'])
128
  return df
129
 
130
+ with st.spinner('Loading S.T.A.R.K AI System...'):
131
+ df = load_data()
132
+ # Toast moved outside cached function
133
+ # st.toast("✅ Data loaded successfully", icon="✅")
134
 
135
  # 4. SIDEBAR & FILTERS
136
  with st.sidebar: