Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

KNN cluster classification works by finding the distances between a query and all examples in its data. The specified number of examples (K) closest to

KNN cluster classification works by finding the distances between a query and all examples in its data. The specified number of examples (K) closest to the query are selected. The classifier then votes for the most frequent label found.

There are several advantages of KNN classification, one of them being simple implementation. Search space is robust as classes do not need to be linearly separable. It can also be updated online easily as new instances with known classes are presented.

A KNN model can be implemented using the following steps:

  1. Load the data;
  2. Initialise the value of k;
  3. For getting the predicted class, iterate from 1 to total number of training data points;
  4. Calculate the distance between test data and each row of training data;
  5. Sort the calculated distances in ascending order based on distance values;
  6. Get top k rows from the sorted array;
  7. Get the most frequent class of these rows; and
  8. Return the predicted class.

For your assignment, you will build a KNN classifier in Python.

CSV file has data that looks like this:

15,66,237,0,Strategy 21,60,238,0,Platformer 14,78,176,1,Strategy 10,67,216,1,Strategy 19,69,185,1,RPG 34,72,138,0,Platformer

Using this data, your classifier should be able to predict a person's favorite video game genre based on their age, height, weight, and gender. (Do not worry about real-world accuracy here. This is to provide you an opportunity to practice.)

You can also choose to collect and use your own data points.

Submission should include an executable Python file that accepts input of 4 floating point numbers representing, respectively, age (in years), height (in inches), weight (in lbs), and gender (females represented by 0s and males represented by 1s).

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

Outline the process of short-selling.

Answered: 1 week ago

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago