GMARTINEZMILLA commited on
Commit
fe7656a
1 Parent(s): 714d8c4

feat: updated location of files

Browse files
Files changed (1) hide show
  1. app.py +65 -64
app.py CHANGED
@@ -14,6 +14,47 @@ from utils import recomienda_tfid
14
  # Page configuration
15
  st.set_page_config(page_title="DeepInsightz", page_icon=":bar_chart:", layout="wide")
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # Load CSV files at the top
18
  df = pd.read_csv("df_clean.csv")
19
  nombres_proveedores = pd.read_csv("nombres_proveedores.csv", sep=';')
@@ -94,53 +135,12 @@ def radar_chart(categories, values, amounts, title):
94
 
95
  return fig
96
 
97
- # Custom CSS for dark theme and styling
98
- st.markdown("""
99
- <style>
100
- body {
101
- background-color: #121212;
102
- color: white;
103
- }
104
- .stMetric {
105
- background-color: #2E2E2E;
106
- border-radius: 10px;
107
- padding: 10px;
108
- }
109
- .stMetric > div {
110
- color: white;
111
- }
112
- .stMetric > div > div {
113
- color: white !important;
114
- }
115
- .custom-title {
116
- color: white;
117
- font-size: 36px;
118
- margin-bottom: 20px;
119
- }
120
- .custom-metric-box {
121
- background-color: #2E2E2E;
122
- border-radius: 10px;
123
- padding: 20px;
124
- margin-bottom: 10px;
125
- text-align: center;
126
- color: white;
127
- }
128
- .up-arrow {
129
- color: #00FF00; /* Green */
130
- }
131
- .down-arrow {
132
- color: #FF0000; /* Red */
133
- }
134
- .container {
135
- display: flex;
136
- justify-content: space-between;
137
- }
138
- </style>
139
- """, unsafe_allow_html=True)
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 == "Summary":
146
  st.title("Welcome to DeepInsightz")
@@ -149,30 +149,29 @@ if page == "Summary":
149
  We analyzed thousands of customers and suppliers to help businesses make smarter sales decisions.
150
  """)
151
 
152
- # Create layout with three columns: left (col1), middle (col2), and right (col3)
153
- col1, col2, col3 = st.columns([1, 2, 1])
154
 
155
  # Left Column (Red): Metrics and Donut Charts
156
  with col1:
157
- st.markdown('<div class="custom-box">', unsafe_allow_html=True)
158
- 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)
159
- st.markdown('</div>', unsafe_allow_html=True)
160
 
161
- st.markdown('<div class="custom-box">', unsafe_allow_html=True)
162
- 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)
163
- st.markdown('</div>', unsafe_allow_html=True)
164
-
165
- st.markdown('<div class="custom-box">States Migration</div>', unsafe_allow_html=True)
166
-
167
- # Donut chart placeholder
168
  donut_fig = px.pie(values=[70, 30], names=['Inbound', 'Outbound'], hole=0.7)
169
  donut_fig.update_traces(textinfo='percent+label')
170
  donut_fig.update_layout(showlegend=False, margin=dict(t=0, b=0, l=0, r=0))
171
  st.plotly_chart(donut_fig, use_container_width=True)
172
 
 
173
  # Middle Column (White): 3D Cluster Model and Bar Chart
174
  with col2:
175
- st.subheader("3D Customer Clusters")
 
 
176
  np.random.seed(42)
177
  df_cluster = pd.DataFrame({
178
  'Cluster': np.random.choice(['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'], 100),
@@ -182,24 +181,26 @@ if page == "Summary":
182
  })
183
  fig_cluster = px.scatter_3d(df_cluster, x='x', y='y', z='z', color='Cluster')
184
  st.plotly_chart(fig_cluster, use_container_width=True)
185
-
186
- st.subheader("Sales by Cluster")
 
 
187
  sales_data = {'Cluster': ['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'],
188
- 'Sales': [400000, 600000, 500000, 300000]}
189
  df_sales = pd.DataFrame(sales_data)
190
  fig_sales = px.bar(df_sales, x='Cluster', y='Sales', title="Sales by Cluster")
191
  st.plotly_chart(fig_sales, use_container_width=True)
192
 
193
  # Right Column (Blue): Key Metrics Overview and Data Preparation Summary
194
  with col3:
195
- st.subheader("Key Metrics Overview")
196
  st.write("""
197
  - **Customers Analyzed**: 4,000
198
  - **Suppliers Analyzed**: 400
199
  - **Invoice Lines Processed**: 800,000
200
  """)
201
 
202
- st.subheader("Data Preparation Summary")
203
  st.write("""
204
  - Cleaned and standardized product codes and descriptions.
205
  - Excluded customers with fewer than 12 purchases or sales below €1,200.
 
14
  # Page configuration
15
  st.set_page_config(page_title="DeepInsightz", page_icon=":bar_chart:", layout="wide")
16
 
17
+ # Custom CSS for styling similar to the inspiration
18
+ st.markdown("""
19
+ <style>
20
+ [data-testid="block-container"] {
21
+ padding-left: 2rem;
22
+ padding-right: 2rem;
23
+ padding-top: 1rem;
24
+ padding-bottom: 0rem;
25
+ margin-bottom: -7rem;
26
+ }
27
+ [data-testid="stVerticalBlock"] {
28
+ padding-left: 0rem;
29
+ padding-right: 0rem;
30
+ }
31
+ [data-testid="stMetric"] {
32
+ background-color: #393939;
33
+ text-align: center;
34
+ padding: 15px 0;
35
+ }
36
+ [data-testid="stMetricLabel"] {
37
+ display: flex;
38
+ justify-content: center;
39
+ align-items: center;
40
+ }
41
+ [data-testid="stMetricDeltaIcon-Up"] {
42
+ position: relative;
43
+ left: 38%;
44
+ -webkit-transform: translateX(-50%);
45
+ -ms-transform: translateX(-50%);
46
+ transform: translateX(-50%);
47
+ }
48
+ [data-testid="stMetricDeltaIcon-Down"] {
49
+ position: relative;
50
+ left: 38%;
51
+ -webkit-transform: translateX(-50%);
52
+ -ms-transform: translateX(-50%);
53
+ transform: translateX(-50%);
54
+ }
55
+ </style>
56
+ """, unsafe_allow_html=True)
57
+
58
  # Load CSV files at the top
59
  df = pd.read_csv("df_clean.csv")
60
  nombres_proveedores = pd.read_csv("nombres_proveedores.csv", sep=';')
 
135
 
136
  return fig
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  # Navigation menu
139
+ with st.sidebar:
140
+ st.sidebar.title("DeepInsightz")
141
+ page = st.sidebar.selectbox("Select the tool you want to use", ["Summary", "Customer Analysis", "Articles Recommendations"])
142
+
143
+
144
 
145
  if page == "Summary":
146
  st.title("Welcome to DeepInsightz")
 
149
  We analyzed thousands of customers and suppliers to help businesses make smarter sales decisions.
150
  """)
151
 
152
+ # Create layout with three columns
153
+ col1, col2, col3 = st.columns((1.5, 4.5, 2), gap='medium')
154
 
155
  # Left Column (Red): Metrics and Donut Charts
156
  with col1:
157
+ st.markdown('#### Key Metrics')
158
+ st.metric(label="Texas", value="29.0 M", delta="+367 K", delta_color="normal")
159
+ st.metric(label="New York", value="19.5 M", delta="-77 K", delta_color="inverse")
160
 
161
+ st.markdown('#### States Migration')
162
+
163
+ # Create a placeholder for your own donut charts with Plotly
 
 
 
 
164
  donut_fig = px.pie(values=[70, 30], names=['Inbound', 'Outbound'], hole=0.7)
165
  donut_fig.update_traces(textinfo='percent+label')
166
  donut_fig.update_layout(showlegend=False, margin=dict(t=0, b=0, l=0, r=0))
167
  st.plotly_chart(donut_fig, use_container_width=True)
168
 
169
+
170
  # Middle Column (White): 3D Cluster Model and Bar Chart
171
  with col2:
172
+ st.markdown('#### 3D Customer Clusters')
173
+
174
+ # Replace with your own customer cluster visualization
175
  np.random.seed(42)
176
  df_cluster = pd.DataFrame({
177
  'Cluster': np.random.choice(['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'], 100),
 
181
  })
182
  fig_cluster = px.scatter_3d(df_cluster, x='x', y='y', z='z', color='Cluster')
183
  st.plotly_chart(fig_cluster, use_container_width=True)
184
+
185
+ st.markdown('#### Sales by Cluster')
186
+
187
+ # Replace with your own sales data
188
  sales_data = {'Cluster': ['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4'],
189
+ 'Sales': [400000, 600000, 500000, 300000]}
190
  df_sales = pd.DataFrame(sales_data)
191
  fig_sales = px.bar(df_sales, x='Cluster', y='Sales', title="Sales by Cluster")
192
  st.plotly_chart(fig_sales, use_container_width=True)
193
 
194
  # Right Column (Blue): Key Metrics Overview and Data Preparation Summary
195
  with col3:
196
+ st.markdown('#### Key Metrics Overview')
197
  st.write("""
198
  - **Customers Analyzed**: 4,000
199
  - **Suppliers Analyzed**: 400
200
  - **Invoice Lines Processed**: 800,000
201
  """)
202
 
203
+ st.markdown('#### Data Preparation Summary')
204
  st.write("""
205
  - Cleaned and standardized product codes and descriptions.
206
  - Excluded customers with fewer than 12 purchases or sales below €1,200.