Question: The objective of this lab is to program and test two classication algorithms, very simple but very eective: the K - Nearest Neighbor ( KNN

The objective of this lab is to program and test two classication algorithms,
very simple but very eective: the K-Nearest Neighbor (KNN) algorithm and the
Classier Bayesian Naive (CBN). We are studying here only the simplest versions
of these algorithms. For this lab we will need to import sklearn and numpy. The
tests can be done on sklearn's predened data that comes with their class labels
(target), for example:
iris = datasets.load_iris ()
X = iris.data
Y = iris.target
A Nearest neighbor
The Nearest Neighbor algorithm is a very simple classication algorithm which is
based on the following principle: the class of each test data (to be classied) must
be the class of the closest (most similar) data among the training data. List of
useful functions:
- metrics.pairwise.euclidean_distances: calculates distances between data.
- argsort: returns the indices of the ordered vector
- argmin, argmax: returns the indices of the minimum/maximum values
- neighbors.KNeighborsClassifier: K Nearest Neighbors alg. of sklearn
2. The TNN function calculates a predicted label for each data. Change the
function to calculate and return the prediction error: i.e. the percentage
badly predicted labels and test it on Iris Data.

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!