Mahendra87 commited on
Commit
d1766f5
·
verified ·
1 Parent(s): 768e2d2

Upload 4 files

Browse files
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ # Set working directory inside container
8
+ WORKDIR /app
9
+
10
+ # Copy all files to the container
11
+ COPY . /app
12
+
13
+ # Install dependencies
14
+ RUN pip install --no-cache-dir --upgrade pip && \
15
+ pip install --no-cache-dir -r requirements.txt
16
+
17
+ # Expose the port Flask will run on (Hugging Face uses 7860)
18
+ EXPOSE 7860
19
+
20
+ # Command to run the app
21
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import joblib
3
+ import pandas as pd
4
+ import os
5
+
6
+
7
+ # Load the trained model pipeline
8
+ model_path = os.path.join("deployment_files", "super_kart_prediction_model_v1_0.joblib")
9
+ model = joblib.load(model_path)
10
+
11
+ # Initialize the Flask app
12
+ app = Flask(__name__)
13
+
14
+ @app.route('/')
15
+ def index():
16
+ return "SuperKart Sales Forecast API is running!"
17
+
18
+ @app.route('/predict', methods=['POST'])
19
+ def predict():
20
+ try:
21
+ # Get JSON data and convert to DataFrame
22
+ data = request.get_json()
23
+ df = pd.DataFrame(data)
24
+
25
+ # Make prediction
26
+ prediction = model.predict(df)
27
+
28
+ return jsonify({"prediction": prediction.tolist()})
29
+ except Exception as e:
30
+ return jsonify({"error": str(e)})
31
+
32
+ if __name__ == '__main__':
33
+ app.run(host='0.0.0.0', port=7860)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ flask
2
+ scikit-learn
3
+ pandas
4
+ numpy
5
+ xgboost
6
+ joblib
super_kart_prediction_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1ed63f9f7c8aa4cf526967cfdf5245f801b269c45a7eb8b6691ce8240f9ee65
3
+ size 418244