In [1]:
In [2]:
Check the head of the dataframe.
In [23]:
Out[23]:
In [4]:
Out[4]:
In [5]:
Create a StandardScaler() object called scaler.
In [6]:
Fit scaler to the features.
In [7]:
Out[7]:
Use the .transform() method to transform the features to a scaled version.
In [8]:
Convert the scaled features to a dataframe and check the head of this dataframe to make sure the scaling worked.
In [9]:
Out[9]:
In [10]:
In [11]:
In [12]:
Create a KNN model instance with n_neighbors=1
In [13]:
Fit this KNN model to the training data.
In [14]:
Out[14]:
Use the predict method to predict values using your KNN model and X_test.
In [24]:
Create a confusion matrix and classification report.
In [16]:
In [17]:
In [18]:
In [25]:
Now create the following plot using the information from your for loop.
In [20]:
Out[20]:
In [21]: