Question: How to use the (unweighted) KNN algorithm for predicting thecarat(numerical) target feature for the following single observation using the Euclidean distance metric with different number

How to use the (unweighted) KNN algorithm for predicting thecarat(numerical) target feature for the following single observation using theEuclidean distancemetric with different number of neighbors:

  • cut= good
  • color= D
  • depth= 60
  • price= premium
  • (carat= 0.71 but you will pretend that you do not have this information)

Q.2

KNN modeling. Specifically,

  1. Perform one-hot encoding of the categorical descriptive features in the input dataset.
  2. Scale your descriptive features to be between 0 and 1.
  3. Display thelast10 rows after one-hot encoding and scaling.

NOTE:For Parts (B), (C), and (D) below, you arenotallowed to use theKNeighborsRegressor()in Scikit-Learn module, but rather use manual calculations (via either Python or Excel). That is, you will need to show and explain all your solution stepswithoutusing Scikit-Learn. The reason for this restriction is so that you get to learn how some things work behind the scenes.

Q.3

What is the prediction of the 1-KNN algorithm (i.e., k=1 in KNN) for thecarattarget feature using your manual calculations (using the Euclidean distance metric) for the single observation given above?

What is the prediction of the 5-KNN algorithm?

What is the prediction of the 10-KNN algorithm?

This part (E) is an exception to the solution mode instructions for this question. In particular, you will need to use theKNeighborsRegressor()in Scikit-Learn to perform the same predictions in each Part (B) to (D). That is,

  • What is the prediction of the 1-KNN algorithm usingKNeighborsRegressor()?
  • What is the prediction of the 5-KNN algorithm usingKNeighborsRegressor()?
  • What is the prediction of the 10-KNN algorithm usingKNeighborsRegressor()?

Are you able to get the same results as in your manual calculations? Please explain.

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 Mathematics Questions!