Giter VIP home page Giter VIP logo

k-means-from-scratch's Introduction

K Means Clustering Algorithm Implemented from Scratch

Introduction

K-Means clustering algorithm is implemented from scratch to unveil hidden patterns and insights among the football players featured in FIFA 22.

Feature Selection

a subset of features from the FIFA 22 player dataset are selected because they capture key attributes of football players, such as their current performance, future potential, market value, salary, and age.. These features include "overall," "potential," "wage_eur," "value_eur," and "age."

K means algorithm quick overview

K-Means is an unsupervised machine learning algorithm used for clustering or grouping data points into clusters. It is widely used in data analysis and pattern recognition. The goal of K-Means is to find groups in the data, with the number of groups (clusters) denoted by "K." Here's how it works:

  1. Initialization: Starting by selecting K initial centroids. These centroids are initially chosen randomly from the dataset itself.

  2. Assignment: Assigning each data point to the nearest centroid. This is done by calculating the distance (Eucledian Distance) between each data point and each centroid. The data point is assigned to the cluster associated with the nearest centroid.

    • Eucledian Distance (In case of 2 dimensions)

      $$\sqrt{(x2-x1)^2 + (y2-y2)^2}$$
  3. Re-generate new centroids: Recalculating the centroids of each cluster by taking the geometric mean of all the data points assigned to that cluster.

    • Geometric Mean

      $$\left( x_1 \cdot x_2 \cdot x_3 \cdot \ldots \cdot x_n \right)^{\frac{1}{n}}$$

Repeat: Repeat steps 2, 3 until the new centroids are equal to the old centroids or the maximum number or iterations are reached Result: The final centroids represent the center of each cluster. The data points are clustered based on their proximity to these centroids.

Quick Demonstration

Before Clustering

After Clustering

cluster

Data

You can download the dataset from here https://www.kaggle.com/datasets/stefanoleone992/fifa-22-complete-player-dataset. Use the file players_22.csv

k-means-from-scratch's People

Contributors

sarahishamsaied 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.