Comments (2)
KNN - K Nearest Neighbor
KNN algorithm is mainly used to classify and predicting the values in Machine Learning. We can use it for Supervised Machine Learning problems(Labeled) such that Classification and Regression.
KNN
K - constant value
NN - Nearest Neighbor
KNN is simply , Finding the K Nearest Neighbor of the data point and classifying the data points with maximum number of classes of the neighbors
We can find the value of K by finding the mean of the error in each records and plotting as graph
K is the value where the mean error rate is lesser
error =[]
for i in range(1, 40):
model = KNeighborsClassifier(n_neighbors=i)
model.fit(x_train, y_train)
pred_i = model.predict(x_test)
error.append(np.mean(pred_i != y_test))
plt.figure(figsize=(15, 15))
plt.plot(range(1, 40), error, color = "red", linestyle = "dashed", marker="o", markerfacecolor="blue", markersize=10)
plt.title('Error Rate K value')
plt.xlabel('K value')
plt.ylabel('Mean Error')
plt.show()
Finding K -> Finding how many neighbors that we have to choose around the data point
Value of k = less error rate
After choosing K value,
You may have a question like,
How will it find the k nearest points ?
Distance of the data points will be calculated in KNN using Minkowski distance.
Based on Minkowski Distance metric, We gonna classify the data points.
p=1, Manhattan Distance
p=2, Euclidean Distance
Manhattan Distance
This is the distance between real vectors using sum of their absolute difference.
Euclidean Distance
Euclidean distance is calculated as the square root of sum of the squared differences between a new point (x) & existing point y
Hamming Distance
It is used for categorical variables. If the value x and the value y are the same, the distance d will be equal to 0. Otherwise distance equal to 1
The above methods are used to find the distance and to finding the k closest neighbor of that particular data point.
With the classes of neighbors, We can classify the data point with maximum neighbor's class
Thank you!
from onestep-electron-content.
Hey @sudharsansrini the content that you mentioned above looks really amazing and we could incorporate it in the main platform. I am pretty sure that writing this would have taken a good amount of time and i request you to make a PR for the same because otherwise it won't get counted as your contribution. Feel free to join our discord if you need any help with how to contribute and stuff like that.
from onestep-electron-content.
Related Issues (9)
- Content Enhancement : Linear Regression HOT 16
- Content Enhancement : Logistic Regression HOT 1
- Content Suggestion for Advanced Track HOT 3
- Implement a GitHub action for automating plagiarism check. HOT 1
- Content Request: Introduction to Artificial Neural Networks HOT 5
- Found a typo in SVM.md HOT 5
- Documentation request HOT 1
- Content Suggestion for Intermediate Track HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onestep-electron-content.