babloo555777 commited on
Commit
cf91b4b
·
verified ·
1 Parent(s): 96b900e

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +16 -0
  2. app.py +39 -0
  3. requirements.txt +9 -0
  4. superkart_model_v1_0.joblib +3 -0
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ # Set the working directory inside the container
4
+ WORKDIR /app
5
+
6
+ # Copy all files from the current directory to the container's working directory
7
+ COPY . .
8
+
9
+ # Install dependencies from the requirements file without using cache to reduce image size
10
+ RUN pip install --no-cache-dir -r requirements.txt
11
+
12
+ # Define the command to start the application using Gunicorn with 4 worker processes
13
+ # - `-w 4`: Uses 4 worker processes for handling requests
14
+ # - `-b 0.0.0.0:7860`: Binds the server to port 7860 on all network interfaces
15
+ # - `app:app`: Runs the Flask app (assuming `app.py` contains the Flask instance named `app`)
16
+ CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"]
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ import pandas as pd
3
+ from flask import Flask, request, jsonify
4
+
5
+ app = Flask("SuperKart Sales Predictor")
6
+
7
+ model = joblib.load("superkart_v1_0.joblib")
8
+
9
+
10
+ @app.get('/')
11
+ def home():
12
+ return "Welcome to the SuperKart Sales Prediction API"
13
+
14
+ @app.post('/v1/customer')
15
+ def predict_churn():
16
+
17
+ customer_data = request.get_json()
18
+
19
+ # Extract relevant customer features from the input data
20
+ sample = {
21
+ 'Product_Weight': customer_data['Product_Weight'],
22
+ 'Product_Sugar_Content': customer_data['Product_Sugar_Content'],
23
+ 'Product_Allocated_Area': customer_data['Product_Allocated_Area'],
24
+ 'Product_Type': customer_data['Product_Type'],
25
+ 'Product_MRP': customer_data['Product_MRP'],
26
+ 'Store_Establishment_Year': customer_data['Store_Establishment_Year'],
27
+ 'Store_Size': customer_data['Store_Size'],
28
+ 'Store_Location_City_Type': customer_data['Store_Location_City_Type'],
29
+ 'Store_Type': customer_data['Store_Type'],
30
+ }
31
+
32
+ input_data = pd.DataFrame([sample])
33
+
34
+ prediction = model.predict(input_data).tolist()[0]
35
+
36
+ return prediction
37
+
38
+ if __name__ == '__main__':
39
+ app.run(debug=True)
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ numpy==2.0.2
2
+ pandas==2.2.2
3
+ scikit-learn==1.6.1
4
+ matplotlib==3.10.0
5
+ seaborn==0.13.2
6
+ joblib==1.4.2
7
+ xgboost==2.1.4
8
+ requests==2.32.3
9
+ huggingface_hub==0.30.1
superkart_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0a6c737696559949fe6f5e020c8035c9e6bf36a39858f4fa2cf4a1ac3b7af5e
3
+ size 470116