The imbalanced regression method DenseWeight
Project description
DenseWeight
This package implements the method for imbalanced regression DenseWeight. The corresponding paper "Density-based weighting for imbalanced regression" is accepted for publication and will soon be available.
The goal of DenseWeight is to allow training machine learning models for regression tasks that emphasize performance for data points with rare target values in comparison to data points with more common target values. This can be useful when rare samples are of particular interest e.g. when estimating precipitation and you are interested in estimating rare, extreme precipitation events as well as possible. The parameter alpha controls the intensity of the density-based weighting scheme (alpha = 0.0 -> uniform weighting; larger alpha -> more emphasis on rare samples).
DenseWeight judges the rarity of a target value based on its density, which is obtained through Kernel Density Estimation (KDE). This package uses the fast convolutional-based KDE implementation FFTKDE from KDEpy to allow the application of DenseWeight for large datasets.
Installation
DenseWeight is available at PyPI and can be installed via pip:
pip install denseweight
Usage
import numpy as np
from denseweight import DenseWeight
# Create toy target variable with 1000 samples
y = np.random.normal(size=1000)
# Define DenseWeight
dw = DenseWeight(alpha=1.0)
# Fit DenseWeight and get the weights for the 1000 samples
weights = dw.fit(y)
# Calculate the weight for an arbitrary target value
weights = dw([0.1206])
These weights can be used as sample weights for machine learning algorithms which support them. They can also be easily integrated into loss function for models like Neural Networks to create a cost-sensitive learning solution to data imbalance in regression tasks which we call DenseLoss (more details on this in the paper).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file denseweight-0.1.0.tar.gz
.
File metadata
- Download URL: denseweight-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1f61ec321408a00236c21dbb970df3c8ccd0cdcd2c3fc15be7a63b03507442d |
|
MD5 | 74cb2e705fae638c6d4a49f6c5ce331a |
|
BLAKE2b-256 | dac4e2d63471641b71a9290b7d98ccb240e73b3c67fc7dc76790659d9bce954d |
File details
Details for the file denseweight-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: denseweight-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9ccb28aa6f5456fc88957c996e27938f5f606aa1e0a804ed5b59f60569abe1c |
|
MD5 | 89cc1b8319c2b7e3e79a7e18cc807801 |
|
BLAKE2b-256 | 1cab6525849444a00628b918b0096362d11fdcb28931ad01ccade9913e967300 |
File details
Details for the file denseweight-0.1.0-1-py3-none-any.whl
.
File metadata
- Download URL: denseweight-0.1.0-1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5adb64aa293293a333a0b5c15a1e15fe66f18c67f1603e4f739edd33b7832d0 |
|
MD5 | 48da21249af033ba1962e6a30eba2703 |
|
BLAKE2b-256 | df6bb49f16191b2f8bf35d764ff0784867bd66f55e100a2817541086b8e0c554 |