Skip to main content

A Python library for skew-weighted normalization

Project description

skewnormlib

skewnorm is an open-source Python library designed for preprocessing data using a novel method called Skew Weighted Normalization. This technique accounts for the skewness in data and applies normalization while optionally introducing a non-linear transformation. It is ideal for preparing data for machine learning models that require normalized inputs.


What is SkewWeightedNormalization?

The SkewWeightedNormalization class is a custom data transformer that normalizes data while considering its skewness. It achieves this by combining a skew-adjusted normalization term and a non-linear transformation term, making it more robust for skewed datasets.

Mathematical Formula:

The transformation is defined as:

[ \text{scaled_data} = \frac{X - \mu}{\sigma (1 + \alpha \cdot |\gamma|)} + \beta \cdot \tanh\left(\frac{X - \mu}{k \cdot \sigma}\right) ]

Where:

  • (X): Input data.
  • (\mu): Mean of the data.
  • (\sigma): Standard deviation of the data.
  • (\gamma): Skewness of the data.
  • (\alpha): Skewness weighting factor (default: 1.0).
  • (\beta): Weighting factor for the non-linear transformation (default: 0.5).
  • (k): Scaling factor for the non-linear term (default: 1.0).

How to Use

Installation

Install the library from PyPI:

pip install skewnorm

Usage Example

import numpy as np
from skewnorm.normalization import SkewWeightedNormalization

# Sample data
data = np.array([[1, 2, 3],
                 [4, 5, 6],
                 [7, 8, 9],
                 [10, 20, 30]])

# Initialize the transformer
swn = SkewWeightedNormalization(alpha=1.0, beta=0.5, k=1.0)

# Fit the transformer to the data
swn.fit(data)

# Transform the data
transformed_data = swn.transform(data)
print("Transformed Data:")
print(transformed_data)

Advantages

  • Handles Skewness: Unlike traditional normalization techniques, this method adjusts for skewness, making it suitable for heavily skewed datasets.
  • Non-linear Transformation: The additional (\tanh) term helps reduce the influence of extreme outliers.
  • Scikit-learn Compatible: The class adheres to Scikit-learn's API, allowing seamless integration into pipelines.
  • Open Source: The library is open for contributions, making it a community-driven project.

Disadvantages

  • Complexity: The additional parameters ((\alpha, \beta, k)) require tuning for optimal results.
  • Performance: Slightly slower than standard normalization techniques due to the computation of skewness and the non-linear term.

When to Use It

  • Skewed Data: Use this method when the dataset has significant skewness, as it normalizes while accounting for the skew.
  • Outlier Sensitivity: When datasets contain extreme outliers that might adversely affect models, this normalization technique can help mitigate their influence.
  • Preprocessing for ML: Use this as a preprocessing step for machine learning models that perform better on normalized data (e.g., SVM, Neural Networks).

Contributing

This library is open source, and contributions are welcome! Feel free to:

  1. Submit bug reports.
  2. Suggest new features.
  3. Improve documentation.
  4. Optimize performance.

Visit the GitHub repository to contribute: GitHub Repository


License

This project is licensed under the MIT License, ensuring it remains free and open for everyone.


Contact

For questions or suggestions, contact:

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

skewnormlib-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

skewnormlib-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file skewnormlib-0.1.0.tar.gz.

File metadata

  • Download URL: skewnormlib-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for skewnormlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58715c1c00a7e031ac92d59fe91f0280dd5f2ebdde311817992f8980e6bb6bd7
MD5 44a9bd04ce6f7291f002a84d90b5d922
BLAKE2b-256 c588918c8ddbdd66712159b8c107bd577fae0beba26627ab98866c4a2d966f66

See more details on using hashes here.

File details

Details for the file skewnormlib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: skewnormlib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for skewnormlib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a0b94f709647f6682e65fd62eeb3ab322d2111c48e58e54bed7e572aad30b94
MD5 6871cc15abddacbf8e4433a0dd59af5c
BLAKE2b-256 406430876f0f01930ef5ff1cfd84287122aeb86785e5deb20798c19829f3f925

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