11. Machine Learning
Activity 25: Using Machine Learning to Predict Customer Return Rate Accuracy
Solution:
- The first step asks you to download the dataset and display the first five rows.
Import the necessary
pandasandnumpylibraries to begin with:import pandas as pd import numpy as np
- Next, load the
CHURN.csvfile:df = pd.read_csv('CHURN.csv') - Now, display the headers using
.head():df.head()
You should get the following output:
Figure 11.37: Dataset displaying the data as output
- The next step asks you to check for
NaNvalues. The following code reveals that there are none:df.info()
You should get the following output:
Figure 11.38: Information on the dataset
- The next step is done for you. The following code converts
'No'and'Yes'into0and1:df['Churn'] = df['Churn'].replace(to_replace=['No', 'Yes'], value=[0, 1])
- The next step asks you to correctly define
Xandy. The correct solution...