Coder Social home page Coder Social logo

kmeans's Introduction

๐Ÿค– KMeans

KMeans is a popular unsupervised machine learning algorithm used for clustering data points into groups or clusters based on their similarity. Building your own version of KMeans is an excellent way to deepen your understanding of the algorithm and improve your skills in machine learning.

๐Ÿง  Algorithm (traning)

The algorithm follows these steps:

  1. Define the number of clusters: KMeans requires you to specify the number of clusters in advance. You can choose any number of clusters based on your data and problem domain.
  2. Initialize centroids: Choose K points at random from the dataset to serve as the initial centroids for each cluster.
  3. Assign data points to clusters: For each data point, calculate its distance from each centroid and assign it to the closest cluster.
  4. Update centroids: Calculate the mean of all the points assigned to each cluster and set the centroid of that cluster to the mean.
  5. Repeat steps 3-4 until convergence: Keep repeating steps 3-4 until the centroids stop changing or a maximum number of iterations is reached.

โœ”๏ธ Metrics

After the execution we can evaluate the quality of the clusters using metrics such as within-cluster sum of squares or silhouette score.

๐Ÿฆพ Improvements

You can also consider adding some variations to the basic KMeans algorithm, such as using different distance metrics, using more advanced initialization methods, or implementing parallelization for faster performance on large datasets.

๐Ÿ‘ฉโ€๐Ÿซ Example

Notebook with a little example.

kmeans's People

Contributors

franciscosanchezoliver avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.