AbdullahImran commited on
Commit
c7e7611
·
verified ·
1 Parent(s): a7db21d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -43,19 +43,17 @@ def run_all_models(file):
43
  return "Error processing file", None, None, None, None, None
44
 
45
  try:
46
- # Prepare data for models
47
- model_features = df.copy()
48
- for col in ['Id','anomaly_score','risk_flag']:
49
- if col in model_features:
50
- model_features.drop(col, axis=1, inplace=True)
51
- # Fill NaNs
52
- model_features = model_features.fillna(0)
53
 
54
- # Align DataFrame columns to model’s training set:
55
- model_features = model_features.reindex(
56
- columns=expected_features, # from xgb_clf.get_booster().feature_names
57
- fill_value=0
58
- )
 
 
 
59
 
60
  # 1. BANKRUPTCY CLASSIFICATION
61
  bankruptcy_preds = xgb_clf.predict(clf_features)
 
43
  return "Error processing file", None, None, None, None, None
44
 
45
  try:
46
+ # CLEAN DATASET: Drop irrelevant columns
47
+ df_clean = df.drop(columns=[col for col in ['Id', 'anomaly_score', 'risk_flag'] if col in df.columns])
 
 
 
 
 
48
 
49
+ # 1. Features for bankruptcy classification (XGBoost raw model)
50
+ clf_features = df_clean.copy()
51
+ clf_features = clf_features.fillna(0)
52
+ clf_features = clf_features.reindex(columns=expected_features, fill_value=0)
53
+
54
+ # 2. Features for anomaly detection (XGBoost pipeline model)
55
+ reg_features = df_clean.copy() # Pipeline handles preprocessing internally
56
+
57
 
58
  # 1. BANKRUPTCY CLASSIFICATION
59
  bankruptcy_preds = xgb_clf.predict(clf_features)