fix: handling string feature values in SHAP output
Browse files- .gitignore +5 -1
- app/main.py +1 -2
.gitignore
CHANGED
|
@@ -15,4 +15,8 @@ env/
|
|
| 15 |
|
| 16 |
# Fichiers système
|
| 17 |
.DS_Store
|
| 18 |
-
Thumbs.db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Fichiers système
|
| 17 |
.DS_Store
|
| 18 |
+
Thumbs.db
|
| 19 |
+
|
| 20 |
+
# Test coverage report
|
| 21 |
+
htmlcov/
|
| 22 |
+
.coverage
|
app/main.py
CHANGED
|
@@ -150,8 +150,7 @@ def predict(data: EmployeeInput):
|
|
| 150 |
"top_5_factors": {
|
| 151 |
factor: {
|
| 152 |
"interpretation": interpret_shap(rank, shap_series[factor]),
|
| 153 |
-
"feature_value": float(df[factor].values[0]) if factor in df.columns else "encoded"
|
| 154 |
-
}
|
| 155 |
for rank, factor in enumerate(top_factors.index)
|
| 156 |
}
|
| 157 |
}
|
|
|
|
| 150 |
"top_5_factors": {
|
| 151 |
factor: {
|
| 152 |
"interpretation": interpret_shap(rank, shap_series[factor]),
|
| 153 |
+
"feature_value": str(df[factor].values[0]) if factor in df.columns and isinstance(df[factor].values[0], str) else float(df[factor].values[0]) if factor in df.columns else "encoded" }
|
|
|
|
| 154 |
for rank, factor in enumerate(top_factors.index)
|
| 155 |
}
|
| 156 |
}
|