Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 47 |
-
|
| 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 |
-
#
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 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)
|