LovnishVerma commited on
Commit
538e361
·
verified ·
1 Parent(s): 606c477

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -50
app.py CHANGED
@@ -8,7 +8,7 @@ from datetime import datetime
8
  # 1. PAGE CONFIGURATION
9
  st.set_page_config(
10
  page_title="S.T.A.R.K AI | UIDAI Fraud Detection",
11
- page_icon="",
12
  layout="wide",
13
  initial_sidebar_state="expanded"
14
  )
@@ -163,54 +163,54 @@ def load_data():
163
  'West Bengal': (22.9868, 87.8550)
164
  }
165
 
166
- def get_coords(row):
167
- state = row.get('state', 'Delhi')
168
- district = str(row.get('district', 'Unknown'))
169
-
170
- # 1. Get State Base Coordinates (Use your updated list)
171
- base_lat, base_lon = state_centers.get(state, (20.5937, 78.9629))
172
-
173
- # 2. DEFINE STATE RADIUS SCALER (In Degrees)
174
- # Default is 0.5 (~55km) which is safer than 1.5
175
- default_radius = 0.5
176
-
177
- # Tighter constraints for small States/UTs
178
- radius_map = {
179
- 'Chandigarh': 0.04,
180
- 'Delhi': 0.15,
181
- 'Goa': 0.15,
182
- 'Puducherry': 0.1,
183
- 'Lakshadweep': 0.05,
184
- 'Daman and Diu': 0.05,
185
- 'Dadra and Nagar Haveli': 0.05,
186
- 'Kerala': 0.3, # Narrow state
187
- 'Haryana': 0.4,
188
- 'Punjab': 0.4,
189
- 'Tripura': 0.3,
190
- 'Sikkim': 0.15,
191
- 'Andaman and Nicobar Islands': 1.0 # Long archipelago
192
- }
193
-
194
- # Get the specific radius for this state
195
- radius = radius_map.get(state, default_radius)
196
-
197
- # 3. DETERMINISTIC HASHING
198
- district_hash = hash(state + district)
199
- np.random.seed(district_hash % 2**32)
200
-
201
- # Offset using the specific radius
202
- dist_lat_offset = np.random.uniform(-radius, radius)
203
- dist_lon_offset = np.random.uniform(-radius, radius)
204
-
205
- # 4. MICRO JITTER (Random noise for individual points)
206
- np.random.seed(None)
207
- noise_lat = np.random.normal(0, 0.02 * radius) # Scale noise relative to state size
208
- noise_lon = np.random.normal(0, 0.02 * radius)
209
-
210
- return pd.Series({
211
- 'lat': base_lat + dist_lat_offset + noise_lat,
212
- 'lon': base_lon + dist_lon_offset + noise_lon
213
- })
214
 
215
  # Apply coordinates
216
  coords = df.apply(get_coords, axis=1)
@@ -379,7 +379,7 @@ with tab_list:
379
  st.download_button(
380
  "Download CSV",
381
  data=csv,
382
- file_name="uidai_S.T.A.R.K AI_priority_list.csv",
383
  mime="text/csv",
384
  type="primary"
385
  )
 
8
  # 1. PAGE CONFIGURATION
9
  st.set_page_config(
10
  page_title="S.T.A.R.K AI | UIDAI Fraud Detection",
11
+ page_icon="🛡️",
12
  layout="wide",
13
  initial_sidebar_state="expanded"
14
  )
 
163
  'West Bengal': (22.9868, 87.8550)
164
  }
165
 
166
+ def get_coords(row):
167
+ state = row.get('state', 'Delhi')
168
+ district = str(row.get('district', 'Unknown'))
169
+
170
+ # 1. Get State Base Coordinates (Use your updated list)
171
+ base_lat, base_lon = state_centers.get(state, (20.5937, 78.9629))
172
+
173
+ # 2. DEFINE STATE RADIUS SCALER (In Degrees)
174
+ # Default is 0.5 (~55km) which is safer than 1.5
175
+ default_radius = 0.5
176
+
177
+ # Tighter constraints for small States/UTs
178
+ radius_map = {
179
+ 'Chandigarh': 0.04,
180
+ 'Delhi': 0.15,
181
+ 'Goa': 0.15,
182
+ 'Puducherry': 0.1,
183
+ 'Lakshadweep': 0.05,
184
+ 'Daman and Diu': 0.05,
185
+ 'Dadra and Nagar Haveli': 0.05,
186
+ 'Kerala': 0.3, # Narrow state
187
+ 'Haryana': 0.4,
188
+ 'Punjab': 0.4,
189
+ 'Tripura': 0.3,
190
+ 'Sikkim': 0.15,
191
+ 'Andaman and Nicobar Islands': 1.0 # Long archipelago
192
+ }
193
+
194
+ # Get the specific radius for this state
195
+ radius = radius_map.get(state, default_radius)
196
+
197
+ # 3. DETERMINISTIC HASHING
198
+ district_hash = hash(state + district)
199
+ np.random.seed(district_hash % 2**32)
200
+
201
+ # Offset using the specific radius
202
+ dist_lat_offset = np.random.uniform(-radius, radius)
203
+ dist_lon_offset = np.random.uniform(-radius, radius)
204
+
205
+ # 4. MICRO JITTER (Random noise for individual points)
206
+ np.random.seed(None)
207
+ noise_lat = np.random.normal(0, 0.02 * radius) # Scale noise relative to state size
208
+ noise_lon = np.random.normal(0, 0.02 * radius)
209
+
210
+ return pd.Series({
211
+ 'lat': base_lat + dist_lat_offset + noise_lat,
212
+ 'lon': base_lon + dist_lon_offset + noise_lon
213
+ })
214
 
215
  # Apply coordinates
216
  coords = df.apply(get_coords, axis=1)
 
379
  st.download_button(
380
  "Download CSV",
381
  data=csv,
382
+ file_name="uidai_stark_ai_priority_list.csv",
383
  mime="text/csv",
384
  type="primary"
385
  )