<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <a href="https
Step1:  2. Check the types of the variable that you take into account along the way.
Step2:  3. Draw the histogram of total day minutes and total intl calls and interpret the result.
Step3:  The above histogram shows us the frequency of the variable "Total day minutes" in the telecom_churn dataset. The histogram reads as follows
Step4:  The above histogram shows us the frequency of the variable "Total intl calls" in the telecom_churn dataset. The histogram reads as follows
Step5:  Density plots are, by definition, smoothed-out versions of the respective historgrams. We get roughly the same information from the density plots as we do from the histograms, which is that "Total day minutes" is normally distributed, whereas "Total intl calls" has a significant right skew.
5. Draw the distplot, boxplot, and violin plot of total intl calls and interpret the result
Step6:  A box plot helps us to understand the extent to which data spreads out. We see from the above box plot of "Total intl calls" that
Step7:  The above violin plot of "Total intl calls" includes a rotated kernel density plot on each side. It shows us the full distribution of the data, and confirms that the data are most dense between 2.5 and 5.0 calls.
Step8:  The above distplot of "Total intl calls" shows us similar information as the violin plot, which is that the data are most dense between 2.5 and 5.0 calls.
6. Using churn and customer service calls variables, draw the count plot and interpret the result*
Step9:  Most customers do not churn.
Step10:  The most frequent value for 'Customer service calls' is 1.0, followed by 2, 0, 3, 4, 5, 6, and 7. It's interesting that a significant number of customers don't seem to make customer service calls, since 0 is the third most frequent number of calls.
7. Identify the correlation between the variables using pandas and seaborn libraries
Step11:  Total day minutes is strongly correlated with Total day charge.
Total eve minutes is strongly correlated with Total eve charge.
Total night minutes is strongly correlated with Total night charge.
Total intl minutes is strongly correlated with Total intl charge.
8. Detect the relationship between total day minutes and total night minutes variable using a visualization technique of your choice
Step12:  There does not appear to be a linear relationship between Total day minutes and Total night minutes.
9. Try to understand the relationship between total day minutes and two categorical variables, namely churn and customer service calls using catplot.
Hint
Step13:  From the above catplot, we see that the median number of total day minutes for customers who have churned is higher than the median number of total day minutes for customers who have not churned, for customer service calls under 4. Starting at 4 calls, the trend reverses and the median number of total day minutes for customers who have churned is lower than the median number of total day minutes for customers who have not churned. 
A clear relationship between total day minutes and churn is difficult to detect here.
10. Using subplot function, draw histogram of all numerical variables
<ASSISTANT_TASK:>
Python Code:
#codes here
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("https://raw.githubusercontent.com/Yorko/mlcourse.ai/master/data/telecom_churn.csv")
df.head()
Explanation: <a href="https://colab.research.google.com/github/gaargly/gaargly.github.io/blob/master/2021_06_30_Lira_3rdAssignment_Tyler.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
In this assignment, we will telekom_churn dataset to explore the data using visualization techniques. Please note that for every visualization you apply, you need to interpret what you have found in order to get full credit.
1. Import the data first
End of explanation
#codes here
df.dtypes
Explanation: 2. Check the types of the variable that you take into account along the way.
End of explanation
#codes here
plt.figure(figsize=(10,5))
plt.hist(df['Total day minutes'])
plt.xlabel('Total Day Minutes')
plt.ylabel('Frequency')
plt.title('Histogram of Total Day Minutes')
plt.show()
Explanation: 3. Draw the histogram of total day minutes and total intl calls and interpret the result.
End of explanation
#codes here
plt.figure(figsize=(10,5))
plt.hist(df['Total intl calls'])
plt.xlabel('Total Intl Calls')
plt.ylabel('Frequency')
plt.title('Histogram of Total Intl Calls')
plt.show()
Explanation: The above histogram shows us the frequency of the variable "Total day minutes" in the telecom_churn dataset. The histogram reads as follows:
The data appear to be approximately normally distributed.
The most frequent interval gathers around total day minutes of 200.
The next frequent interval gathers around total day minutes of 150.
The data range from 0 to 350 minutes, with a mean between 150 and 200 minutes (at around 175 minutes).
End of explanation
#codes here
from scipy.stats import kde
data = df['Total day minutes']
density = kde.gaussian_kde(data)
x = np.linspace(0,350,20)
y = density(x)
plt.plot(x,y)
plt.title("Density Plot of Total Day Minutes")
plt.show()
#codes here
data = df['Total intl calls']
density = kde.gaussian_kde(data)
x = np.linspace(0,20,300)
y = density(x)
plt.plot(x,y)
plt.title("Density Plot of the Total Intl Calls")
plt.show()
Explanation: The above histogram shows us the frequency of the variable "Total intl calls" in the telecom_churn dataset. The histogram reads as follows:
The data have a right skew.
The most frequent interval gathers around total intl calls of 2.5.
The next frequent interval gathers around total day calls of 5.0.
A very small proportion of accounts had more than 10.0 calls in this dataset.
4. This time draw the density plot of the same variable and discuss the difference between these two plots
End of explanation
# Boxplot
plt.figure(figsize=(10,5))
plt.boxplot(df['Total intl calls'])
plt.ylabel('Total Intl Calls')
plt.title('Boxplot of Total Intl Calls')
plt.xticks([])
plt.show()
Explanation: Density plots are, by definition, smoothed-out versions of the respective historgrams. We get roughly the same information from the density plots as we do from the histograms, which is that "Total day minutes" is normally distributed, whereas "Total intl calls" has a significant right skew.
5. Draw the distplot, boxplot, and violin plot of total intl calls and interpret the result
End of explanation
# Violin Plot
plt.figure(figsize=(10,5))
plt.violinplot(df['Total intl calls'])
plt.xlabel('Probability')
plt.ylabel('Total Intl Calls')
plt.title('Violin plot of Total Intl Calls')
plt.show()
Explanation: A box plot helps us to understand the extent to which data spreads out. We see from the above box plot of "Total intl calls" that:
Minimum: The smallest value excluding any outliers is 0.0
First quartile (25th Percentile): The middle value between the smallest number (not the minimum) and the median of the dataset is a little over 2.5
Median of the data: The middle value of the dataset is around 3.5
Third quartile: The middle value between the largest number and the median of the dataset is around 6.0
Maximum: The biggest value excluding any outliers is 10.0
There are 10 outliers with values bigger than 10.0
End of explanation
# Distplot
sns.set(rc={"figure.figsize": (8, 4)}); np.random.seed(0)
x = df['Total intl calls']
ax = sns.distplot(x)
plt.show()
Explanation: The above violin plot of "Total intl calls" includes a rotated kernel density plot on each side. It shows us the full distribution of the data, and confirms that the data are most dense between 2.5 and 5.0 calls.
End of explanation
#codes here
p = sns.countplot(data=df, x = 'Churn')
Explanation: The above distplot of "Total intl calls" shows us similar information as the violin plot, which is that the data are most dense between 2.5 and 5.0 calls.
6. Using churn and customer service calls variables, draw the count plot and interpret the result*
End of explanation
#codes here
p = sns.countplot(data=df, x = 'Customer service calls')
Explanation: Most customers do not churn.
End of explanation
#codes here
sns.heatmap(df.corr())
plt.show()
Explanation: The most frequent value for 'Customer service calls' is 1.0, followed by 2, 0, 3, 4, 5, 6, and 7. It's interesting that a significant number of customers don't seem to make customer service calls, since 0 is the third most frequent number of calls.
7. Identify the correlation between the variables using pandas and seaborn libraries
End of explanation
#codes here
plt.figure(figsize=(10,10))
plt.subplot(2,1,1)
plt.scatter(df['Total day minutes'],df['Total night minutes'])
plt.xlabel('Total day minutes calls')
plt.ylabel('Total night minutes')
plt.title('Total day minutes vs Total night minutes')
plt.show()
Explanation: Total day minutes is strongly correlated with Total day charge.
Total eve minutes is strongly correlated with Total eve charge.
Total night minutes is strongly correlated with Total night charge.
Total intl minutes is strongly correlated with Total intl charge.
8. Detect the relationship between total day minutes and total night minutes variable using a visualization technique of your choice
End of explanation
#codes here
sns.catplot(
    x="Churn",
    y="Total day minutes",
    col="Customer service calls",
    data=df[df["Customer service calls"] < 8],
    kind="box",
    col_wrap=4,
    height=3,
    aspect=0.8,
);
Explanation: There does not appear to be a linear relationship between Total day minutes and Total night minutes.
9. Try to understand the relationship between total day minutes and two categorical variables, namely churn and customer service calls using catplot.
Hint: try different values of customer service calls
End of explanation
#codes here
fig, axs = plt.subplots(7, 2, figsize=(7, 7))
sns.histplot(data=df, x="Number vmail messages", kde=True, color="violet", ax=axs[0, 0])
sns.histplot(data=df, x="Total day minutes", kde=True, color="indigo", ax=axs[0, 1])
sns.histplot(data=df, x="Total day calls", kde=True, color="blue", ax=axs[1, 0])
sns.histplot(data=df, x="Total day charge", kde=True, color="green", ax=axs[1, 1])
sns.histplot(data=df, x="Total eve minutes", kde=True, color="yellow", ax=axs[2, 0])
sns.histplot(data=df, x="Total eve calls", kde=True, color="orange", ax=axs[2, 1])
sns.histplot(data=df, x="Total eve charge", kde=True, color="red", ax=axs[3, 0])
sns.histplot(data=df, x="Total night minutes", kde=True, color="lightblue", ax=axs[3, 1])
sns.histplot(data=df, x="Total night calls", kde=True, color="black", ax=axs[4, 0])
sns.histplot(data=df, x="Total night charge", kde=True, color="purple", ax=axs[4, 1])
sns.histplot(data=df, x="Total intl minutes", kde=True, color="navy", ax=axs[5, 0])
sns.histplot(data=df, x="Total intl calls", kde=True, color="coral", ax=axs[5, 1])
sns.histplot(data=df, x="Total intl charge", kde=True, color="cyan", ax=axs[6, 0])
sns.histplot(data=df, x="Customer service calls", kde=True, color="magenta", ax=axs[6, 1])
plt.show()
Explanation: From the above catplot, we see that the median number of total day minutes for customers who have churned is higher than the median number of total day minutes for customers who have not churned, for customer service calls under 4. Starting at 4 calls, the trend reverses and the median number of total day minutes for customers who have churned is lower than the median number of total day minutes for customers who have not churned. 
A clear relationship between total day minutes and churn is difficult to detect here.
10. Using subplot function, draw histogram of all numerical variables
End of explanation
<END_TASK>