The K-neighbors method is an instance-based learning algorithm. It remembers the
training set and when a new data point is presented it looks for the closest K samples
from the training set and returns.
the average of the target values of these K values for regression
the class of the majority of the K training examples. (using some procedure to break ties)
Regularisation
The parameter K can be used to control over
With K=1 the algorithm is likely to overfit.
Large values of k can underfit
Example
We can use the iris dataset:
for k=1
for k=3
if you can want to read more about k-means and know-how to implement it using the python code, then please comment in the below section or send your query related to any help.
#python #pythonhomeworkhelp #pythonassignmenthelp #pythonprojecthelp #pythonmachinelearning #machinelearningassignmenthelp