Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +6 -0
- app.py +24 -0
- requirements.txt +6 -0
- superkart_best_model.pkl +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY . .
|
| 4 |
+
RUN pip install -r requirements.txt
|
| 5 |
+
EXPOSE 8000
|
| 6 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
model = joblib.load("superkart_best_model.pkl")
|
| 8 |
+
|
| 9 |
+
FEATURE_COLUMNS = ["Product_Weight","Product_Sugar_Content","Product_Allocated_Area","Product_Type","Product_MRP","Store_Establishment_Year","Store_Size","Store_Location_City_Type","Store_Type","Store_Current_Age","Product_Type_Group"]
|
| 10 |
+
|
| 11 |
+
@app.route("/predict", methods=["POST"])
|
| 12 |
+
def predict():
|
| 13 |
+
data = request.get_json()
|
| 14 |
+
df_input = pd.DataFrame([data])
|
| 15 |
+
df_input = df_input.reindex(columns=FEATURE_COLUMNS, fill_value=0)
|
| 16 |
+
preds = model.predict(df_input)
|
| 17 |
+
return jsonify({"predictions": preds.tolist()})
|
| 18 |
+
|
| 19 |
+
@app.route("/", methods=["GET"])
|
| 20 |
+
def home():
|
| 21 |
+
return "SuperKart API Ready!"
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
app.run(host="0.0.0.0", port=8000)
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask==3.0.3
|
| 2 |
+
numpy==2.0.2
|
| 3 |
+
pandas==2.2.2
|
| 4 |
+
scikit-learn==1.6.1
|
| 5 |
+
xgboost==2.1.4
|
| 6 |
+
joblib==1.4.2
|
superkart_best_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d09945964f4a7e3d3983192be044bb459d5540d92ad9a0b979c8e4e5c2b256c5
|
| 3 |
+
size 1270901
|