Spaces:
Runtime error
Runtime error
Update plot colors and labels
Browse files- pages/clustering.py +11 -1
- recommender_system.py +3 -2
pages/clustering.py
CHANGED
@@ -235,7 +235,12 @@ def plot_rfm_distribution(df_rfm: pd.DataFrame, cluster_info: Dict[str, List[int
|
|
235 |
"""Plots 3 histograms for the RFM metrics."""
|
236 |
|
237 |
for x in ("Revenue", "Frequency", "Recency"):
|
238 |
-
fig = px.histogram(
|
|
|
|
|
|
|
|
|
|
|
239 |
# Get the max value in the cluster info. The cluster info is a list of min - max
|
240 |
# values per cluster.
|
241 |
values = cluster_info[f"{x}_cluster"]
|
@@ -247,6 +252,11 @@ def plot_rfm_distribution(df_rfm: pd.DataFrame, cluster_info: Dict[str, List[int
|
|
247 |
line_dash="dot",
|
248 |
annotation=dict(textangle=90, font_color="red"),
|
249 |
)
|
|
|
|
|
|
|
|
|
|
|
250 |
st.plotly_chart(fig)
|
251 |
|
252 |
|
|
|
235 |
"""Plots 3 histograms for the RFM metrics."""
|
236 |
|
237 |
for x in ("Revenue", "Frequency", "Recency"):
|
238 |
+
fig = px.histogram(
|
239 |
+
df_rfm,
|
240 |
+
x=x,
|
241 |
+
log_y=True,
|
242 |
+
title=f"{x} metric",
|
243 |
+
)
|
244 |
# Get the max value in the cluster info. The cluster info is a list of min - max
|
245 |
# values per cluster.
|
246 |
values = cluster_info[f"{x}_cluster"]
|
|
|
252 |
line_dash="dot",
|
253 |
annotation=dict(textangle=90, font_color="red"),
|
254 |
)
|
255 |
+
|
256 |
+
fig.update_layout(
|
257 |
+
yaxis_title="Count (log scale)",
|
258 |
+
)
|
259 |
+
|
260 |
st.plotly_chart(fig)
|
261 |
|
262 |
|
recommender_system.py
CHANGED
@@ -254,7 +254,7 @@ def display_recommendation_plots(
|
|
254 |
opacity=0.8,
|
255 |
name="Similar bought by user",
|
256 |
marker_symbol="square-open",
|
257 |
-
marker_color="
|
258 |
marker_size=10,
|
259 |
hovertext=contribution_description.loc[contributions].values.squeeze(),
|
260 |
)
|
@@ -268,6 +268,7 @@ def display_recommendation_plots(
|
|
268 |
name="Product bought by similar users",
|
269 |
opacity=0.7,
|
270 |
marker_symbol="circle-open",
|
|
|
271 |
marker_size=10,
|
272 |
hovertext=items_other_description.loc[
|
273 |
bought_by_similar_users
|
@@ -281,7 +282,7 @@ def display_recommendation_plots(
|
|
281 |
y=suggestion_dec[:, 1],
|
282 |
mode="markers",
|
283 |
name="Suggested",
|
284 |
-
marker_color="
|
285 |
marker_symbol="star",
|
286 |
marker_size=10,
|
287 |
hovertext=suggestion_description.loc[suggestions].values.squeeze(),
|
|
|
254 |
opacity=0.8,
|
255 |
name="Similar bought by user",
|
256 |
marker_symbol="square-open",
|
257 |
+
marker_color="#010CFA",
|
258 |
marker_size=10,
|
259 |
hovertext=contribution_description.loc[contributions].values.squeeze(),
|
260 |
)
|
|
|
268 |
name="Product bought by similar users",
|
269 |
opacity=0.7,
|
270 |
marker_symbol="circle-open",
|
271 |
+
marker_color="#FA5F19",
|
272 |
marker_size=10,
|
273 |
hovertext=items_other_description.loc[
|
274 |
bought_by_similar_users
|
|
|
282 |
y=suggestion_dec[:, 1],
|
283 |
mode="markers",
|
284 |
name="Suggested",
|
285 |
+
marker_color="#1A9626",
|
286 |
marker_symbol="star",
|
287 |
marker_size=10,
|
288 |
hovertext=suggestion_description.loc[suggestions].values.squeeze(),
|