Skip to content

Commit 4f321c0

Browse files
authored
Create devcontainer.json
1 parent e7ecd9e commit 4f321c0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.devcontainer/devcontainer.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{pip install flask,
2+
"image": "mcr.microsoft.com/devcontainers/universal:2",
3+
"features": {}from flask import Flask, request, jsonify
4+
import pandas as pd
5+
from sklearn.preprocessing import StandardScaler
6+
7+
# Initialize Flask app
8+
app = Flask(__name__)
9+
10+
# Pre-trained model (make sure to load your actual trained model here)
11+
from sklearn.ensemble import RandomForestClassifier
12+
13+
# Load model (replace this with your actual model loading process)
14+
# model = load_your_trained_model()
15+
16+
# For example, if using a Random Forest:
17+
model = RandomForestClassifier(n_estimators=100, random_state=42)
18+
19+
# Pre-process input data (standardize it based on your training process)
20+
scaler = StandardScaler()
21+
22+
@app.route('/predict', methods=['POST'])
23+
def predict():
24+
# Get data from the request
25+
data = request.get_json(force=True)
26+
27+
# Ensure the data has the correct format (this will depend on your feature set)
28+
features = pd.DataFrame(data['features'])
29+
30+
# Standardize features
31+
features = scaler.transform(features)
32+
33+
# Make prediction
34+
prediction = model.predict(features)
35+
36+
# Return the prediction as JSON
37+
return jsonify({'prediction': prediction.tolist()})
38+
39+
if __name__ == '__main__':
40+
app.run(debug=True)
41+
}curl -X POST http://127.0.0.1:5000/predict -H "Content-Type: application/json" -d '{"features": [[1.5, 2.3, 3.1]]}'

0 commit comments

Comments
 (0)