Train a knn model where k is 3 using the training dataset.
Make predictions using the test dataset
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 y_train. 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
Question 12
Train a Random Forests model where the number of estimators is 100 using the training dataset.
Make predictions using the test dataset
Compute accuracy and save as accuracy
Hints:
You need to use the RandomForestClassifier function. Instantiate a RandomForestClassifier object and pass the number of estimators to the function. Train
the model using the X_train and y_train. 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