LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Preprocessing for Machine Learning in Python

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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(____.____(____, ____))
Code bearbeiten und ausführen