Menu

(Solved) : Use Python Notebooks Learn Knn Mnist Dataset Explore Curse Dimensionality Try Decision Tre Q43941152 . . .

use python notebooks to learn about kNN, the MNISTdataset, explore the curse
of dimensionality, and try out the decision tree classifer in thesklearn library.

[8pts total] Q1. k-Nearest Neighbours Classifier on Synthetic Data One of the important ways of both understanding and also d

This needs to be written in Python. We are usingGoogle Colab

This is a machine learning class.

Question is to set up data to implement K-nearestneighbours algorithms

[8pts total] Q1. k-Nearest Neighbours Classifier on Synthetic Data One of the important ways of both understanding and also debugging machine learning algorithms is to create your own, synthetic data sets. In this question you will implement a k-nearest neighbours (kNN) classifier and evaluate it on synthetic data. a) (2pts Create the data set. You will “train” a KNN classifier on the following training data: . The data is 2-dimensional points in a grid, such that the 11-coordinates and 19-coordinates both range from -1.5…1.5, with a spacing of 0.1 between points. • A training point, I=(11,19), will be classified as follows: – Class 1 if |2||2 <1 – Class 2 otherwise Write code that generates this dataset and displays it using a scatterplot, using different colours for each class. Note || || = ( +25) can be implemented by: numpy.linalg.norm( [x[0], x[i]], p) b) (3pts] Implement the KNN algorithm. This may be best done using a Python class, with a fit method that takes the training data and k as input, and a predict method that takes a test example as input and returns a class prediction. You should find the nearest neighbours by using the Euclidean distance, ||2 – y2- c) 1pt Visualize the predictions. Use the matplotlib.pyplot.contourf function to display how your KNN classifier performs on new data. To do this, evaluate your model’s predictions across a fairly fine numpy.meshgrid, with a space of about 10-2 between points. The meshgrid can have boundaries from-1.5 to 1.5 in both coordinates. By examining multiple plots, can you say how the performance of the classifier depends on k? d) (1pt] Try another data set. Repeat part a), replacing the condition |2 <1 with 1 <1, and repeat part c) on the new training data. How does the performance of the classifier change with k? (Try some extreme values!) e) (1 pt) Continue exploring data sets. Repeat part a), replacing the condition ||||2 <1 with |||04 S1, repeat part c) with the data. Now how does the performance of the classifier change with k? Based on your results, do you think using Euclidean distance for kNN is always the best choice? Show transcribed image text [8pts total] Q1. k-Nearest Neighbours Classifier on Synthetic Data One of the important ways of both understanding and also debugging machine learning algorithms is to create your own, synthetic data sets. In this question you will implement a k-nearest neighbours (kNN) classifier and evaluate it on synthetic data. a) (2pts Create the data set. You will “train” a KNN classifier on the following training data: . The data is 2-dimensional points in a grid, such that the 11-coordinates and 19-coordinates both range from -1.5…1.5, with a spacing of 0.1 between points. • A training point, I=(11,19), will be classified as follows: – Class 1 if |2||2

Expert Answer


Answer to use python notebooks to learn about kNN, the MNIST dataset, explore the curse of dimensionality, and try out the decisio…

OR