Skip to content

corticalstack/LinearSeparability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Linear Separability Visualization

A Python tool for visualizing linear separability concepts using machine learning classifiers on the Wine dataset.

πŸ“ Description

This repository demonstrates the concept of linear separability in machine learning by applying different classification algorithms to the Wine dataset. It visualizes data distributions, decision boundaries, and classification performance metrics to help understand how different algorithms separate data points in feature space.

✨ Features

  • πŸ“Š Data visualization using scatter plots and scatter matrices
  • πŸ”· Convex hull visualization to show class boundaries
  • πŸ” Implementation of multiple classifiers:
    • Perceptron (linear classifier)
    • Support Vector Machine with linear kernel
    • Support Vector Machine with RBF kernel (non-linear)
  • πŸ“ˆ Decision boundary visualization for each classifier
  • πŸ“‰ Confusion matrix generation to evaluate classifier performance

πŸ› οΈ Prerequisites

  • Python 3.6+
  • Required libraries:
    pandas
    numpy
    scikit-learn
    matplotlib
    scipy
    

πŸš€ Usage

  1. Clone the repository:

    git clone https://github.com/corticalstack/LinearSeparability.git
    cd LinearSeparability
  2. Install the required dependencies:

    pip install pandas numpy scikit-learn matplotlib scipy
  3. Run the main script:

    python main.py
  4. Observe the generated visualizations:

    • Scatter matrix of the first 4 features
    • Scatter plot of alcohol vs malic acid features with class coloring
    • Convex hull visualization of class boundaries
    • Decision boundaries and confusion matrices for each classifier

🧩 How It Works

The LinearSeparability class performs the following steps:

  1. Loads the Wine dataset from scikit-learn
  2. Creates visualizations of the dataset features
  3. Implements three different classifiers:
    • Perceptron: A simple linear classifier
    • SVM with linear kernel: A more robust linear classifier
    • SVM with RBF kernel: A non-linear classifier
  4. For each classifier, it:
    • Trains on the first two features (alcohol and malic acid)
    • Visualizes the decision boundary
    • Displays a confusion matrix to evaluate performance

πŸ“š Technical Details

  • The project focuses on binary classification by converting the Wine dataset (which has 3 classes) into a binary problem (class 1 vs. others)
  • The visualization shows how different algorithms create decision boundaries between classes
  • Demonstrates the difference between linear classifiers (Perceptron, linear SVM) and non-linear classifiers (RBF SVM)

πŸ“„ License

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

πŸ”— Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages