Model Training Using Scaled Features
Explore how to train a K-Nearest Neighbors model using scaled features, evaluate its performance, and understand the impact of parameter choices like k-value on model accuracy and efficiency. Learn why scaling is crucial in distance-based algorithms.
We'll cover the following...
We have the scaled data from the previous lesson. Let’s split the data into the train and test parts. We can either use our newly created data frame (df_scaled_features) or NumPy array (scaled_features). Let’s try the NumPy array for now.
We’ll train the model with the training data.
Model training using scaled features
Let's create an instance of KNeighborsClassifier with a different name, fit the training dataset, and predict in a single cell. For direct comparisons to see the effect of scaling, we'll keep n_neighbors = 3 the same as without scaling.
Once our model is created, we can evaluate it.
Predictions and evaluations
Let's perform the model evaluations.
We are getting accurate evaluations and significant improvements using scaled features. We can see the importance of scaled features in distance-based algorithms like KNN. However, we are not done yet. There is another thing we need to check ...