Question: You are given the following Python code: from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix iris =
You are given the following Python code: from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix iris = load_iris () X= iris.data y= iris.target \# Splitting the dataset into training and test set. Xtrain, Xtest, ytrain, ytest =train_test_split (X,y, test_size =0.35) \# Part (b)(i): Add your code here \# Part (b)(ii): Add your code here Write Python code to complete the following tasks: (i) Create and train a K-Nearest Neighbors model with the given dataset. [2 marks] (ii) Compute and output the Confusion Matrix. [2 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
