How to implement KNN from scratch with Python
Вставка
- Опубліковано 28 сер 2024
- In the first lesson of the Machine Learning from Scratch course, we will learn how to implement the K-Nearest Neighbours algorithm. Being one of the simpler ML algorithms, it is a great way to kick off our deep dive into ML algorithms.
You can find the code here: github.com/Ass...
Previous lesson: • Machine Learning From ...
Next lesson: • How to implement Linea...
Welcome to the Machine Learning from Scratch course by AssemblyAI.
Thanks to libraries like Scikit-learn we can use most ML algorithms with a couple of lines of code. But knowing how these algorithms work inside is very important. Implementing them hands-on is a great way to achieve this.
And mostly, they are easier than you’d think to implement.
In this course, we will learn how to implement these 10 algorithms.
We will quickly go through how the algorithms work and then implement them in Python using the help of NumPy.
▬▬▬▬▬▬▬▬▬▬▬▬ CONNECT ▬▬▬▬▬▬▬▬▬▬▬▬
🖥️ Website: www.assemblyai...
🐦 Twitter: / assemblyai
🦾 Discord: / discord
▶️ Subscribe: www.youtube.co...
🔥 We're hiring! Check our open roles: www.assemblyai...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Are KNN and K-means the same thing?
No. KNN is a supervised learning algorithm whereas K-means is a clustering algorithm.
#MachineLearning #DeepLearning
Short and simple. I like the way you explained the KNN in simple words.
Thank you!
Implementing KNN is so easy? That was my first thought after I saw this video. Really the way, it is explained and shown here is remarkable. It not only shows KKN but also how powerful is plain Python when used sensibly with library like Numpy. The entire idea is very useful for beginners like me. I am now AssemlyAI subscriber. I am going to not only see but follow along all videos of this playlist in order to get better understanding of Python, Numpy, Pandas and DataScience. Thank you AssemblyAI for sharing.
This is the best series to learn ML.
🎓🔥🔥
Imma recommend it to all my ml enthusiast friends ✌🏻
Thank you!
wonderfully done with a lot of clarity
The free course is appreciated, but I have trouble understanding some of the terms and the thoughts behind certain functions.
short and simple ,no complications
Very easy to follow after I created my own implementation. Very similar to my own implementation, except I elected to use a priority queue to keep track of the k nearest, instead of sort (because having to keep track of indices was a pain, and it was getting late). Coded mine in C# without third party libraries. I like that numpy offers a argsort method here, comes in handy.
Great tutorial, I also added tie-breaking functionality in case tie occurs in most frequent label.
I don't understand that why we add terms that '[0][0]' to the list of most_commons? 8:04
The counter returns the sorted count of all possible outcomes, i.e. a list of tuples and each tuples has the label and the count, (label, count). You only want the most common one, i.e. the first element in the array and you only want the label, not the count, i.e. you want the first element of that tuple which is also accessed by using [0]. Therefore you need to apply [0][0].
Short and simple, Thank you very much
You're very welcome!
Nice and concise. Love it.
Thank you abla
How can I plot the graph again to see if it turned those blues into the green?
Whoa, excellent video! It was well explained, thanks! 😁😁👍🤩
You're very welcome :)
I like to follow this course from Lesson 1, what is the link that i need to start here?
I am getting error no module NAMED KNN .... pl help to resolve this problem.
I love this tutorial so much
Awesome!
cheers. still not entirely sure what the output of the Counter method is... i.e. that last array similar to this: [1, 2, 2, 0, 1, 2 ..., 1] etc.
Could you perhaps explain?
These are the target labels
example for reference :
-- Iris Setosa : 0
-- Iris Versicolour: 1
-- Iris Virginica: 2
Great video!
Glad you enjoyed it
Thank you for sharing
Thanks for watching!
Thank you
You're very welcome :)
good job, I like it, KNN doesn't well with images i believe right?
What about the regression case?
There is no regression in knn it is a classification algorithm
@KarthickKenny. One can apply KNN when the response variable is continuous
@@andrea-mj9ce you have to apply regression algorithm in that case not knn
amazing job
wow, she knows her stuff.
great excahnge ndiro niya
How did you visualised the data ?
Please explain in more detail every line code.
Amazing!
numpy error in vscode???
great simple tutorial but how do i plot a graph with the knn?
Great video! Thnk you for making it.
Got this error in Colab. ModuleNotFoundError: No module named 'KNN' when running from KNN import KNN
You're welcome Santiago! You should include the KNN python file we develop in the video in the file system of the collab notebook. That should get rid of the error! :)
how to setup my machine with all these libraries ???
pip
i love you
Thx, however, this euclidean distance function needs to be corrected.
It's actually ok I'd say
@@osviiii yeap i checked that, i just confused a little
nice
How to implement knn from scratch… import numpy and sklearn ¯\_(ツ)_/¯
Are you Turkish
Yes!
@@AssemblyAI that "i" in range pronounciation gave it away :D
thank you for the practice... but it's an exact copy from this one ua-cam.com/video/ngLyX54e1LU/v-deo.html created 4 years ago
Yes! Pat works with me too, we decided to do a new run of his videos :)
Lewis Brenda Walker James Jackson Charles
I like this approach, it is so helpful. Curious how it compares with sklearn's version of sklearn.neighbors.KNeighborsClassifier 😃
I went through all of these Assembly AI lessons, making each one work perfectly. Then I redid each one using Scikit Learn classes. In every case, I was able to drop in the sklearn equivalent and get the same or better results. A good entree into Scikit Learn.