Skip to main content

A lightweight binary image classification system built with scikit‑learn, focusing on k‑Nearest Neighbors (kNN) and classical ML models. It features dynamic, model‑aware image preprocessing (HOG, scaling, PCA) that adapts automatically to image characteristics, enabling efficient training and reliable inference for custom datasets.

Project description

DynamicML 🚀

Dynamic, model‑aware classical machine learning for image classification

CREATED BY SUNKARA SAI GANESH , KARROTHU MOURYA , KUDIRELLA SANMUKA SAI, DONTALA. KIRAN KUMAR.

DynamicML is a lightweight Python library built on top of scikit‑learn that enables binary image classification using classical machine learning models, with a strong focus on dynamic, model‑aware preprocessing. The library is designed to automatically adapt preprocessing pipelines based on image characteristics and model requirements, making it easy to experiment, benchmark, and deploy classical ML solutions for image data. Typically in just 2-4 lines of code.


DynamicML – (Classical ML) Project Overview

This project implements classical machine learning models supported by DynamicML, built on top of scikit-learn.

Instead of deep learning, this system uses:

Image feature extraction (HOG)

Feature scaling (StandardScaler)

Dimensionality reduction (PCA)

Classical ML classifier (Single model at a time)

The goal is to classify images into two classes efficiently using lightweight ML models.

Supported Models (DynamicML)

DynamicML supports most classical classifiers from scikit-learn, including:

🔹 Linear Models

Logistic Regression

SGDClassifier

RidgeClassifier

🔹 Distance-Based Models

k-Nearest Neighbors (kNN)

Radius Neighbors

Nearest Centroid

🔹 Support Vector Machines

Linear SVM

Kernel SVM (RBF, Polynomial, Sigmoid)

🔹 Probabilistic Models

Gaussian Naive Bayes

Multinomial Naive Bayes

Complement Naive Bayes

Bernoulli Naive Bayes

🔹 Tree-Based Models

Decision Tree

Random Forest

Extra Trees

🔹 Boosting & Ensembles

AdaBoost

Gradient Boosting

HistGradientBoosting

Bagging

Voting

Stacking

🔹 Neural & Advanced Models

MLPClassifier

GaussianProcessClassifier

⚠️ Note: In this project, only one model is trained at a time for binary classification.

Dataset Structure dataset/ │ ├── class_0/ │ ├── img1.jpg │ ├── img2.jpg │ └── ... │ └── class_1/ ├── img1.jpg ├── img2.jpg └── ...

Each folder represents one class.

Preprocessing Pipeline

The project uses a classical ML pipeline for image processing:

1️⃣ Image Loading & Resizing

Images are loaded from dataset folders

Converted to grayscale (if required)

Resized to fixed dimensions

2️⃣ Feature Extraction – HOG

We use Histogram of Oriented Gradients (HOG) to extract texture and edge-based features.

Why HOG?

Captures shape & edge information

Works well for classical ML

Reduces need for deep learning

3️⃣ Feature Scaling – StandardScaler

After HOG extraction:

StandardScaler()

Normalizes feature distribution

Improves convergence

Required for SVM, Logistic Regression, MLP, etc.

4️⃣ Dimensionality Reduction – PCA PCA(n_components = k)

Why PCA?

Reduces high-dimensional HOG features

Removes noise

Improves training speed

Prevents overfitting

📊 Train-Test Split train_test_split( test_size=0.2, stratify=y, random_state=42 )

80% Training

20% Testing

Stratified to maintain class balance

⚙️ Model Training

Example (Random Forest):

RandomForestClassifier( n_estimators=100, max_depth=None, random_state=42 )

Steps:

Load dataset

Apply HOG

Scale features

Apply PCA

Train model

Evaluate performance

Save model using joblib

📈 Evaluation Metrics

The model is evaluated using:

✅ Accuracy

✅ Classification Report

✅ Confusion Matrix

Example output:

Accuracy: 0.91

Precision | Recall | F1-score ... 💾 Model Saving

Trained models are saved as:

modelname_timestamp.joblib

Saved bundle includes:

{ "model": trained_model, "label_encoder": label_encoder }

This ensures reproducibility and easy deployment.

🚀 How to Run Step 1: Install Requirements pip install scikit-learn numpy opencv-python scikit-image joblib Step 2: Run Training Scikit_Img_Classif_Supervised.RandomForest_Classifier("dataset_path") 🏗 System Architecture Image Dataset ↓ Preprocessing ↓ HOG Feature Extraction ↓ StandardScaler ↓ PCA ↓ Classifier (Single Model) ↓ Evaluation ↓ Model Saving

🎯 Why Classical ML Instead of CNN?

Lightweight

Faster training

Works well on small datasets

Suitable for hackathons

Easier interpretability

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynamicml-1.0.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamicml-1.0.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file dynamicml-1.0.2.tar.gz.

File metadata

  • Download URL: dynamicml-1.0.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dynamicml-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f5ec8448542ee274b42e7d992543f7613c44756b0ad786d86fdb22185f12b537
MD5 d0281a58ad15b86552fb7c26715faedb
BLAKE2b-256 1b6348e573eeaadf26806c3bc8385279a3d9780092cb647969c1f7cd67cded00

See more details on using hashes here.

File details

Details for the file dynamicml-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: dynamicml-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dynamicml-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6b78d009fbe34fde9312f96b98330f7a1df3e4dc677c306b582aa795a8f7349
MD5 e956766a0f8fc21fd313e108a4cc6ede
BLAKE2b-256 b476f45e9122fe0771ae0c58398671eba2e070be0dced9f77c50d76e7277d4f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page