omm7 commited on
Commit
d595955
·
verified ·
1 Parent(s): 3b73c40

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +11 -0
  2. app.py +20 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /app
4
+
5
+ COPY . .
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ EXPOSE 7860
10
+
11
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import numpy as np
3
+ import pickle
4
+
5
+ app = Flask(__name__)
6
+
7
+ # Load model
8
+ with open("xgb_superkart_model.pkl", "rb") as f:
9
+ model = pickle.load(f)
10
+
11
+ @app.route("/")
12
+ def home():
13
+ return "SuperKart Sales Forecast API is live."
14
+
15
+ @app.route("/predict", methods=["POST"])
16
+ def predict():
17
+ data = request.get_json(force=True)
18
+ input_features = np.array(data["features"]).reshape(1, -1)
19
+ prediction = model.predict(input_features)
20
+ return jsonify({"prediction": float(prediction[0])})
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ flask
2
+ scikit-learn
3
+ numpy