Code
Code
data = pd.read_csv('Banking_data.csv')
sns.histplot(data['age'], kde=True)
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.show()
sns.countplot(y='job', data=data)
plt.xlabel('Count')
plt.ylabel('Job Type')
plt.show()
sns.countplot(x='marital', data=data)
plt.xlabel('Marital Status')
plt.ylabel('Count')
plt.show()
sns.countplot(x='education', data=data)
plt.xlabel('Education Level')
plt.ylabel('Count')
plt.show()
sns.countplot(x='default', data=data)
plt.title('Credit in Default')
plt.xlabel('Default')
plt.ylabel('Count')
plt.show()
sns.histplot(data['balance'], kde=True)
plt.xlabel('Balance')
plt.ylabel('Frequency')
plt.show()
sns.countplot(x='housing', data=data)
plt.xlabel('Housing Loan')
plt.ylabel('Count')
plt.show()
plt.figure(figsize=(7, 5))
sns.countplot(x='loan', data=data)
plt.xlabel('Personal Loan')
plt.ylabel('Count')
plt.show()
# 9. Communication types used during the campaign
plt.figure(figsize=(7, 5))
sns.countplot(x='contact', data=data)
plt.xlabel('Type of Communication')
plt.ylabel('Count')
plt.show()
plt.figure(figsize=(10, 6))
plt.ylabel('Frequency')
plt.show()
plt.figure(figsize=(10, 6))
order_months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
plt.xlabel('Month')
plt.ylabel('Frequency')
plt.show()
plt.figure(figsize=(10, 6))
plt.xlabel('Duration (seconds)')
plt.ylabel('Frequency')
plt.show()
# 13. Number of contacts performed during the campaign for each client
plt.figure(figsize=(10, 6))
sns.countplot(x='campaign', data=data)
plt.xlabel('Number of Contacts')
plt.ylabel('Frequency')
plt.xticks(rotation=90)
plt.show()
# 14. Distribution of the number of days passed since last contact from a previous campaign
plt.figure(figsize=(10, 6))
# Filtering out clients who were not contacted before (pdays = -1)
plt.xlabel('Days')
plt.ylabel('Frequency')
plt.show()
# 15. Number of contacts performed before the current campaign for each client
plt.figure(figsize=(10, 6))
sns.countplot(x='previous', data=data)
plt.ylabel('Frequency')
plt.xticks(rotation=90)
plt.show()
# 16. Outcomes of the previous marketing campaigns
plt.figure(figsize=(7, 5))
sns.countplot(x='poutcome', data=data)
plt.xlabel('Outcome')
plt.ylabel('Count')
plt.show()
# 17. Distribution of clients who subscribed to a term deposit vs. those who did not
plt.figure(figsize=(7, 5))
sns.countplot(x='y', data=data)
plt.xlabel('Subscribed')
plt.ylabel('Count')
plt.show()
# 18. Correlations between different attributes and the likelihood of subscribing to a term
deposit
plt.figure(figsize=(15, 10))
plt.show()
plt.figure(figsize=(2, 8))
sns.heatmap(data_numeric.corr()[['y_yes']].sort_values(by='y_yes', ascending=False),
annot=True, cmap='coolwarm