Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Python Program, provide codes and detailed explanation at each step. Goal: Create a mini but functional kNN classifier with hyperparameter search ( specifically

Create a Python Program, provide codes and detailed explanation at each step.
Goal:
Create a mini but functional kNN classifier with hyperparameter search (specifically, use GridSearchCV in sklearn.model_selection).
Use Numpy for data processing (data initialisation, data insertion etc) and use Scikit-learn library for machine learning part.
The program asks the user for input N (positive integer) and reads it.
Then the program asks the user to provide N (x, y) pairs (one by one) and reads all of them: first: x value, then: y value for every pair one by one.
X is treated as the input feature and Y is treated as the class label. X is a real number, Y is a non-negative integer.
This set of pairs constitutes the training set TrainS ={(x, y)_i}, i =1..N.
Then the program asks the user for input M (positive integer) and reads it.
Then the program asks the user to provide M (x, y) pairs (one by one) and reads all of them: first: x value, then: y value for every pair one by one.
X is treated as the input feature and Y is treated as the class label. X is a real number, Y is a non-negative integer.
This set of pairs constitutes the test set TestS ={(x, y)_i}, i =1..M.
In the end, the program outputs: thebest kfor the kNN Classification method and thecorresponding test accuracy.
kNN Classifier should be trained on pairs from TrainS, tested on x values from TestS and compared with y values from TestS.
Try the following range of k: 1<= k <=10.

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions