change
Browse files
app.py
CHANGED
|
@@ -96,24 +96,21 @@ with tab2:
|
|
| 96 |
|
| 97 |
# Visualizations for Item Purchased distribution
|
| 98 |
fig, ax = plt.subplots(figsize=(10, 5))
|
| 99 |
-
sns.countplot(y=df['Item Purchased'], order=df['Item Purchased'].value_counts().index, palette='viridis', ax=ax)
|
| 100 |
ax.set_title("Overall Item Purchase Distribution")
|
| 101 |
ax.set_xlabel("Count")
|
| 102 |
ax.set_ylabel("Item Purchased")
|
| 103 |
st.pyplot(fig)
|
| 104 |
|
| 105 |
-
#
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
fig, ax = plt.subplots(figsize=(10, 6))
|
| 115 |
-
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt='.2f', ax=ax)
|
| 116 |
-
st.pyplot(fig)
|
| 117 |
|
| 118 |
with tab3:
|
| 119 |
st.subheader("Enter Customer Details")
|
|
@@ -149,4 +146,4 @@ with tab3:
|
|
| 149 |
# Display average purchase amount trend
|
| 150 |
avg_purchase_amount = cluster_data.groupby('Item Purchased')['Purchase Amount (USD)'].mean()
|
| 151 |
st.write("### Average Purchase Amount for Items in This Cluster:")
|
| 152 |
-
st.write(avg_purchase_amount)
|
|
|
|
| 96 |
|
| 97 |
# Visualizations for Item Purchased distribution
|
| 98 |
fig, ax = plt.subplots(figsize=(10, 5))
|
| 99 |
+
sns.countplot(y=df['Item Purchased'], order=df['Item Purchased'].value_counts().index, hue=df['Item Purchased'], palette='viridis', ax=ax)
|
| 100 |
ax.set_title("Overall Item Purchase Distribution")
|
| 101 |
ax.set_xlabel("Count")
|
| 102 |
ax.set_ylabel("Item Purchased")
|
| 103 |
st.pyplot(fig)
|
| 104 |
|
| 105 |
+
# Separate Correlation Matrices for Each Label
|
| 106 |
+
labels = ['Gender', 'Frequency of Purchases', 'Item Purchased']
|
| 107 |
+
for label in labels:
|
| 108 |
+
df[f'{label}_Numeric'] = LabelEncoder().fit_transform(df[label])
|
| 109 |
+
correlation_matrix = df[[f'{label}_Numeric', 'Purchase Amount (USD)', 'Previous Purchases']].corr()
|
| 110 |
+
fig, ax = plt.subplots(figsize=(10, 6))
|
| 111 |
+
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt='.2f', ax=ax)
|
| 112 |
+
st.subheader(f"Feature Correlation Matrix for {label}")
|
| 113 |
+
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
with tab3:
|
| 116 |
st.subheader("Enter Customer Details")
|
|
|
|
| 146 |
# Display average purchase amount trend
|
| 147 |
avg_purchase_amount = cluster_data.groupby('Item Purchased')['Purchase Amount (USD)'].mean()
|
| 148 |
st.write("### Average Purchase Amount for Items in This Cluster:")
|
| 149 |
+
st.write(avg_purchase_amount)
|