Solved

Consider the Following Code and Output: in [57]: for K

Question 36

Multiple Choice

Consider the following code and output: In [57]: for k in range(1, 20, 2) :
) ..: kfold = KFold(n_splits=10, random_state=11, shuffle=True)
) ..: knn = KNeighborsClassifier(n_neighbors=k)
) ..: scores = cross_val_score(estimator=knn,
) ..: X=digits.data, y=digits.target, cv=kfold)
) ..: print(f'k={k:<2}; mean accuracy={scores.mean() :.2%}; ' +
) ..: f'standard deviation={scores.std() :.2%}')
) ..:
K=1 ; mean accuracy=98.83%; standard deviation=0.58%
K=3 ; mean accuracy=98.78%; standard deviation=0.78%
K=5 ; mean accuracy=98.72%; standard deviation=0.75%
K=7 ; mean accuracy=98.44%; standard deviation=0.96%
K=9 ; mean accuracy=98.39%; standard deviation=0.80%
K=11; mean accuracy=98.39%; standard deviation=0.80%
K=13; mean accuracy=97.89%; standard deviation=0.89%
K=15; mean accuracy=97.89%; standard deviation=1.02%
K=17; mean accuracy=97.50%; standard deviation=1.00%
K=19; mean accuracy=97.66%; standard deviation=0.96%
Which of the following statements is false?


A) The loop creates KNeighborsClassifiers with odd k values from 1 through 19 and performs k-fold cross-validation on each.
B) The k value 7 in kNN produces the most accurate predictions for the Digits dataset.
C) The accuracy tends to decrease for higher k values.
D) Compute time grows with k, because k-NN needs to perform many more calculations to find the nearest neighbors.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents