Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
eb4cbbc
1
Parent(s):
8f0b3af
feat: updated location of files
Browse files
app.py
CHANGED
@@ -140,80 +140,83 @@ st.markdown("""
|
|
140 |
|
141 |
# Navigation menu
|
142 |
st.sidebar.title("DeepInsightz")
|
143 |
-
page = st.sidebar.selectbox("Select the tool you want to use", ["
|
144 |
|
145 |
if page == "Home":
|
146 |
st.title("Welcome to DeepInsightz")
|
147 |
st.markdown("""
|
148 |
### Data-driven Customer Clustering
|
149 |
-
|
150 |
""")
|
151 |
|
152 |
-
#
|
153 |
-
st.
|
154 |
-
st.write("""
|
155 |
-
- **Customers Analyzed**: 4,000
|
156 |
-
- **Suppliers Analyzed**: 400
|
157 |
-
- **Invoice Lines Processed**: 800,000
|
158 |
-
""")
|
159 |
-
|
160 |
-
st.info("The data was cleaned, duplicate entries were removed, and we standardized product codes and descriptions. We excluded customers with less than 12 purchases or total sales below €1,200 in 2024.")
|
161 |
-
|
162 |
-
# 2. Customer Distribution
|
163 |
-
st.subheader("Customer Distribution by Purchase Volume")
|
164 |
|
165 |
-
#
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
df_customers = pd.DataFrame(data)
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
177 |
|
178 |
-
#
|
179 |
-
|
180 |
-
|
|
|
|
|
181 |
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
183 |
np.random.seed(42)
|
184 |
df_cluster = pd.DataFrame({
|
185 |
-
'Cluster': np.random.choice(['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'
|
186 |
'x': np.random.randn(100),
|
187 |
'y': np.random.randn(100),
|
188 |
'z': np.random.randn(100)
|
189 |
})
|
|
|
|
|
190 |
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
193 |
|
194 |
-
|
195 |
-
st.subheader("Product Group vs Manufacturer Distribution")
|
196 |
-
st.write("See how different manufacturers align with various product groups purchased by customers.")
|
197 |
-
|
198 |
-
# Example data for product groups vs manufacturers (replace with real data)
|
199 |
-
prod_data = {
|
200 |
-
'Product Group': ['Group A', 'Group B', 'Group C', 'Group D', 'Group E'],
|
201 |
-
'Manufacturer 1': [25, 40, 35, 30, 50],
|
202 |
-
'Manufacturer 2': [30, 35, 30, 45, 40],
|
203 |
-
'Manufacturer 3': [35, 25, 40, 25, 35]
|
204 |
-
}
|
205 |
-
df_prod_manu = pd.DataFrame(prod_data)
|
206 |
-
|
207 |
-
fig_prod_manu = px.bar(df_prod_manu, x='Product Group', y=['Manufacturer 1', 'Manufacturer 2', 'Manufacturer 3'],
|
208 |
-
title="Manufacturer Distribution Across Product Groups")
|
209 |
-
st.plotly_chart(fig_prod_manu)
|
210 |
|
211 |
-
#
|
212 |
-
st.markdown(""
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
""")
|
216 |
|
|
|
|
|
|
|
|
|
|
|
217 |
# Customer Analysis Page
|
218 |
elif page == "Customer Analysis":
|
219 |
st.title("Customer Analysis")
|
|
|
140 |
|
141 |
# Navigation menu
|
142 |
st.sidebar.title("DeepInsightz")
|
143 |
+
page = st.sidebar.selectbox("Select the tool you want to use", ["Summary", "Customer Analysis", "Articles Recommendations"])
|
144 |
|
145 |
if page == "Home":
|
146 |
st.title("Welcome to DeepInsightz")
|
147 |
st.markdown("""
|
148 |
### Data-driven Customer Clustering
|
149 |
+
We analyzed thousands of customers and suppliers to help businesses make smarter sales decisions.
|
150 |
""")
|
151 |
|
152 |
+
# Create layout with three columns: left (red), middle (white), and right (blue)
|
153 |
+
st.markdown('<div class="container">', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
+
# Left Column (Red): Metrics and Donut Charts
|
156 |
+
st.markdown('<div class="col-red">', unsafe_allow_html=True)
|
157 |
+
|
158 |
+
st.markdown('<div class="custom-box">', unsafe_allow_html=True)
|
159 |
+
st.markdown("**Texas**<br><span style='font-size:28px;'>29.0 M</span><br><span style='color:#00FF00;'>+367 K</span>", unsafe_allow_html=True)
|
160 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
161 |
|
162 |
+
st.markdown('<div class="custom-box">', unsafe_allow_html=True)
|
163 |
+
st.markdown("**New York**<br><span style='font-size:28px;'>19.5 M</span><br><span style='color:#FF0000;'>-77 K</span>", unsafe_allow_html=True)
|
164 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
165 |
+
|
166 |
+
st.markdown('<div class="custom-box">States Migration</div>', unsafe_allow_html=True)
|
167 |
|
168 |
+
# Donut chart placeholder
|
169 |
+
donut_fig = px.pie(values=[70, 30], names=['Inbound', 'Outbound'], hole=0.7)
|
170 |
+
donut_fig.update_traces(textinfo='percent+label')
|
171 |
+
donut_fig.update_layout(showlegend=False, margin=dict(t=0, b=0, l=0, r=0))
|
172 |
+
st.plotly_chart(donut_fig, use_container_width=True)
|
173 |
|
174 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
175 |
+
|
176 |
+
# Middle Column (White): 3D Cluster Model and Bar Chart
|
177 |
+
st.markdown('<div class="col-white">', unsafe_allow_html=True)
|
178 |
+
|
179 |
+
st.subheader("3D Customer Clusters")
|
180 |
np.random.seed(42)
|
181 |
df_cluster = pd.DataFrame({
|
182 |
+
'Cluster': np.random.choice(['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'], 100),
|
183 |
'x': np.random.randn(100),
|
184 |
'y': np.random.randn(100),
|
185 |
'z': np.random.randn(100)
|
186 |
})
|
187 |
+
fig_cluster = px.scatter_3d(df_cluster, x='x', y='y', z='z', color='Cluster')
|
188 |
+
st.plotly_chart(fig_cluster, use_container_width=True)
|
189 |
|
190 |
+
st.subheader("Sales by Cluster")
|
191 |
+
sales_data = {'Cluster': ['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'],
|
192 |
+
'Sales': [400000, 600000, 500000, 300000]}
|
193 |
+
df_sales = pd.DataFrame(sales_data)
|
194 |
+
fig_sales = px.bar(df_sales, x='Cluster', y='Sales', title="Sales by Cluster")
|
195 |
+
st.plotly_chart(fig_sales, use_container_width=True)
|
196 |
|
197 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
# Right Column (Blue): Other Relevant Information
|
200 |
+
st.markdown('<div class="col-blue">', unsafe_allow_html=True)
|
201 |
+
|
202 |
+
st.subheader("Key Metrics Overview")
|
203 |
+
st.write("""
|
204 |
+
- **Customers Analyzed**: 4,000
|
205 |
+
- **Suppliers Analyzed**: 400
|
206 |
+
- **Invoice Lines Processed**: 800,000
|
207 |
+
""")
|
208 |
+
|
209 |
+
st.subheader("Data Preparation Summary")
|
210 |
+
st.write("""
|
211 |
+
- Cleaned and standardized product codes and descriptions.
|
212 |
+
- Excluded customers with fewer than 12 purchases or sales below €1,200.
|
213 |
""")
|
214 |
|
215 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
216 |
+
|
217 |
+
# Close the container div
|
218 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
219 |
+
|
220 |
# Customer Analysis Page
|
221 |
elif page == "Customer Analysis":
|
222 |
st.title("Customer Analysis")
|