Navigate Select ESC Close

K-Means Clustering From Scratch in Python (Mathematical)

2023-06-25 Science & Technology
42.6k
1.1k
27
NeuralNine
NeuralNine
470.0k subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

In this video we implement K-Means clustering from scratch. We look at the theory and the mathematics behind it and then we use NumPy to put it into code. ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾ 📚 Programming Books & Merch 📚 🐍 The Python Bible Book: https://www.neuralnine.com/books/ 💻 The Algorithm Bible Book: https://www.neuralnine.com/books/ 👕 Programming Merch: https://www.neuralnine.com/shop 💼 Services 💼 💻 Freelancing & Tutoring: https://www.neuralnine.com/services 🌐 Social Media & Contact 🌐 📱 Website: https://www.neuralnine.com/ 📷 Instagram: https://www.instagram.com/neuralnine 🐦 Twitter: https://twitter.com/neuralnine 🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/ 📁 GitHub: https://github.com/NeuralNine 🎙 Discord: https://discord.gg/JU4xr8U3dm Timestamps: (0:00) Intro (0:17) Theory & Math Background (7:21) Coding K-Means From Scratch (32:37) Outro

Top Comments (10)

@pitaeata8493 2023-07-03

this is great, thank you. it feels good to understand something and be a little closer to understanding machine learning or how to use it properly.

13
@Herakleum 2023-08-24

I take random points from my data as initial centroids, less computations since you only need the set a random integers for indices.

4 3 replies
@martxrrr 2025-11-26

Slowly becoming a Machine Learning Engineer through the knowledge shared by NeuralNine. Thank you G❤

1
@philtoa334 2023-06-25

Thx_.

1
@barcakoseoglu6323 2025-06-09

I don't understand why there's a [0] after we find the means of the points. Don't we need a 1D array, not just a single element?

0 1 replies
@Hickssama 2024-03-17

Thank you sir

0
@arnaldocosta3233 2024-09-23

Thanks!

0
@tcgvsocg1458 2023-06-26

really interesting

0
@linusolmin9313 2024-06-02

Thank you very much!

0
@medmigalexandernaslund 2023-10-11

I'm glad I found this tutorial!

0

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot