Spaces:
Running
Running
Upload eda.py
Browse files
eda.py
CHANGED
@@ -17,6 +17,7 @@ def run():
|
|
17 |
# Checking Central Tendency Numerical Data
|
18 |
df_describe = df.describe().T
|
19 |
df_describe = df_describe.apply(lambda x: x.map('{:.2f}'.format))
|
|
|
20 |
df_describe
|
21 |
|
22 |
# Showing Explanation
|
@@ -53,7 +54,7 @@ def run():
|
|
53 |
|
54 |
# Show the plot
|
55 |
plt.tight_layout()
|
56 |
-
|
57 |
# Showing Explanation
|
58 |
with st.expander('Explanation'):
|
59 |
st.caption('From the visualization, we can see that a large number of customers Not Churn 33881 (52.6%) and those who will be Churn 30493 (47.4%). In my opinion, this number is a pretty bad number for the company, because customers who Not Churn and those who do Churn are only a very small difference so it is necessary to improve both technically and non-technically.')
|
@@ -66,7 +67,7 @@ def run():
|
|
66 |
plt.title('Age Distribution by Customer Churn')
|
67 |
plt.xlabel('Age')
|
68 |
plt.ylabel('Frequency')
|
69 |
-
|
70 |
|
71 |
# Showing Explanation
|
72 |
with st.expander('Explanation'):
|
@@ -92,7 +93,7 @@ def run():
|
|
92 |
shadow=True, startangle=140)
|
93 |
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
|
94 |
plt.title('Churn Rate by Gender')
|
95 |
-
|
96 |
# Showing Explanation
|
97 |
with st.expander('Explanation'):
|
98 |
st.caption('We can see from the results of the pierchart visualization above, where the possibility of churn rates in the female gender tends to be more than men, where women 58.8% and men 41.2% of the total data, from these results we can later make improvements to maintain female gender customers.')
|
@@ -114,7 +115,7 @@ def run():
|
|
114 |
for i, rate in enumerate(churn_rate_by_subscription_normalized):
|
115 |
plt.text(i, rate, f'{rate:.4f}', ha='center', va='bottom')
|
116 |
|
117 |
-
|
118 |
# Showing Explanation
|
119 |
with st.expander('Explanation'):
|
120 |
st.caption('For Further Analysis Since churn rates are similar, it suggests that factors other than subscription type may have a more significant impact on churn. And for Business Strategy A churn rate approaching 50% warrants a detailed examination of customer service practices, product quality, pricing strategy, and competitive pressures. Strategies need to be implemented to enhance customer satisfaction and loyalty across all subscription types.')
|
@@ -138,7 +139,7 @@ def run():
|
|
138 |
# Add labels on each bar
|
139 |
for i, rate in enumerate(churn_rate_by_contract_length_normalized):
|
140 |
plt.text(i, rate, f'{rate:.4f}', ha='center', va='bottom')
|
141 |
-
|
142 |
|
143 |
# Showing Explanation
|
144 |
with st.expander('Explanation'):
|
@@ -154,7 +155,7 @@ def run():
|
|
154 |
plt.title('Total Spend Distribution by Customer Churn')
|
155 |
plt.xlabel('Total Spend')
|
156 |
plt.ylabel('Frequency')
|
157 |
-
|
158 |
|
159 |
|
160 |
# Showing Explanation
|
|
|
17 |
# Checking Central Tendency Numerical Data
|
18 |
df_describe = df.describe().T
|
19 |
df_describe = df_describe.apply(lambda x: x.map('{:.2f}'.format))
|
20 |
+
df_describe = pd.DataFrame(df_describe)
|
21 |
df_describe
|
22 |
|
23 |
# Showing Explanation
|
|
|
54 |
|
55 |
# Show the plot
|
56 |
plt.tight_layout()
|
57 |
+
st.pyplot()
|
58 |
# Showing Explanation
|
59 |
with st.expander('Explanation'):
|
60 |
st.caption('From the visualization, we can see that a large number of customers Not Churn 33881 (52.6%) and those who will be Churn 30493 (47.4%). In my opinion, this number is a pretty bad number for the company, because customers who Not Churn and those who do Churn are only a very small difference so it is necessary to improve both technically and non-technically.')
|
|
|
67 |
plt.title('Age Distribution by Customer Churn')
|
68 |
plt.xlabel('Age')
|
69 |
plt.ylabel('Frequency')
|
70 |
+
st.pyplot()
|
71 |
|
72 |
# Showing Explanation
|
73 |
with st.expander('Explanation'):
|
|
|
93 |
shadow=True, startangle=140)
|
94 |
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
|
95 |
plt.title('Churn Rate by Gender')
|
96 |
+
st.pyplot()
|
97 |
# Showing Explanation
|
98 |
with st.expander('Explanation'):
|
99 |
st.caption('We can see from the results of the pierchart visualization above, where the possibility of churn rates in the female gender tends to be more than men, where women 58.8% and men 41.2% of the total data, from these results we can later make improvements to maintain female gender customers.')
|
|
|
115 |
for i, rate in enumerate(churn_rate_by_subscription_normalized):
|
116 |
plt.text(i, rate, f'{rate:.4f}', ha='center', va='bottom')
|
117 |
|
118 |
+
st.pyplot()
|
119 |
# Showing Explanation
|
120 |
with st.expander('Explanation'):
|
121 |
st.caption('For Further Analysis Since churn rates are similar, it suggests that factors other than subscription type may have a more significant impact on churn. And for Business Strategy A churn rate approaching 50% warrants a detailed examination of customer service practices, product quality, pricing strategy, and competitive pressures. Strategies need to be implemented to enhance customer satisfaction and loyalty across all subscription types.')
|
|
|
139 |
# Add labels on each bar
|
140 |
for i, rate in enumerate(churn_rate_by_contract_length_normalized):
|
141 |
plt.text(i, rate, f'{rate:.4f}', ha='center', va='bottom')
|
142 |
+
st.pyplot()
|
143 |
|
144 |
# Showing Explanation
|
145 |
with st.expander('Explanation'):
|
|
|
155 |
plt.title('Total Spend Distribution by Customer Churn')
|
156 |
plt.xlabel('Total Spend')
|
157 |
plt.ylabel('Frequency')
|
158 |
+
st.pyplot()
|
159 |
|
160 |
|
161 |
# Showing Explanation
|