Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,22 +42,20 @@ def run_all_models(file):
|
|
42 |
|
43 |
try:
|
44 |
# Prepare data for models (assuming same feature set as training)
|
|
|
45 |
model_features = df.copy()
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
if col in model_features.columns:
|
51 |
-
model_features = model_features.drop(col, axis=1)
|
52 |
-
|
53 |
-
# Handle missing values
|
54 |
model_features = model_features.fillna(0)
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
61 |
# 1. BANKRUPTCY CLASSIFICATION
|
62 |
bankruptcy_preds = xgb_clf.predict(model_features)
|
63 |
bankruptcy_probs = xgb_clf.predict_proba(model_features)
|
|
|
42 |
|
43 |
try:
|
44 |
# Prepare data for models (assuming same feature set as training)
|
45 |
+
# Prepare data for models
|
46 |
model_features = df.copy()
|
47 |
+
for col in ['Id','anomaly_score','risk_flag']:
|
48 |
+
if col in model_features:
|
49 |
+
model_features.drop(col, axis=1, inplace=True)
|
50 |
+
# Fill NaNs
|
|
|
|
|
|
|
|
|
51 |
model_features = model_features.fillna(0)
|
52 |
+
|
53 |
+
# Align DataFrame columns to model’s training set:
|
54 |
+
model_features = model_features.reindex(
|
55 |
+
columns=expected_features, # from xgb_clf.get_booster().feature_names
|
56 |
+
fill_value=0
|
57 |
+
)
|
58 |
+
|
59 |
# 1. BANKRUPTCY CLASSIFICATION
|
60 |
bankruptcy_preds = xgb_clf.predict(model_features)
|
61 |
bankruptcy_probs = xgb_clf.predict_proba(model_features)
|