Machine Learning Tutorial Python - 18: K nearest neighbors classification with python code
ฝัง
- เผยแพร่เมื่อ 27 มิ.ย. 2024
- In this video we will understand how K nearest neighbors algorithm work. Then write python code using sklearn library to build a knn (K nearest neighbors) model. The end, I have an exercise for you to practice concepts you learnt in this video.
Code: github.com/codebasics/py/blob...
Exercise: github.com/codebasics/py/blob...
⭐️ Timestamps ⭐️
00:00 Theory
03:51 Coding
14:09 Exercise
Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
Machine learning tutorial playlist for beginners: • Machine Learning Tutor...
🌎 My Website For Video Courses: codebasics.io/?...
Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
🎥 Codebasics Hindi channel: / @codebasicshindi
#️⃣ Social Media #️⃣
🔗 Discord: / discord
📸 Dhaval's Personal Instagram: / dhavalsays
📸 Instagram: / codebasicshub
🔊 Facebook: / codebasicshub
📱 Twitter: / codebasicshub
📝 Linkedin (Personal): / dhavalsays
📝 Linkedin (Codebasics): / codebasics
❗❗ DISCLAIMER: All opinions expressed in this video are of my own and not that of my employers'.
Do you want to learn technology from me? Check codebasics.io/ for my affordable video courses.
just a tip I read from a book: for highly structured data a smaller K is better (like this example, or handwritting/ speech recognition), but for noisy data it is recommended using a bigger K.
keep up the great videos!
can u lmk the book ur refering to
When you said most important skill then said ctrl C/Ctrl V I lost it. haha. great video
I got a score of 0.99444 with k=6 while using random state to test the outcomes of each change in K. I've also discovered that sklearn has a module for displaying confusion matrix without using seaborn or matplotlib. The module is called ConfusionMatrixDisplay and it only takes the confusion matrix object as its parameter. Thanks Dhaval Patel sir.
The best teacher makes simple the difficult subject. Thank you. You are great!!!
iv tested the classification with KNN in the digits dataset and had an accuracy of 99.44% with n_neighbours=3 and test_size=0.2 of the split (i never see solutions) thank you for your tutorials its extremely useful (y)
Nice explanation and sir please continue this playlist it's really helpful to gain knowledge regarding Machine learning.
Thank you so much sir
"How to become data scientist/ML engineer"
Views = 500K
"Tutorial on ML/DS topics"
Views = 5-10K
sums up how much effort everyone is putting to be a ML/DS guy🌝
Ha ha, this is so true 😊
7:39 Most relatable statement I've heard so far
these lectures tempt me to search for next upcoming videos...thank you for all these effort...
What an amazing and, easy to learn video. Thank you.
Going back to basics Boss!?! You are amazing !!
The most important skill that you have is to copy the amazing knowledge you have and past it smoothly to our understanding. That is what I called mastering ctrl c and ctrl v
Thank you so much, Dhaval! I'm watching your videos to survive my DS classes.
Even my training institute is teaching from your codes only.
You are really a great teacher
😂😂😂
Really an outlier in simplification. Awesome 🙏
I tested n_neighbors between 1 to 100 using cross validation and plotted the results. looks like as you increase number of neighbors, the score declines (the cool thing is it's linear)
highest score was at n_neighbors = 3 with test_size = 0.33 and it was 0.9915.
p.s: I have watched all the videos from this series and I've got to say you're amazing sir. keep making tutorials cause you're the best!
try test_size=0.2 i had 0.9944 😀
First time here and I just have to subcribe. Very funny but good teacher. God bless you.
Very easy and meaningful explanation, Thank You Sir
Awesome explanation!!
Your last comment is very sir.
Your are an amazing teacher sir.
Thanks a lot
Exercise Result 99.16% Score with k=4, Thank u so much sir, i m trying to solve all ur exercises and it is helping me build my confidence in ML
hi..can u tell the scope of ml in jobs
@@obamaengineer4806
Amazing
Please do it for other algorithms also
You are excellent!!!!
you're the best.Thank you
im gonna use my most important skill "Ctrl-C Ctrl-V" hahaha.. that funny sir
Very useful video, that's a lot
Plotted scores between 1 and 50 and found highest accuracy at k = 7 or k = 8 at 99.72% accuracy. Like everyone else, it sharply declined after that. Used the same parameters for data split as in the video.
Really informative sir
for k =1 overfit issue for k=3 I got the best score of 0.985397 for the exercise digits dataset . as compared to the SVM, KNN gave the best accuracy for digits dataset
nice lecture sir
pretty good tutorial for free👍
Thank u sir
Perfect score with n_neightbors = 6.
Your computer will start sneezing and it will have a fever 🤣🤣 Amazing content ❤💯
Thankss!
Thanks😀
Sir can you explain this code to replace nan values with knn and dataset have both categorical and continuous datapoint
If a give an input list for the KNN algorithm to predict the classes of each element, How can I print out the list of inputs only belonging to a particular class?
hello sir, while making the heatmap using the seaborn during making label I think at x -axis there should true and in y label predicted but you had done exactly opposite
is it like as you done ore actually there is mistakes I have confusion in confusion matrix interpretation.
please reply me sir
Sir , i have a background of Geophysics and i want to do data science in canada. So, is it possible to connect data sciences with Geophysics
Most important skill cntrol c and control v hence prooved in this video,,...😝
Can we use SVM here 6:45 . since it can be easily separated using hyperplane
I have one doubt, in Confusion_Matrix(Truth,Predicted) , but in plt graph we are giving in reverse... like x-axis as Predicted and y-axis as Truth....
Can you please clarify , Thank you 🙏
I dont think it matters....you can do either way...You may try yourself..
I got an accuracy of 96.38 with K = 4 after working on the exercise
Sir can you post about unsupervised learning, about Boltzmann machine and it's types
i.restricted Boltzmann machine
ii. Deep Boltzmann machine
iii. Deep belief network
Can you create videos for Reinforced Learning?
most Important skill
Ctrl + C and Ctrl + V....
😂sir you are humorous!
Is it necessary to split the dataset into Training and Testing set for KNN? Since KNN being a lazy algorithm
He is just doing it for testing the model. So it's like he only had data equal to training data. Then he used testing data as foreign data to figure out where those foreign data lie in the clusters.
@@ShawnDypxz Makes sense. Thank you
Hi Sir , Thanks Thanks Thanks for this explain and You are great man in your explain thanks alooooot,, Excuse me Sir is the test=30% and train =70%?
yes it is.....but you can change it to 80:20 if you wish to
great explanation!!! using gridsearchcv method, K=2 was the best value. Continue the great job
🤩
I was following this tutorial series but unfortunately it is missing some topics. Any idea how many topics are left?
yes I need to cover XGBoost, adboost, bagging, boosting, PCA. But majority of the topics are covered already in the series.
*Hi, I have already added this comment to Perosonal Finance video but adding again to get an answer*
*NEED HELP*
I am currently doing *Personal Finance* project but I am getting error and despite dsearching a lot I couldnot resolve it, While transforming data initially, when I change date type from text to (Date) type, it only shows 2021 at the end of every date, like this 1/18/2021. Even before it was data of 2019 like jan-19 but after only shows this. Please help me in this, I am stuck here for a long time.
Sir it is mandatory to learn excel and statistics for data analyst jobs?
yes
Hi sir ,I want your videos on Rasa chatbot and sentiment analysis
I can help you, worked on building RASA based models as well
@@shobhitbishop thank you sir.
Please tell me how to make Knn based error checking on language in step by step or please share any link ??
Hi, How many ways to find out K value. And " Elbow" method it's useful or not in finding K value, if suppose not why?
Elbow method is used in K-means clustering
Sir I'm a fresher chemical engineer, can I build career in data analytics? I'm so confused . Plz help
yes you can
how to develop the model using KNN ?@@suprithhemanthkumar9166
Sir, I would die for you. I am paying thousands of dollars for some guy to not teach me a goddamn thing.
😂😂😂I like the joke at the end of the video, i have tried it and my below is my classification report:
precision recall f1-score support
0 1.00 1.00 1.00 26
1 0.89 1.00 0.94 50
2 1.00 1.00 1.00 38
3 1.00 0.93 0.96 28
4 1.00 0.96 0.98 28
5 0.96 1.00 0.98 43
6 1.00 1.00 1.00 32
7 0.95 1.00 0.98 42
8 1.00 0.88 0.93 40
9 1.00 0.94 0.97 33
accuracy 0.97 360
macro avg 0.98 0.97 0.97 360
weighted avg 0.97 0.97 0.97 360
and my cm is:
array([[26, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 50, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 38, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 26, 0, 1, 0, 1, 0, 0],
[ 0, 0, 0, 0, 27, 0, 0, 1, 0, 0],
[ 0, 0, 0, 0, 0, 43, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 32, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 42, 0, 0],
[ 0, 5, 0, 0, 0, 0, 0, 0, 35, 0],
[ 0, 1, 0, 0, 0, 1, 0, 0, 0, 31]], dtype=int64)
Dang I caught the virus lol j/k. Thanks great video! 👍
now my computer has a fever
test_size = 0.2
k = 7
score: 0.9972222222222222
My computer got the virus, he wasn't lying
ayo why is marc specter teaching artificial intelligence?
It is my alter ego teaching ML 😎
Why people keep calling you sir?
how this question it is even related to ML
lol virus 😂
i think sir you need to work on how to speak. It seems you are pretty confused yourself