Skip to main content

H-Measure Classification Metric

Project description

README

Description

A Python translation of the R package hmeasure (GitHub) (CRAN).

Installation

To install the hmeasure library use pip:

pip install hmeasure

or install directly from source:

python setup.py install

Usage

>>> import numpy
>>> from hmeasure import h_score
>>> rng = numpy.random.default_rng(66)
>>> y_true = rng.integers(low=0, high=2, size=10)
>>> y_true
array([1, 1, 0, 1, 1, 0, 1, 1, 1, 0])
>>> # y_pred random sampled in interval [0, 1)
>>> y_pred = (1 - 0) * rng.random(10) + 0
>>> y_pred
array([0.84901876, 0.10282827, 0.43752488, 0.46004468, 0.90878931,
...    0.79177719, 0.5297229 , 0.13803906, 0.73166264, 0.22959056])
>>> h_score(y_true, y_pred)
0.18889596344769588
>>> n1, n0 = y_true.sum(), y_true.shape[0]-y_true.sum()
>>> h_score(y_true, y_pred, severity_ratio=(n1/n0))
0.18889596344769588
>>> h_score(y_true, y_pred, severity_ratio=0.7)
0.13502616807120948
>>> h_score(y_true, y_pred, severity_ratio=-0.7)
0.18310946512079307
>>> h_score(y_true, y_pred, severity_ratio=0.1)
0.001212529211507385
>>> h_score(y_true, y_pred, severity_ratio=0.5)
0.10750123502531805

Questions and comments

In case of questions or comments, write an email:
ldanov@users.noreply.github.com

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

hmeasure-0.1.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

hmeasure-0.1.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file hmeasure-0.1.6.tar.gz.

File metadata

  • Download URL: hmeasure-0.1.6.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for hmeasure-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f7df10d13730bdff49e9afadf2c8459889025e5c9198ac7223321227394f1000
MD5 fc1011550a9338e33e4945552eb5903f
BLAKE2b-256 498501ee89217dd79f1cc114a022e283e5eedf9fe65bf126c426833a616b3a6f

See more details on using hashes here.

File details

Details for the file hmeasure-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: hmeasure-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for hmeasure-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4020536e35221edf111776814a514284d63d4819734f8b113102420c9d803aa9
MD5 dda976f4fa1806b8bb69095134a61960
BLAKE2b-256 e9388ebeead1b701c3a106b73ef6a2dd3519877c5c0431e1d161561aa850ba45

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