Skip to main content

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 available here.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

denseweight-0.1.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

denseweight-0.1.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: denseweight-0.1.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for denseweight-0.1.1.tar.gz
Algorithm Hash digest
SHA256 384e45e72c6f09949b7c6017c0623e697bc9bae73102afcbbade9d3575f129d4
MD5 20abd31890ff7b0007cc965fbe40a93b
BLAKE2b-256 4409cb9dcac8bc44e7df570da43539ca1192972afd53235d408cea0de6c78640

See more details on using hashes here.

File details

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

File metadata

  • Download URL: denseweight-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for denseweight-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9832036e0dcfe0c32541f49c289389d053c558de4eb0ea9395989f1502113403
MD5 a8175da8156df9dc838b92ca000869d8
BLAKE2b-256 ecbfdd370c4fc95ebe2c2a24feb6141c83d55752443151eb7ee74542d3b5c44b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page