Dilipk commited on
Commit
07502c7
1 Parent(s): d69306c
Files changed (2) hide show
  1. app.py +0 -0
  2. 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
- def predict(features):
10
- # Scale the features
11
- scaled_features = scaler.transform(np.array(features).reshape(1, -1))
12
- prediction = model.predict(scaled_features)
13
- return prediction[0]
14
 
15
- # Sample usage
16
- if __name__ == "__main__":
17
- # Sample feature data (replace with real data when calling)
18
- sample_data = [0.5, 1.2, -0.3, 2.0]
19
- result = predict(sample_data)
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