Challenge

Supervised Learning - Classification Week 8 Challenge

Q.1 Apply knn to the “Surface defects in stainless steel plates” and identify the differences.

Note:Coding file for this question is uploaded in .ipynb format

Q.2 What are the pros and cons of knn

Pros:

  • It can be used for both classification and regression problems.
  • The mathematics behind the algorithm is easy to understand.
  • There is a single hyperparameter, the value of K. This makes hyper parameter tuning easy.
  • It is very easy to implement as the only thing to be calculated is the distance between different points on the basis of data of different features and this distance can easily be calculated using distance formula such as- Euclidian or Manhattan
  • There is no training period for it. It stores the training dataset and learns from it only at the time of making real time predictions.This makes the KNN algorithm much faster than other algorithms that require training e.g. SVM, Linear Regression etc.
  • Since the KNN algorithm requires no training before making predictions, new data can be added seamlessly which will not impact the accuracy of the algorithm.
  • KNN doesn’t make any assumption for the distribution of the given data.

Cons:

  • Does not work well with high dimensionality as this will complicate the distance calculating process to calculate distance for each dimension.
  • Does not work well with large dataset because in large datasets, the cost of calculating the distance between the new point and each existing point is huge which degrades the performance of the algorithm.
  • Feature scaling required-We need to do feature scaling (standardization and normalization) before applying KNN algorithm to any dataset. If we don’t do so, KNN may generate wrong predictions.
  • KNN is sensitive to noise in the dataset. We need to manually impute missing values and remove outliers.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.