MLDeveloper commited on
Commit
58f8c94
·
verified ·
1 Parent(s): 8f5a5bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import streamlit as st
2
  import numpy as np
3
- import pandas as pd
4
  from sklearn.linear_model import LinearRegression
5
 
6
  # Streamlit page config
@@ -11,42 +10,40 @@ st.markdown("Enter item details below to predict sales:")
11
 
12
  # Input fields
13
  project_name = st.text_input("📦 Project Name")
14
- item_weight = st.number_input("⚖️ Item Weight (kg)", min_value=0.0, step=0.1)
15
- item_visibility = st.slider("👀 Item Visibility", 0.0, 1.0, 0.1)
16
- item_mrp = st.number_input("💰 Item MRP (Max Retail Price)", min_value=0.0, step=1.0)
17
 
18
  # Predict button
19
  if st.button("Predict Sales"):
20
  if not project_name:
21
  st.warning("Please enter a project name.")
22
  else:
23
- # Dummy ML Model: Replace with your actual trained model
24
  X_train = np.array([
25
  [9.3, 0.016, 249.8],
26
  [5.92, 0.019, 48.27],
27
  [17.5, 0.016, 141.62],
28
  [19.2, 0.0075, 182.095],
29
  ])
30
- y_train = np.array([3735.14, 443.42, 2233.6, 3612.47]) # example sales
31
 
 
32
  model = LinearRegression()
33
  model.fit(X_train, y_train)
34
 
35
- # Prepare input
36
  user_input = np.array([[item_weight, item_visibility, item_mrp]])
37
- prediction = model.predict(user_input)[0]
38
 
39
- st.success(f"📈 Predicted Sales for '{project_name}': ₹{prediction:,.2f}")
40
 
41
- # Sidebar info
42
  st.sidebar.title("📌 About")
43
  st.sidebar.markdown(
44
  """
45
- This app uses a simple ML model to estimate sales based on:
46
- - Item weight
47
- - Item visibility
48
- - Item MRP
49
-
50
- Replace with a trained BigMart dataset model for production use.
51
  """
52
  )
 
1
  import streamlit as st
2
  import numpy as np
 
3
  from sklearn.linear_model import LinearRegression
4
 
5
  # Streamlit page config
 
10
 
11
  # Input fields
12
  project_name = st.text_input("📦 Project Name")
13
+ item_weight = st.number_input("⚖️ Item Weight (in kg)", min_value=0.0, step=0.1)
14
+ item_visibility = st.slider("👀 Item Visibility", 0.0, 1.0, 0.05)
15
+ item_mrp = st.number_input("💰 Item MRP", min_value=0.0, step=1.0)
16
 
17
  # Predict button
18
  if st.button("Predict Sales"):
19
  if not project_name:
20
  st.warning("Please enter a project name.")
21
  else:
22
+ # Dummy training data for demo
23
  X_train = np.array([
24
  [9.3, 0.016, 249.8],
25
  [5.92, 0.019, 48.27],
26
  [17.5, 0.016, 141.62],
27
  [19.2, 0.0075, 182.095],
28
  ])
29
+ y_train = np.array([3735.14, 443.42, 2233.6, 3612.47]) # Target: Item_Outlet_Sales
30
 
31
+ # Train model
32
  model = LinearRegression()
33
  model.fit(X_train, y_train)
34
 
35
+ # Prepare user input
36
  user_input = np.array([[item_weight, item_visibility, item_mrp]])
37
+ predicted_sales = model.predict(user_input)[0]
38
 
39
+ st.success(f"📈 Predicted Sales for '{project_name}': ₹{predicted_sales:,.2f}")
40
 
41
+ # Sidebar
42
  st.sidebar.title("📌 About")
43
  st.sidebar.markdown(
44
  """
45
+ This app predicts sales based on item weight, visibility, and MRP using a demo ML model.
46
+
47
+ 🔧 Replace with a trained model on BigMart dataset for real-world use!
 
 
 
48
  """
49
  )