Quiz Space

Machine Learning Practice · Quiz 2 · 1 Dec 2024 · September 2024 term

Question 19: What will be the output of the following code?

Question 19

+3 marksNumerical answer

What will be the output of the following code?

python
import numpy as np
from sklearn.neighbors import KNeighborsRegressor
X_train = np.array([[1, 100], [4, 400], [5, 500], [6, 600], [8, 800],
[9, 900], [11, 1100], [12, 1200], [15, 1500],
[18, 1800], [19, 1900]])
y_train = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
X_test = np.array([[2, 200]])
knn = KNeighborsRegressor(n_neighbors=len(y_train),
metric="euclidean",
weights='uniform')
knn.fit(X_train, y_train)
print(knn.predict(X_test))
Show answer

Correct answer: 60

Question 19 of 21 in the IIT Madras BS Machine Learning Practice (MLP) Quiz 2 paper sat on 1 Dec 2024, in the September 2024 term (IIT M DIPLOMA AN EXAM QDD2 01 Dec 2024). It carries 3 marks.

More questions from this paper

  1. Q1Consider the following code for Ridge Regression: What will be the output for the coefficients?
  2. Q2Consider the following code for Stochastic Gradient Descent (SGD) Classifier: What is the significance of l1_ratio = 0.…
  3. Q3Given the following code for Polynomial Regression: What will be the output of the code?
  4. Q4Consider the following code implementation that utilizes sklearn to set up a machine learning model with preprocessing:…
  5. Q5Figure question
  6. Q6Consider the following code: What will be the behavior of the code?
  7. Q7Figure question
  8. Q8Figure question
  9. Q9You are working on a classification project using the Wine dataset. After fitting a Gaussian Naive Bayes model, you wan…
  10. Q10Figure question
  11. Q11Figure question
  12. Q12Figure question
  13. Q13Figure question
  14. Q14Figure question
  15. Q15You are a data scientist working on a binary classification problem to predict whether customers will buy a product bas…
  16. Q16Consider the following RidgeClassifier implementation in Python: Which of the following statements are correct? (Select…
  17. Q17Figure question
  18. Q18Figure question
  19. Q20In the following code snippet, how many bigrams will be generated when using CountVectorizer with ngram_range=(2, 2)? E…
  20. Q21Figure question