Skip to main content

Generalized Distance Weighted Discrimination (DWD) with sGS-ADDM

Project description

genDWD: Generalized Distance Weighted Discrimination

genDWD is a high-performance Python implementation of the Generalized Distance Weighted Discrimination (DWD) algorithm.

While Support Vector Machines (SVM) are widely used, they often suffer from the "data piling" phenomenon in HDLSS (High Dimensional Low Sample Size) settings, where many data points project onto the same location on the decision boundary, leading to poor generalization. DWD was specifically developed to overcome this by accounting for the relative distance of all data points, providing better robustness in high-dimensional spaces.

Originally formulated for binary classification, this implementation extends the algorithm's utility by featuring built-in Multiclass classification support, enabling its application to complex, real-world datasets with multiple categories. It is designed to handle these tasks efficiently using the sGS-ADMM framework for large-scale optimization.


Core Research Basis

This implementation is strictly constructed based on the numerical procedures described in the following scientific paper:

"Fast algorithms for large scale generalized distance weighted discrimination"

Xin Yee Lam, J.S. Marron, Defeng Sun, and Kim-Chuan Toh (September 5, 2018)

Key Features

  • Automatic Detection: Automatically switches between Binary and Multiclass (One-vs-One) logic.
  • Adaptive Solvers: Dynamically selects between Cholesky Decomposition, Sherman-Morrison-Woodbury (SMW) formula, or PSQMR based on n (data) and d (features).
  • sGS-ADMM Framework: Ensures fast convergence using Symmetric Gauss-Seidel ADMM.
  • Penalty Tuning: Automatic C parameter calculation using median inter-class distance.

Quick Start

Install the package:

pip install genDWD

Implementation Guide

To use the genDWD class in your project, follow the instructions below. The model follows the standard .fit() and .predict() pattern.

1. Basic Initialization

You can customize the model during initialization. The parameter C=None is recommended as it calculates the penalty based on the dataset's geometry.

from gendwd import genDWD

model = genDWD(C=None)

2. Model Training and Prediction

The model follows the familiar .fit() and .predict() workflow. It automatically handles both binary and multiclass data.

Training the Model

To train the model, pass your feature matrix X and label vector y. The algorithm will automatically detect if it should use a binary or multiclass (One-vs-One) strategy.

Example:
from sklearn.datasets import load_breast_cancer

#Load Breast Cancer Dataset
data = load_breast_cancer()
X, y = data.data, data.target

model.fit(X, y)

y_pred = model.predict(X) 

print(f"Accuracy : {np.mean(y_pred==y)*100} %")

Acknowledgments

This implementation is heavily inspired by the logic and parameters of the DWDLargeR R package. We are grateful to the original authors for their foundational work in efficient DWD algorithms.

We would like to express my sincere gratitude to the following individuals for their invaluable support and guidance during the development of this project:

  • Adilan Widyawan Mahdiyasa, S.Si., M.Si., Ph.D., for the academic guidance, mentorship, and insights into the mathematical foundations of optimization and discrimination algorithms.
  • Ika Widya Palupi, Marshanda Nalurita Serlaloy, Puan Amalia Islamiati, and Radithya Rizky Syandana, my team in this project, for their unwavering support, meaningful discussions, and generous contributions of time and effort throughout the coding, debugging, and testing phases of this project.

Their contributions have been instrumental in making this implementation of the genDWD algorithm possible.

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

gendwd-0.1.4.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

gendwd-0.1.4-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file gendwd-0.1.4.tar.gz.

File metadata

  • Download URL: gendwd-0.1.4.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for gendwd-0.1.4.tar.gz
Algorithm Hash digest
SHA256 292f85a593eebebe43b056b2adaf0f7b8f0218d4dc64345b72f61bfb2a07c0cd
MD5 ccccb919cbf7413a97370238cb829d0f
BLAKE2b-256 9c7ebd35c989f2fcbcbcf386cf50e4eb741b9bc9b761770b5a98ed9b9c3bf60b

See more details on using hashes here.

File details

Details for the file gendwd-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: gendwd-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for gendwd-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0d03572e6fcf396ec6835ab6e28c15132627e084420df002218530870aa833d8
MD5 cf0adb51a4fe3ce0bbd68f32c0879fb5
BLAKE2b-256 48816997c0e14cbd3412d2c29895af11c33aa8b5b483df1be802933ab766c6c3

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