Spaces:
Sleeping
Sleeping
hamzayounis106 commited on
Commit ·
587edf4
1
Parent(s): 462f10c
Add StandardScaler object for feature scaling
Browse files- Introduced a new StandardScaler instance saved as scaler.pkl.
- This scaler standardizes features by removing the mean and scaling to unit variance.
- The scaler is configured with default parameters: with_mean=True, with_std=True, and copy=True.
- This change is essential for preprocessing data before model training to ensure consistent feature scaling.
- app.py +18 -0
- knn_diabetes_model.pkl +0 -0
- scaler.pkl +0 -0
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from flask import Flask, request, jsonify
|
| 4 |
+
|
| 5 |
+
# Load your model
|
| 6 |
+
model = joblib.load("knn_diabetes_model.pkl")
|
| 7 |
+
|
| 8 |
+
app = Flask(__name__)
|
| 9 |
+
|
| 10 |
+
@app.route("/predict", methods=["POST"])
|
| 11 |
+
def predict():
|
| 12 |
+
data = request.json # expects JSON with same feature names as training
|
| 13 |
+
df = pd.DataFrame(data)
|
| 14 |
+
predictions = model.predict(df)
|
| 15 |
+
return jsonify(predictions.tolist())
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
app.run(debug=True)
|
knn_diabetes_model.pkl
ADDED
|
Binary file (83.8 kB). View file
|
|
|
scaler.pkl
ADDED
|
Binary file (1.16 kB). View file
|
|
|