Skip to content

itsumarsoomro/linear-discriminant-analysis-LDA-ML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linear Discriminant Analysis (LDA) - Machine Learning Project

Node.js Express MIT License

Overview

This repository implements Linear Discriminant Analysis (LDA), a machine learning algorithm for dimensionality reduction and classification, using Node.js. LDA projects high-dimensional data onto a lower-dimensional space while maximizing class separation, making it particularly effective for supervised learning tasks.

Features

  • 📊 Implementation of Linear Discriminant Analysis in Node.js
  • 🔍 Dimensionality reduction capabilities
  • 📈 Data visualization tools
  • 🧪 Example datasets with visualizations
  • 📝 Detailed implementation guide

Table of Contents

Prerequisites

  • Node.js 18.x or higher
  • npm (Node Package Manager)

Installation

  1. Clone the repository:
git clone https://github.com/itsumarsoomro/linear-discriminant-analysis-LDA-ML.git
cd linear-discriminant-analysis-LDA-ML
  1. Install dependencies:
npm install
  1. Start the server:
npm start

Project Structure

linear-discriminant-analysis-LDA-ML/
│
├── server.js              # Main application file
├── package.json        # Project dependencies
├── package-lock.json   # Dependency lock file
└── README.md           # Project documentation

Usage

After starting the server, navigate to http://localhost:3000 in your web browser to access the application.

// Sample code from ldaController.js

const performLDA = (data, labels) => { // Calculate class means const classMeans = calculateClassMeans(data, labels);

// Calculate scatter matrices const { withinClassScatter, betweenClassScatter } = calculateScatterMatrices(data, labels, classMeans);

// Calculate eigenvalues and eigenvectors const { eigenvalues, eigenvectors } = calculateEigen(withinClassScatter, betweenClassScatter);

// Project data onto lower dimension const projectedData = projectData(data, eigenvectors);

return projectedData; };

API Routes

POST /api/lda

Performs LDA on the provided dataset.

Request body:

{
  "data": [[1, 2, 3], [4, 5, 6], ...],
  "labels": [0, 1, 0, ...],
  "dimensions": 2
}

Response:

{
  "projectedData": [[1.2, 2.3], [4.5, 5.6], ...],
  "accuracy": 0.95
}

GET /api/results

Retrieves the results of the LDA analysis.

Response:

{
  "originalDimensions": 4,
  "reducedDimensions": 2,
  "classificationAccuracy": 0.95,
  "visualizationUrl": "/images/lda_plot.png"
}

Results

The implementation demonstrates:

  • Successful dimensionality reduction
  • Clear class separation in the projected space
  • High classification accuracy
  • Interactive visualization of results

Results can be viewed in the web interface or accessed via the API endpoints.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

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


Contact

Umar Soomro - @itsumarsoomro

Project Link: https://github.com/itsumarsoomro/linear-discriminant-analysis-LDA-ML

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published