Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

k-nearest neighbors algorithm with c++ (oop) programming. Please, could you support for solutions as soon as possible? Assume that we have 2 features and 3

image text in transcribed

k-nearest neighbors algorithm with c++ (oop) programming.

Please, could you support for solutions as soon as possible?

Assume that we have 2 features and 3 categories. The features could be between -5 and 5. Also, we have 30 training samples and each sample has an index, a category id, and 2 features. Index attribute of a sample is an identity number between 0 and 29. Category attribute of a sample is a number between 0 and 2. The first 10 samples must belong to Category 0, then, the second 10 samples must belong to Category 1, and the last 10 samples must belong to Category 2. The features of a sample must be between -5 and 5. Assign features randomly corresponding to that interval. : Fig 1. An example classification for K-NN algorithm. (Source: Wikipedia) The test sample (green dot) should be classified either to blue squares or to red triangles. If k = 3 (solid line circle) it is assigned to the red triangles because there are 2 triangles and only 1 square inside the inner circle. If k = 5 (dashed line circle) it is assigned to the blue squares (3 squares vs. 2 triangles inside the outer circle) [1]. We have also 10 test samples with randomly assigned features between -5 and 5. Index attribute of a test sample is an identity number between 30 and 39. In this lab final, you will design a class hierarchy to classify test samples with K-Nearest Neighbors classification algorithm (k-NN). Use two separate containers for training and test samples. For each test sample, employ Euclidean distance and a plurality vote of its neighbor's criterion to determine category of a test sample

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Please make it fast 2 9 1 .

Answered: 1 week ago