Coder Social home page Coder Social logo

devasena37 / psoclustering Goto Github PK

View Code? Open in Web Editor NEW

This project forked from niloofarshahbaz/psoclustering

0.0 0.0 0.0 42 KB

This is an implementation of clustering IRIS dataset with particle swarm optimization(PSO)

License: Apache License 2.0

Python 100.00%

psoclustering's Introduction

PSOClustering

This is an implementation of clustering data with particle swarm optimization(PSO) algorithm

This implementation is inspired by the following paper : Data Clustering using Particle Swarm Optimization

The dataset used in this implementation is the IRIS flower dataset but this can surely work with other datasets too!

Run

after installing the requirements run main.py. you can choose to plot the point with matplotlib by changing the variable plot at the top of the code.

However be aware that this will only keep the first 2 dimensions of the dataset points and other dimensions will not be considered.

Other than the number of clusters (n_clusters) and the number of particles (n_particles) you can choose whether to use kmeans for seeding the initial swarm( called Hybrid PSO Clustering) or not ( with hybrid variable). You can also change the pso algorithm parameters w, c1 and c2.

Usage

will need pso_clustering.py and particle.py.

from pso_clustering import PSOClusteringSwarm

# data should be a numpy array of n-dimensional points

pso = PSOClusteringSwarm(n_clusters=3, n_particles=10, data=data_points, hybrid=True, w=0.72, c1=1.49, c2=1.49)

clusters, global_best_fitness = pso.start(iteration=1000)

The function start() will return a tuple of the final clusters (for each data point has the cluster id) and the final value of the global best fitness of the swarm.

psoclustering's People

Contributors

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