Skip to main content

PyImbalReg

Pre-processing technics for imbalanced datasets in regression modelling

PyPI version License: GPL v3 Codacy Badge GitHub last commit


Dealing with imbalanced datasets for regression modelling

Your trained regression model has heteroskedasticity problem? Your model can't predict the extreme values very well? Consider using these pre-processing technics for solving these issues probably caused by your imbalanced dataset.

  • RandomOversampling (RO)
  • GaussianNoise and Undersampling (GN)
  • WEighted Relevance-based Combination Strategy (WERCS)

How to use? (2 Minutes read)

  1. Pass your data as a pandas dataframe to any of these technics
  2. Define a releavnce function that maps the output variable to [0, 1] (The higher this value the rarer the samples)
  3. Set a threshold for flagging the samples: rare and normal
  4. Set model-specific parameters
  5. get() a new dataset with new samples

Installation

## Pypi version
pip install PyImbalReg

## GitHub version
pip install git+https://github.com/vd1371/PyImbalReg.git

Example

# importing PyImbalReg
import PyImbalReg as pir

# importing the data
from seaborn import load_dataset
data = load_dataset('dots')

ro = pir.RandomOversampling(data,           # Passing the data
			rel_func = None,    # Default relevance function will be used
			threshold = 0.7,    # Set the threshold
			o_percentage = 5    # ( o_percentage - 1 ) x n_rare_samples will be added 
			)
new_data = ro.get()

Requirements

  1. SciPy
  2. Pandas
  3. Numpy

Other examples

  1. RandomOversampling
  2. GaussianNoise
  3. WERCS

Contributions

Please share your issues, new technics and your contributions with us. Your help is much appreciated in advance.


If you are using this repository

Please cite the below reference(s)

Branco, P., Torgo, L. and Ribeiro, R.P., 2019. Pre-processing approaches for imbalanced distributions in regression. Neurocomputing, 343, pp.76-99.


License

© Vahid Asghari, 2020. Licensed under the General Public License v3.0 (GPLv3).

P.S. Some parts of the readme and codes were inspired from https://github.com/nickkunz/smogn


Release files for PyImbalReg 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyImbalReg 0.0.3
File Size Uploaded
PyImbalReg-0.0.3.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyImbalReg 0.0.3
File Interpreter ABI Platform
PyImbalReg-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / PyImbalReg-0.0.3.tar.gz

Download URL PyImbalReg-0.0.3.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8e92c5038347ee89bfa1b4b35b6d6693fa8fe26d32d3617ba375e7d74f8a5613
BLAKE2b-256 checksum
How to use checksums
47dafcbca942b4df020efd6c5a340e6539db21a3ff5738008f3d3d0a7c1c70c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Release files / PyImbalReg-0.0.3-py3-none-any.whl

Download URL PyImbalReg-0.0.3-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
325746f9f44e80fe6f039ab17d1c2db957dd1b54c7266b712bd2a5281e9af03f
BLAKE2b-256 checksum
How to use checksums
4d696edda09d648c1682c45c69b0db7b5b7481ac8390595238c59bbe879d9777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page