Question: What do I have wrong here? # Your code to train knn, make predictions, and compute accuracy goes in here #accuracy = # compute accuracy

 What do I have wrong here? # Your code to train

What do I have wrong here?

# Your code to train knn, make predictions, and compute accuracy goes in here

#accuracy = # compute accuracy here

Employee_attrition is the data.

1. Train a knn model where k is 3 using the training dataset. 2. Make predictions using the test dataset 3. Compute accuracy and save as accuracy - Hints: - You need to use the KNeighborsClassifier function. Instantiate a knn object and pass the number of neighbors to the function. Train the model using the X _train and ytrain. Then make predictions using X _test. Then compute the accuracy using the predicted values and y test. - Check Module 6d: Model Performance and_Module 5c: Classification 4]: from sklearn.neighbors import KNeighborsclassifier from sklearn.metrics import confusion_matrix knn = KNeighborsclassifier(n_neighbors = 3) knn.fit(X_train, y_train) cm = confusion_matrix (y test, knn.predict(X_test) ) accuracy =(cm[,0]+cm[1,1])/sum(sum(cm)) accuracy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!