Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
1. Create a TNN function (X, Y) which takes X data and labels as input Y and
which returns a label, for each data, predicted from the nearest neighbor of
this data. Here we take each data, one by one, as data test and we consider
all others as learning data. That we allows to test the power of our algorithm
according to a validation method by cross validation of leave one out type.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions