Giter Site home page Giter Site logo

samxx97 / fuzzy-clustering Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 174 KB

An Implementation of fuzzy clustering algorithms in Numpy

License: MIT License

Python 100.00%
fuzzy-cmeans-clustering numpy-library clustering-algorithms vectorized-computation

fuzzy-clustering's Introduction

Fuzzy Clustering

๐Ÿ“– Description

a Numpy vectorized implementation written in Python of some of the fuzzy clustering algorithms, it includes the following:

  • โžค Fuzzy C-Means
  • โžค Gustafason-Kessel

Theoritical General Description of the Fuzzy Algorithm

Fuzzy Clustering is a form of clustering in which each data point can belong to more than one cluster it involves assigning data points to clusters such that items in the same cluster are as similar as possible while items belonging to different clusters are as dissimiliar as possible. Clusters are identified via similarity measures. Different similarity measures may be used, in this implementation the euclidean distance and Mahalanobis distance are used.

Comparison to hard Clustering

in non-fuzzy clustering, data is divided into distinct clusters, where each data point can only belong to exactly one cluster. In Fuzzy clustering, data points can potentially belong to multiple clusters.

The Algorithm:

  1. Initialize Membership Matrix such that values across each center sum to 1
  2. Update the Class Centers Matrix
  3. Calculate the distances of samples from Class Centers
  4. Update Memberships
  5. Repeat step number 2 Until Convergence or reaching maximum number of iterations allowed

๐Ÿ’พ How to Install

before installing the package its highly recommended that you create a virtual environment, there are many tools which are capable of that, such as conda , venv ...etc. here is an example of doing so using virtualenv:

First you install virtualenv

$ pip install virtualenv 

Then create a folder where you can create your environment and cd into it and then execute the following command:

$ virtualenv env 

Now activate the environment

$ \env\Scripts\activate.bat 

To Install the Package from PyPi, install pip then run the following code:

$ pip install Fuzzy_Clustering 

OR if you want to also include dependencies which are necessery for running the examples, you must run the following:(Recommended)

$ pip install Fuzzy_Clustering[examples] 

๐Ÿ“ Usage

You can clone the repository and check into the examples folder, it provides two examples.

The first example demonstrates how one can use fuzzy clustering to segment the color values within an into several distinct groups, in the example below,Fuzzy C-Means was used with a parameterof 10 clusters.

$ python fuzzy_image_segmentation.py 

segmentation results

The second example demonstrates the results of running the algorithm on a set of random scattered data points, the algorithm was run several times with a varying number of clusters parameter.

$ python random_data_clustering.py 

random points clustering

fuzzy-clustering's People

Contributors

samxx97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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