added all
Browse files- app.py +0 -0
- inference.py +9 -16
app.py
ADDED
|
File without changes
|
inference.py
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
|
|
|
|
|
| 1 |
import joblib
|
| 2 |
import numpy as np
|
| 3 |
-
from sklearn.preprocessing import StandardScaler
|
| 4 |
-
|
| 5 |
-
# Load the model and scaler
|
| 6 |
-
model = joblib.load("classification_model.joblib")
|
| 7 |
-
scaler = joblib.load("scaler.pkl")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
scaled_features = scaler.transform(np.array(features).reshape(1, -1))
|
| 12 |
-
prediction = model.predict(scaled_features)
|
| 13 |
-
return prediction[0]
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
print(f"Prediction: {result}")
|
|
|
|
| 1 |
+
# inference.py
|
| 2 |
+
|
| 3 |
import joblib
|
| 4 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Load your model (no scaler)
|
| 7 |
+
model = joblib.load('classification_model.joblib')
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def predict(input_features):
|
| 10 |
+
# Make sure the input is a 2D array (batch_size, num_features)
|
| 11 |
+
input_array = np.array(input_features).reshape(1, -1)
|
| 12 |
+
prediction = model.predict(input_array)
|
| 13 |
+
return prediction.tolist() # Return the prediction as a list for easy JSON handling
|
|
|