GMARTINEZMILLA commited on
Commit
f8ab51b
·
1 Parent(s): 83a6565

feat: generated files

Browse files
Files changed (3) hide show
  1. app.py +31 -17
  2. customer_analysis.py +0 -22
  3. customer_recommendation.py +0 -24
app.py CHANGED
@@ -87,7 +87,7 @@ st.markdown("""
87
  """)
88
 
89
  # Navigation menu
90
- page = st.selectbox("Select the tool you want to use", ["", "Customer Analysis", "Customer Recommendations"])
91
 
92
  # Home Page
93
  if page == "":
@@ -188,12 +188,11 @@ elif page == "Customer Analysis":
188
  st.warning(f"No data found for customer {customer_code}. Please check the code.")
189
 
190
  # Customer Recommendations Page
191
- elif page == "Customer Recommendations":
192
- st.title("Customer Recommendations")
193
- st.markdown("""
194
- Get tailored recommendations for your customers based on their purchasing history.
195
- """)
196
 
 
197
  partial_code = st.text_input("Enter part of Customer Code for Recommendations (or leave empty to see all)")
198
  if partial_code:
199
  filtered_customers = df[df['CLIENTE'].str.contains(partial_code)]
@@ -202,15 +201,30 @@ elif page == "Customer Recommendations":
202
  customer_list = filtered_customers['CLIENTE'].unique()
203
  customer_code = st.selectbox("Select Customer Code for Recommendations", customer_list)
204
 
 
205
  if customer_code:
206
- customer_data = df[df["CLIENTE"] == str(customer_code)]
207
-
208
- if not customer_data.empty:
209
- st.write(f"### Purchase History for Customer {customer_code}")
210
- st.write(customer_data)
211
-
212
- st.write(f"### Recommended Products for Customer {customer_code}")
213
- # Placeholder for recommendation logic
214
- st.write("Product A, Product B, Product C")
215
- else:
216
- st.warning(f"No data found for customer {customer_code}. Please check the code.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  """)
88
 
89
  # Navigation menu
90
+ page = st.selectbox("Select the tool you want to use", ["", "Customer Analysis", "Basket Recommendations"])
91
 
92
  # Home Page
93
  if page == "":
 
188
  st.warning(f"No data found for customer {customer_code}. Please check the code.")
189
 
190
  # Customer Recommendations Page
191
+ elif page == "Basket Recommendations":
192
+ st.title("Basket Recommendations")
193
+ st.markdown("""Get tailored product recommendations for your customers based on their purchasing basket.""")
 
 
194
 
195
+ # Use the same customer search as in Customer Analysis
196
  partial_code = st.text_input("Enter part of Customer Code for Recommendations (or leave empty to see all)")
197
  if partial_code:
198
  filtered_customers = df[df['CLIENTE'].str.contains(partial_code)]
 
201
  customer_list = filtered_customers['CLIENTE'].unique()
202
  customer_code = st.selectbox("Select Customer Code for Recommendations", customer_list)
203
 
204
+ # Basket input section
205
  if customer_code:
206
+ st.write(f"### Purchase Basket for Customer {customer_code}")
207
+
208
+ # Create input fields for article codes and units
209
+ basket_items = []
210
+ num_lines = st.number_input("How many lines do you want to add?", min_value=1, value=1, step=1)
211
+
212
+ for i in range(num_lines):
213
+ col1, col2 = st.columns(2)
214
+ with col1:
215
+ article_code = st.text_input(f"Enter Article Code for Line {i + 1}")
216
+ with col2:
217
+ units = st.number_input(f"Enter Units for Line {i + 1}", min_value=1, value=1, step=1)
218
+
219
+ # Add each article code and units to the list
220
+ if article_code and units:
221
+ basket_items.append((article_code, units))
222
+
223
+ # Generate the concatenated string
224
+ input_cesta = ''.join([f"{code * units}" for code, units in basket_items])
225
+
226
+ # Show the result
227
+ st.write(f"Generated input_cesta: {input_cesta}")
228
+
229
+ # Placeholder for passing the input_cesta to the model
230
+ st.write("Model is not yet implemented, but input_cesta is ready.")
customer_analysis.py DELETED
@@ -1,22 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import plotly.express as px
4
-
5
- st.set_page_config(page_title="Customer Analysis", page_icon=":mag:")
6
-
7
- st.title("Customer Analysis")
8
- st.markdown("""
9
- Use the tools below to explore your customer data.
10
- """)
11
-
12
- # Cargar y visualizar datos
13
- uploaded_file = st.file_uploader("Upload your CSV file", type="csv")
14
- if uploaded_file:
15
- df = pd.read_csv(uploaded_file)
16
- st.write("## Dataset Overview", df.head())
17
-
18
- # Mostrar un gráfico interactivo
19
- st.markdown("### Sales per Customer")
20
- customer_sales = df.groupby("CLIENTE")["VENTA_ANUAL"].sum().reset_index()
21
- fig = px.bar(customer_sales, x="CLIENTE", y="VENTA_ANUAL", title="Annual Sales per Customer")
22
- st.plotly_chart(fig)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
customer_recommendation.py DELETED
@@ -1,24 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
-
4
- st.set_page_config(page_title="Customer Recommendations", page_icon=":chart_with_upwards_trend:")
5
-
6
- st.title("Customer Recommendations")
7
- st.markdown("""
8
- Get tailored recommendations for your customers based on their purchasing history.
9
- """)
10
-
11
- # Cargar los datos
12
- uploaded_file = st.file_uploader("Upload your CSV file", type="csv")
13
- if uploaded_file:
14
- df = pd.read_csv(uploaded_file)
15
- customer_id = st.selectbox("Select a Customer", df["CLIENTE"].unique())
16
-
17
- # Mostrar datos y recomendación
18
- st.write(f"### Purchase History for Customer {customer_id}")
19
- customer_data = df[df["CLIENTE"] == customer_id]
20
- st.write(customer_data)
21
-
22
- # Generar recomendaciones (placeholder)
23
- st.write(f"### Recommended Products for Customer {customer_id}")
24
- st.write("Product A, Product B, Product C")