inference added
Browse files- README.md +25 -0
- inference.py +20 -0
README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Flask Classification Model
|
| 2 |
+
|
| 3 |
+
This is a classification model trained with scikit-learn. The model predicts binary classes based on four input features.
|
| 4 |
+
|
| 5 |
+
## How to Use
|
| 6 |
+
|
| 7 |
+
1. Clone the repository.
|
| 8 |
+
2. Install necessary libraries.
|
| 9 |
+
3. Run `inference.py` with your input features.
|
| 10 |
+
|
| 11 |
+
Example:
|
| 12 |
+
|
| 13 |
+
```python
|
| 14 |
+
import joblib
|
| 15 |
+
import numpy as np
|
| 16 |
+
|
| 17 |
+
# Load model and scaler
|
| 18 |
+
model = joblib.load("classification_model.joblib")
|
| 19 |
+
scaler = joblib.load("scaler.pkl")
|
| 20 |
+
|
| 21 |
+
# Make a prediction
|
| 22 |
+
input_features = [0.5, 1.2, -0.3, 2.0]
|
| 23 |
+
scaled_features = scaler.transform(np.array(input_features).reshape(1, -1))
|
| 24 |
+
prediction = model.predict(scaled_features)
|
| 25 |
+
print(prediction)
|
inference.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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}")
|