Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -84,13 +84,20 @@ class IrisPredictor:
|
|
84 |
labels={'x': 'Features', 'y': 'Importance'})
|
85 |
return fig
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
def main():
|
96 |
st.title("🌸 Iris Flower Prediction App")
|
|
|
84 |
labels={'x': 'Features', 'y': 'Importance'})
|
85 |
return fig
|
86 |
|
87 |
+
def predict_single_sample(self, model, features):
|
88 |
+
# Ensure scaler is fitted
|
89 |
+
if not hasattr(self.scaler, "mean_"):
|
90 |
+
raise RuntimeError("The scaler is not fitted. Please train the model first.")
|
91 |
+
|
92 |
+
# Scale features
|
93 |
+
scaled_features = self.scaler.transform([features])
|
94 |
+
|
95 |
+
# Make prediction
|
96 |
+
prediction = model.predict(scaled_features)
|
97 |
+
probabilities = model.predict_proba(scaled_features)
|
98 |
+
|
99 |
+
return prediction[0], probabilities[0]
|
100 |
+
|
101 |
|
102 |
def main():
|
103 |
st.title("🌸 Iris Flower Prediction App")
|