Skip to main content

A package for cost-sensitive multiclass classification that increases the sensitivity of important classes by shifting the decision boundary between them according to a prioritization vector.

Project description

SVMargin

Version: 1.4
License: MIT License
Author: Eran Kaufman
Email: erankfmn@gmail.com

Overview

SVMmargin is a Python package designed to address the problem of imbalanced data and cost-sensitive multiclass classification using TensorFlow for GPU acceleration. The package enhances the sensitivity of critical classes by adjusting the decision boundary between them according to a class weight vector. This enables a tighter error bound for high-priority classes while minimizing the overall out-of-sample error across all classes.

The package supports multiple kernel methods, including linear, RBF, and polynomial kernels, implemented with TensorFlow for efficient computation. It is optimized for modern GPU architectures, making it suitable for large-scale datasets. Additionally, SVMmargin incorporates mechanisms for flexible regularization and robust handling of class imbalances, improving classification performance in real-world scenarios.

Features

  • Imbalanced Classification: Adjusts the imbalance of classes based on their inverse size.
  • Cost-Sensitive Classification: Adjusts the sensitivity of classes based on their importance.
  • Apportioned Margin Framework: Efficiently shifts decision boundaries according to a prioritization vector.
  • Support for Multiple Kernels: Includes linear, RBF, and polynomial kernels.
  • TensorFlow Integration for Performance: Optimized with TensorFlow, enabling large-scale training on GPUs for faster and more efficient processing of complex datasets.
  • Fisher Consistency: Ensures the consistency of the classifier.
  • Generalization Bounds: Provides theoretical guarantees on performance.

Installation

You can install the package directly from PyPI using pip:

pip install SVMargin

Usage

For full examples and detailed use cases, refer to the SVMargin notebook on Kaggle:

https://www.kaggle.com/code/amitronen1/svmargin

Available Kernels

  • Linear Kernel: linear
  • RBF Kernel: rbf
  • Polynomial Kernel: poly

You can select the kernel by specifying the kernel parameter when creating an instance of ImbalancedSVM.

Class Weights

The class_weight parameter allows you to assign different importance to different classes. It accepts a dictionary where keys are class labels, and values are the corresponding weights.

Examples

Here are a few usage examples:

Linear Kernel Example

cls = ImbalancedSVM(kernel='linear', class_weight={0: 10, 1: 1}, gamma=0.5, C=1, verbose= True)
cls.fit(X, y, max_iter=30)
predictions = cls.predict(X_test)

RBF Kernel Example

cls = ImbalancedSVM(kernel='rbf', gamma=0.5, class_weight={0: 1, 1: 10}, gamma=0.5, C=1, verbose= True)
cls.fit(X, y, max_iter=30)
predictions = cls.predict(X_test)

License

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

References

If you would like to learn more about the theoretical background and the research behind this package, please refer to the following article: Please cite this article when using this package!

  • Apportioned Margin Approach for Cost Sensitive Large Margin Classifiers
    Gottlieb, LA., Kaufman, E. & Kontorovich, A. Apportioned margin approach for cost sensitive large margin classifiers. Ann Math Artif Intell 89, 1215–1235 (2021). https://doi.org/10.1007/s10472-021-09776-w

Contact

If you have any questions or suggestions, feel free to reach out at erankfmn@gmail.com.

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

svmargin-1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

SVMargin-1.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file svmargin-1.4.tar.gz.

File metadata

  • Download URL: svmargin-1.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for svmargin-1.4.tar.gz
Algorithm Hash digest
SHA256 394725b58b01eca88efab8e08933c4477870434fbeab0dfca83be86b50723d4b
MD5 51015286feb171bf0a3f3beec1290f08
BLAKE2b-256 302d15639103915004a07166b7d482f37a141f781539c8994594d084fd093334

See more details on using hashes here.

File details

Details for the file SVMargin-1.4-py3-none-any.whl.

File metadata

  • Download URL: SVMargin-1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for SVMargin-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 292d48a8e69d909732632845e3115dd400532120c61901da67e1a5e638d56b59
MD5 44a6fd1a29aadbc588a89c8838ae9ac8
BLAKE2b-256 18fa209b9f27f278b6faea678e34e24f0728e6bf041b33af128da95542cea644

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