Coder Social home page Coder Social logo

parvvaresh / clustering-with-genetic Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 33 KB

This Python script implements a genetic algorithm for clustering data. The algorithm optimizes the cluster assignments of data points using a genetic approach, aiming to improve the silhouette score. The silhouette score is a measure of how well-defined the clusters are in the data.

Python 100.00%
clustering genetic-algorithm python3

clustering-with-genetic's Introduction

Genetic Clustering Algorithm

This Python script implements a genetic algorithm for clustering data. The algorithm optimizes the cluster assignments of data points using a genetic approach, aiming to improve the silhouette score. The silhouette score is a measure of how well-defined the clusters are in the data.

Table of Contents

Getting Started

Prerequisites

  • Python 3
  • Required libraries: numpy, pandas, scikit-learn, matplotlib

Installation

  1. Clone the repository:
https://github.com/parvvaresh/clustering-with-genetic
cd clustering-with-genetic
  1. Install the required dependencies:
pip install -r requirements.txt

Usage

Run the genetic_clustering.py script to execute the genetic clustering algorithm on the provided dataset. Make sure to update the script with your dataset or use the default Iris dataset.

python3 test_iris.py

Algorithm Overview

The genetic clustering algorithm consists of the following components:

Genetic Class

Defines the genetic operations such as mutation, generation, and fitness calculation.

Cluster Class

Manages the clustering process, including the initialization of populations, evolution, and convergence.

Main Script

Utilizes the genetic and clustering classes to run the algorithm on a given dataset.

Parameters

  • size_population: Number of individuals in the population.
  • goal: The desired fitness score to achieve.
  • repeat: Number of generations to run the algorithm.
  • is_mutation: Boolean flag to enable or disable mutation.

Results

The script outputs the progress of the algorithm, including the generation number and the fitness score achieved. Additionally, a plot of the fitness scores over generations is displayed at the end of the execution.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

  • This implementation is inspired by genetic algorithms and clustering techniques.
  • Special thanks to the scikit-learn library for providing the silhouette score metric.

clustering-with-genetic's People

Contributors

parvvaresh avatar

Stargazers

Ali Abdollahian Noghabi avatar Amir Hri avatar  avatar  avatar  avatar S.Hosein Sarafrazi avatar Hossein avatar Amirata Ghaffarian avatar Amir-Abbas Alvand avatar  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.