CommencerCommencer gratuitement

KNN on non-scaled data

Before adding standardization to your scikit-learn workflow, you'll first take a look at the accuracy of a K-nearest neighbors model on the wine dataset without standardizing the data.

The knn model as well as the X and y data and labels sets have been created already.

Cet exercice fait partie du cours

Preprocessing for Machine Learning in Python

Afficher le cours

Instructions

  • Split the dataset into training and test sets.
  • Fit the knn model to the training data.
  • Print out the test set accuracy of your trained knn model.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Split the dataset and labels into training and test sets
X_train, X_test, y_train, y_test = ____(____, ____, stratify=y, random_state=42)

# Fit the k-nearest neighbors model to the training data
____

# Score the model on the test data
print(____.____(____, ____))
Modifier et exécuter le code