Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,8 +31,17 @@ feature_options = {
|
|
| 31 |
'habitat': {'grasses': 'g', 'leaves': 'l', 'meadows': 'm', 'paths': 'p', 'urban': 'u', 'waste': 'w', 'woods': 'd'}
|
| 32 |
}
|
| 33 |
|
| 34 |
-
def predict_mushroom(features):
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
input_df = pd.DataFrame([numerical_features])
|
| 37 |
prediction = model.predict(input_df)
|
| 38 |
return 'Poisonous' if prediction[0] == 1 else 'Edible'
|
|
|
|
| 31 |
'habitat': {'grasses': 'g', 'leaves': 'l', 'meadows': 'm', 'paths': 'p', 'urban': 'u', 'waste': 'w', 'woods': 'd'}
|
| 32 |
}
|
| 33 |
|
| 34 |
+
# def predict_mushroom(features):
|
| 35 |
+
# numerical_features = {feature: feature_options[feature][value] for feature, value in features.items()}
|
| 36 |
+
# input_df = pd.DataFrame([numerical_features])
|
| 37 |
+
# prediction = model.predict(input_df)
|
| 38 |
+
# return 'Poisonous' if prediction[0] == 1 else 'Edible'
|
| 39 |
+
|
| 40 |
+
def predict_mushroom(*features):
|
| 41 |
+
# Convert the feature names to a dictionary based on the order
|
| 42 |
+
feature_names = list(feature_options.keys())
|
| 43 |
+
numerical_features = {feature_names[i]: feature_options[feature_names[i]][value] for i, value in enumerate(features)}
|
| 44 |
+
|
| 45 |
input_df = pd.DataFrame([numerical_features])
|
| 46 |
prediction = model.predict(input_df)
|
| 47 |
return 'Poisonous' if prediction[0] == 1 else 'Edible'
|