Skip to main content

A Python library for skew-weighted normalization

Project description

skewnormlib

skewnormlib 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 skewnormlib

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.1.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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: skewnormlib-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2551cab0a2a1aadd4f0cef6044c849c8ffa59ae3cb311c5d612165074660c938
MD5 4c9069eccda9076a87caf1aa88d3f7ae
BLAKE2b-256 2b736326264349e363667cf9d72f5ceba0d222338ce3ae4fc1ca106a9290f3ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skewnormlib-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71c16bb2a19ecb0a852f1ba22c6ae4fae077767b88f56413ab4e701ba90ea3b8
MD5 1830b76aeb2a2fc18484eac0c02ccf3f
BLAKE2b-256 486045f4b4c844a917456ee6fb9a759ae7cde4eb8729cde07ecf9da6a69631b2

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