Supervised Learning - Classification Week 8 Challenge
1. Apply knn to the “Surface defects in stainless steel plates” and identify the differences.
- labeled the dependent variables to a single dimentioanal array.
- droped TypeOfSteel_A400 column because its just the distinction from TypeOfSteel_A400 and TypeOfSteel_A300. this helps avoiding co_linearity among features and value 1 and 0 in TypeOfSteel_A300 is enough to differentiate the two.
- different hyperparameters were explored with the help of scikit learn API.
- manhattan distance proved to be more effective than euclidean distance.
- confusion matrix:

program and data files are attached below.
2. What are the pros and cons of knn?
| Pros | Cons |
| - No Training Period, KNN is called Lazy Learner (Instance based learning). It does not learn anything in the training period. | - Does not work well with large dataset. In large datasets, the cost of calculating the distance between the new point and each existing points is huge which degrades the performance of the algorithm. |
| - 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. | - Does not work well with high dimensions. The KNN algorithm doesn't work well with high dimensional data because with large number of dimensions, it becomes difficult for the algorithm to calculate the distance in each dimension. |
| - KNN is very easy to implement. There are only two parameters required to implement KNN i.e. the value of K and the distance function | - KNN is sensitive to noise in the dataset. We need to manually impute missing values and remove outliers. |