Saturday, February 16, 2013

Algorithm Analysis: The Basic K-means Clustering Algorithm

The basic k-means clustering algorithm is a simple algorithm that separates the given data space into different clusters based on centroids calculation using some proximity function. Using this algorithm, we first choose the k- points as initial centroids and then each point is assigned to a cluster with the closest centroid. The algorithm is formally described as follows:
Input: A data set D containing m objects (points) with n attributes in an              Euclidean space
Output: Partitioning of m objects into k-clusters C1, C2, C3, …, Ck, i.e. Ci D and Ci ∩ Cj = ᶲ  (for 1 ≤ i, j ≤ k)


  1. Select k points as initial centroid
  2. Repeat
  3. Form k clusters by assigning each point to its closest centroid
  4.  Re-compute the centroid of each cluster
  5. Until the centroids don’t change

Time Complexity of the algorithm:

 To analyze the complexity of the algorithm in terms of time required, we need to identify the operations required in each step and in each iteration of the algorithm. Here, for k-means algorithm, the operations for each iteration are:
  • Calculation of distances: To calculate the distance from a point to the centroid, we can use the squared Euclidean proximity function. For this, we need two subtractions, one summation, two multiplications and one square - root operations, i.e., 6-operations.
  • Comparisons between distances
  • Calculation of centroids

So, the total number of operations for an iteration
= distance calculation operations + comparison operations + centroids calculation operations
= 6*[k*m*n] operations + [(k-1)*m*n] operations + [k*((m-1) + 1)*n] operations

Assume that the algorithm converges after I iterations, then total number of operations for the algorithm
= 6*[I*k*m*n] operations + [I*(k-1)*m*n] operations + [I*k*((m-1) + 1)*n] operations
= [6Ikmn + I(k-1)mn + Ikmn] operations
≈ O (I*k*m*n)

Here, we’ve applied the basic assumption of each operation requiring the same amount of time. Since, normally, k << m & n << m, the analysis shows that the k-means is linear in m, the number of points, and is scalable and efficient in processing large data sets.

Space Complexity of the Algorithm:

The space requirement for k-means are modest because only the data points and centroids are needed to be stored. Specifically, the storage required is O((m+k)n), where m is the number of objects (points) & n is the number of attributes considering n-dimensional objects.

[1] Vipin Kumar, Pang-Ning Tan & Michael Steinbach.(2005). "Introduction to Data Mining." Pearson/Addison Wesley, ISBN 0-321-32136-7.


  1. Very interesting blog post.Quite informative and very helpful.This indeed is one of the recommended blog for learners.Thank you for providing such nice piece of article. I'm glad to leave a comment. Expect more articles in future. You too can check this R Programming tutorial for updated knowledge on R Programming.

  2. Thank you for sharing such valuable information and tips. This can give insights and inspirations for us; very helpful and informative! Would love to see more updates from you in the future.
    Big Data Training in Chennai
    Big Data Training
    Loadrunner Training in Chennai
    iOS Training in Chennai
    Selenium Training in Chennai
    Selenium Training

  3. I am really enjoying reading your well written articles.
    It looks like you spend a lot of effort and time on your blog.
    I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..
    IELTS Coaching in Chennai
    IELTS Classes in Mumbai
    IELTS Training in Chennai
    IELTS Coaching Centre in Chennai
    IELTS Center in Mumbai
    Best IELTS Coaching in Chennai

  4. Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in.
    Big Data Course in Chennai
    Big Data Hadoop Training in Chennai
    Hadoop Course in Chennai
    best big data training in chennai
    Big Data Hadoop Training
    Hadoop Training in Chennai

  5. Awwsome informative blog ,Very good information thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
    Aviation Academy in Chennai | Aviation Courses in Chennai | Best Aviation Academy in Chennai | Aviation Institute in Chennai | Aviation Training in Chennai

  6. Nice idea,keep sharing your ideas with us.i hope this information's will be helpful for the new learners.
    Best AWS Training in Bangalore
    AWS Training in Nolambur
    AWS Training in Ashok Nagar

  7. More informative,thanks for sharing with us.
    this blog makes the readers more enjoyable.keep add more info on your page.
    angularjs classes in bangalore
    angularjs tutorial in bangalore
    AngularJS Training in Mogappair
    AngularJS Training in Nungambakkam

  8. There was a time when it was difficult with money. I decided to turn to gambling for all kinds of slot machines and the like. Now knowing this site splendid casino games online for money across and opposite to me is no longer scary

  9. Great Article ,Great blog! lot of valid information.
    Keep sharing more.

  10. Great Article ,Great blog! lot of valid information.
    Keep sharing more.
    JAVA Tutorials

  11. This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
    Tableau training in Chennai | Tableau Courses Training in Chennai | Tableau training Institute in Chennai

  12. This comment has been removed by the author.

  13. This comment has been removed by the author.

  14. Great blog thanks for sharing Looking for the best creative agency to fuel new brand ideas? Adhuntt Media is not just a digital marketing company in chennai. We specialize in revamping your brand identity to drive in best traffic that converts.

  15. Excellent blog thanks for sharing Run your salon business successfully by tying up with the best beauty shop in Chennai - The Pixies Beauty Shop. With tons of prestigious brands to choose from, and amazing offers we’ll have you amazed.

  16. Very useful blog thanks for sharing With over a three decade of beauty expertise at our fingertips, we believed that everyone has the right to be beautiful. And so began the journey of our very own Pearl’s Beautician course in Chennai.

  17. Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.

  18. Great information to say the least. I really do appreciate everything so much from this great article.
    qr code generator

  19. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore /

  20. We as a team of real-time industrial experience with a lot of knowledge in developing applications in python programming (7+ years) will ensure that we will deliver our best in python training in vijayawada. , and we believe that no one matches us in this context.

  21. Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing.
    Please check this ExcelR Pune Digital Marketing Course

  22. Thanks for sharing this informations.
    data science course in coimbatore

    data science training in coimbatore

    android training institutes in coimbatore

    ios training in coimbatore

    aws training in coimbatore

    amazon web services training in coimbatore

    big data training in coimbatore

  23. This was really one of my favorite website. Please keep on posting. ExcelR Digital Marketing Course Pune

  24. I really enjoyed your blog Thanks for sharing such an informative post.

    digital marketing course in hubli

  25. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    Big Data Online Training

    Big Data Classes Online

    Big Data Training Online

    Online Big Data Course

    Big Data Course Online

  26. Very interesting blog Thank you for sharing such a nice and interesting blog and really very helpful article.

    Sap Ariba Online Training

    Sap Ariba Classes Online

    Sap Ariba Training Online

    Online Sap Ariba Course

    Sap Ariba Course Online

  27. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression
    data science interview questions

  28. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here....
    hardware and networking training in chennai

    hardware and networking training in tambaram

    xamarin training in chennai

    xamarin training in tambaram

    ios training in chennai

    ios training in tambaram

    iot training in chennai

    iot training in tambaram

  29. Thank you for excellent article.You made an article that is interesting.
    Rajasthan Budget Tours

  30. This article is well formulated. I particularly like the way how you have delivered all the major points about the topic of the content in petite and crisp points.
    Data Science training in Mumbai
    Data Science course in Mumbai
    SAP training in Mumbai

  31. Amazing Post. The content is very interesting. Waiting for your future updates.
    DevOps Training in Chennai

    DevOps Course in Chennai

  32. wonderful article contains lot of valuable information. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    This article resolved my all queries.good luck an best wishes to the team members.continue posting.learn digital marketing use these following link
    Digital Marketing Course in Chennai

  33. Thanks For Sharing The Information The Information Shared Is Very Valuable Please Keep Updating Us Time Just Went On Reading The article
    by cognex is the AWS Training in Chennai. cognex offer so many courses they are microsoft azure, prince2 foundation, ITI V4 foundation,etc,

  34. I pay a visit every day a few blogs and sites to read articles, but this weblog offers feature based writing.
    leather sofa set

  35. I read this article fully on the topic of the resemblance of most recent and
    preceding technologies, it’s remarkable article.

    Study in Ireland Consultants

  36. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Digital Marketing training in Bhilai

  37. Fantastic blog extremely good well enjoyed with the incredible informative content which surely activates the learners to gain the enough knowledge. Which in turn makes the readers to explore themselves and involve deeply in to the subject. Wish you to dispatch the similar content successively in future as well.

    Data Science Training in Raipur

  38. Truly incredible blog found to be very impressive due to which the learners who ever go through it will try to explore themselves with the content to develop the skills to an extreme level. Eventually, thanking the blogger to come up with such an phenomenal content. Hope you arrive with the similar content in future as well.
    Digital Marketing Course in Raipur

  39. Very nice blogs!!! i have to learning for lot of information for this site…Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing,
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

  40. Really good blog. Well-written and knowledgeable blog. Thanks for sharing such a wonderful blog. Keep sharing!
    Data Science Course in Hyderabad

  41. very interesting to read.thanks for sharing .Angular training in Chennai

  42. These are truly fantastic ideas regarding blogging. You have touched on some pleasant points here. Any way keep up writing. Bada Business


  43. I was just examining through the web looking for certain information and ran over your blog.It shows how well you understand this subject. Bookmarked this page, will return for extra. data science course in vadodara

  44. Excellent website. I was always checking this article, and I’m impressed! Extremely useful and valuable info specially the last part, I care for such information a lot. Thanks buddy.
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

  45. Excellent post. I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.
    DevOps Training in Hyderabad
    DevOps Course in Hyderabad

  46. Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.

    Data Science Certification in Bhilai

  47. Extraordinary blog went amazed with the content that they have developed in a very descriptive manner. This type of content surely ensures the participants to explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.

  48. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Data Science Course in Bhilai

  49. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Data Science Training in Bhilai

  50. Thanks for your marvelous posting! I really enjoyed reading it, you could be a great author. I will be sure to bookmark your blog and definitely will come back in the foreseeable future. I want to encourage you to continue your great posts, have a nice afternoon! Best Digital Marketing Courses in Bangalore

  51. Amazing write-up! Really Good.
    Now the foundation of any business is digital marketing. Adsify marketing is the best Digital marketing in Trivandrum.

  52. This post is so helpfull and informative.Keep updating more information....
    RPA Training Cost
    Learn RPA

  53. Really wonderful blog! Thanks for taking your valuable time to share this with us.
    What is AWS
    Benefits Of AWS

  54. I must state that the blog post is really beneficial to anyone else who reads it because the information and knowledge it includes is vital. Continue to provide such useful knowledge through your posts and keep posting more on
    Big Data Solutions
    Business Analytics Services
    Data Modernization Services
    AI Service Provider

  55. Amazing Post. Thanks for sharing. It gives a great insight into the topic. Please keep updating.I also want to share few points about Best MicroNutrients Company in India


  56. Hey friend, it is very well written article, thank you for the valuable and useful information you provide in this post. Keep up the good work! FYI, please check these depression, stress and anxiety related articles.
    Federal Bank Signet Credit Card 2021 Review , The High Five Habit Free pdf Download , Sadhguru Karma Book PDF Download

  57. Thank you so much for sharing this nice article.
    Introducing our Next Level Complete Laundry Management & Dry-Cleaning software. Connect with us to get accelerated and cost-effective Laundry Management Software.
    Visit Now:

  58. Here at this site is really a fastidious material collection so that everybody can enjoy a lot.
    data analytics training in hyderabad

  59. you will need support or suggestions, write me privately.
    I interested in your implementation/use case.
    the best situs slot terbaik
    daftar bo bonanza
    Slot gampang menang

  60. I’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. data scientist course in mysore

  61. Pinnacle Game Profiler Crack is a valuable application that allows you to play many games on your computer through the use of diverse game Pinnacle Game Profiler Windows 10

  62. MEGAsync, you are given a tool to synchronize your PC with your file storage hosted at MEGA. As a cloud service, you may also use it Mega Download Link

  63. They say the best of all gifts around any Christmas tree is the presence of a happy family all wrapped up in each other. Wishing you a very Merry Christmas Christmas MSG To Loved Ones

  64. Such a very useful article. Very interesting to read this article. Join our online English classes in Riyadh, designed specifically for learners in Saudi Arabia who want to improve their spoken English skills.
    For more info visit Best English Speaking Course in Riyadh or Call +971505593798