Title: Running K-Nearest Neighbors Model and Making Predictions in Machine Learning using Python
Task 5: Run the example codes of Building Your First Model: K-Nearest Neighbors and Making predictions sections on the Jupyter notebook at once as follows:
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=i)
knn.fit(x_train, y_train)
x_new = np.array([[5, 2.9, 1, 0.2]])
print("x_new.shape: {}".format(x_new.shape))
prediction = knn.predict(x_new)
print("Prediction: {}".format(prediction))
print("Predicted target name: {}".format(iris_dataset['target_names'][prediction]))
Above example code predicts the input (new) as class setosa. Change the values in new to observe when the model outputs different predictions (versicolor or virginica). Find out which value has the highest impact on prediction. Include your code and results.