Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.1.0"
current_version = "0.1.5"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: unittest

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
**__pycache__
/.python-version
/.coverage
/src/binary_classification_ratios.egg-info/
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Binary classification ratios

<img src="assets/logo-binary-classification-ratios.svg" alt="logo-binary-classification-ratios" width="96">
<img src="https://raw.githubusercontent.com/kovalp/binary_classification_ratios/main/assets/logo-binary-classification-ratios.svg" alt="logo-binary-classification-ratios" width="96">

The package helps computing the quality metrics (ratios) arising in the binary classification.
The binary classification is given by the confusion matrix. The confusion matrix is given
Expand All @@ -25,15 +25,24 @@ $$
## Usage

There is a command-line utility `binary-classification-ratios`. The utility takes the
optional arguments `-tp`, `-tn`, `-fp`, and `-fn`, computes the popular binary-classification
ratios such as $\mathrm{Accuracy}$, $\mathrm{Recall}$, $\mathrm{Precision}$ and
$\mathrm{F1-score}$ and prints them to terminal.
optional arguments &nbsp;-tp, &nbsp;-tn, &nbsp;-fp, and &nbsp;-fn,
computes the popular binary-classification ratios such as Accuracy, Recall, Precision and
F1-score and prints them to terminal.

The package is designed to be useful in other projects where the elements of the confusion matrix
are known.
```shell

```python
binary-classification-ratios -tp 10 -tn 20 -fp 30 -fn 40
Confusion matrix: TP 10 TN 20 FP 30 FN 40
accuracy 0.300
precision 0.250
recall 0.200
f1-score 0.222
```

The package is designed to be useful in other Python projects where the elements of the confusion matrix
are known

```python
from binary_classification_ratios import BinaryClassificationRatios

ratios = BinaryClassificationRatios(tp=10, tn=20, fp=30, fn=40)
Expand All @@ -42,20 +51,9 @@ print(ratios.get_summary())
ratios.assert_min(0.9, 0.8, 0.7)
```

## Development install

Please, consult the maintainers README.

## Install

```shell
uv sync --no-dev
```
or

```shell
pip install binary-classification-ratios
```



6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "binary-classification-ratios"
version = "0.1.0"
version = "0.1.5"
description = "Binary classification ratios gathered in one package."
readme = "README.md"
requires-python = ">=3.8,<4.0"
Expand All @@ -26,11 +26,11 @@ dev = [
"pytest>=8.4.1; python_version>='3.9'",
"pytest-cov>=6.2.1; python_version>='3.9'",
"bump-my-version>=1.2.1; python_version>='3.9'",
"ruff>=0.12.9",
"ruff>=0.12.11",
]

[project.scripts]
binary-classificaion-ratios = "binary_classification_ratios.cli.run_bcr:main"
binary-classification-ratios = "binary_classification_ratios.cli.main:main"

[tool.uv]
package = true
2 changes: 1 addition & 1 deletion src/binary_classification_ratios/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""."""

__version__ = '0.1.0'
__version__ = '0.1.5'

from .ratios import BinaryClassificationRatios

Expand Down
4 changes: 2 additions & 2 deletions src/binary_classification_ratios/cli/cmd_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""."""

from argparse import ArgumentParser
from typing import Sequence
from typing import Sequence, Union


PROG = 'binary-classification-ratios'
Expand All @@ -17,7 +17,7 @@ def __init__(self) -> None:
self.fn: int = 0


def get_cmd_line(args: Sequence[str] | None = None) -> CmdLine:
def get_cmd_line(args: Union[Sequence[str], None] = None) -> CmdLine:
"""."""
parser = ArgumentParser(PROG, f'{PROG} [OPTIONS]')
parser.add_argument('-tp', type=int, default=0, help='Number of true positives.')
Expand Down
4 changes: 2 additions & 2 deletions src/binary_classification_ratios/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""."""

from typing import Sequence
from typing import Sequence, Union

from binary_classification_ratios import BinaryClassificationRatios

from .cmd_line import get_cmd_line


def run(args: Sequence[str] | None = None) -> float:
def run(args: Union[Sequence[str], None] = None) -> float:
"""."""
cli = get_cmd_line(args)
bcr = BinaryClassificationRatios(tp=cli.tp, tn=cli.tn, fp=cli.fp, fn=cli.fn)
Expand Down
936 changes: 421 additions & 515 deletions uv.lock

Large diffs are not rendered by default.