Question: Please apply KNN algorithm to predict whether a customer will leave or not (target variable LEAVE ) with the data set churn.csv. Please report both

Please apply KNN algorithm to predict whether a customer will leave or not (target variable LEAVE ) with the data set churn.csv. Please report both codes and outputs clearly. A. Select column 2 to 7 (i.e., INCOME, OVERAGE, LEFTOVER, HOUSE, HANDSET PRICE, OVER_15MINS CALLS PER MONTH) as features and the last column (i.e., LEAVE) as target variable. Check the statistical summary of all features. (Note: please do NOT recode the target values into 1 and 0 ) B. Split the data into train (70\%) and test (30\%) set, with random state as 2023 . Scale the features by standardizing them. C. Train three KNN models with k=5,100,1000 respectively, check the generalization performance (i.e., accuracy) of each model on the test set. Which model is better? D. Create a sequence of 20 numbers evenly spaced between 10 (inclusive) and 200 (inclusive), with step size at 10 . Apply grid search to the training set to find the best k value from this sequence, use 5-fold cross validation in this process. What is the best k value? What is the mean cv score for the model with the best k value? E. Visualize the generalization performance of KNN models with different k values with a line plot. The x-axis shows the k values used in the grid search, and the y-axis shows the average generalization score on validation data returned by 5 -fold CV during grid search. F. The grid search process should return a best model (with the best k value) refitted on the entire training set, check its generalization performance (i.e., accuracy) on test set. In addition, apply the best model to make predictions for the first 10 instances in the test set, please display the predicted label and probability of 'Leave' for each instance. (Hint: figure out which column refers to the "LEAVE" class first)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
