kritish205 commited on
Commit
fc800f1
·
verified ·
1 Parent(s): 893f93c

Upload folder using huggingface_hub

Browse files
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use python 3.9 as base image
2
+ FROM python:3.9
3
+
4
+ # Set working directory
5
+ WORKDIR /code
6
+
7
+ # Copy requirements and install
8
+ COPY requirements.txt /code/requirements.txt
9
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
10
+
11
+ # Copy the rest of the app code
12
+ COPY . /code
13
+
14
+ # Command to run the app
15
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+ from huggingface_hub import hf_hub_download
5
+ import os
6
+
7
+ # 1. Load the model from Hugging Face Hub
8
+ REPO_ID = "your_username/superkart-sales-predictor"
9
+ model_path = hf_hub_download(repo_id=REPO_ID, filename="model.joblib")
10
+ model = joblib.load(model_path)
11
+
12
+ def predict_sales(Product_Weight, Product_Sugar_Content, Product_Allocated_Area,
13
+ Product_Type, Product_MRP, Store_Establishment_Year,
14
+ Store_Size, Store_Location_City_Type, Store_Type):
15
+
16
+ # 2. Get inputs and save into a dataframe
17
+ input_data = pd.DataFrame([{
18
+ 'Product_Weight': Product_Weight,
19
+ 'Product_Sugar_Content': Product_Sugar_Content,
20
+ 'Product_Allocated_Area': Product_Allocated_Area,
21
+ 'Product_Type': Product_Type,
22
+ 'Product_MRP': Product_MRP,
23
+ 'Store_Establishment_Year': Store_Establishment_Year,
24
+ 'Store_Size': Store_Size,
25
+ 'Store_Location_City_Type': Store_Location_City_Type,
26
+ 'Store_Type': Store_Type
27
+ }])
28
+
29
+ prediction = model.predict(input_data)[0]
30
+ return f"Estimated Total Sales: ${round(prediction, 2)}"
31
+
32
+ # 3. Define the Gradio Interface
33
+ interface = gr.Interface(
34
+ fn=predict_sales,
35
+ inputs=[
36
+ gr.Number(label="Product Weight"),
37
+ gr.Dropdown(["Low Sugar", "Regular", "No Sugar"], label="Sugar Content"),
38
+ gr.Slider(0, 1, label="Allocated Area Ratio"),
39
+ gr.Dropdown(['Frozen Foods', 'Dairy', 'Canned', 'Baking Goods', 'Health and Hygiene', 'Others'], label="Product Type"),
40
+ gr.Number(label="Product MRP"),
41
+ gr.Number(label="Store Establishment Year"),
42
+ gr.Dropdown(["Small", "Medium", "High"], label="Store Size"),
43
+ gr.Dropdown(["Tier 1", "Tier 2", "Tier 3"], label="City Type"),
44
+ gr.Dropdown(["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"], label="Store Type")
45
+ ],
46
+ outputs="text",
47
+ title="SuperKart Sales Forecast",
48
+ description="Enter product and store details to predict total sales."
49
+ )
50
+
51
+ if __name__ == "__main__":
52
+ interface.launch()
data/superkart_sales_data.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/test.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/train.csv ADDED
The diff for this file is too large to render. See raw diff
 
models/sales_rf_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e129dc8d0cc1b80e6597ae5ec6bbe180608917fc2e591a7bdda6588fa5ad09d8
3
+ size 49992634
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas
2
+ joblib
3
+ scikit-learn
4
+ huggingface_hub
5
+ gradio