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.2.1"
current_version = "0.3.0"
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 0.2.0
# 0.3.0

- Adjustable format for the accuracy and other metrics.
- Using the hatchling build system to avoid complains about the `project.license` format.

- Enforce the initial attributes to builtin `ìnt`.

# 0.1.0

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "binary-classification-ratios"
version = "0.2.1"
version = "0.3.0"
description = "Binary classification ratios gathered in one package."
readme = "README.md"
requires-python = ">=3.8,<4.0"
Expand Down
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.2.1'
__version__ = '0.3.0'

from .ratios import BinaryClassificationRatios

Expand Down
12 changes: 6 additions & 6 deletions src/binary_classification_ratios/ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
and summarize classification metrics such as accuracy, precision, recall, and F1-score.
"""

from typing import Dict, Union
from typing import Any, Dict, Union

from binary_classification_ratios.summary import BinaryClassificationSummary

Expand All @@ -19,12 +19,12 @@ class BinaryClassificationRatios(object):
fn: Number of false negatives.
"""

def __init__(self, *, tp: int = 0, tn: int = 0, fp: int = 0, fn: int = 0) -> None:
def __init__(self, *, tp: Any = 0, tn: Any = 0, fp: Any = 0, fn: Any = 0) -> None:
"""Initializes a new instance with all zero values."""
self.tp = tp
self.tn = tn
self.fp = fp
self.fn = fn
self.tp = int(tp)
self.tn = int(tn)
self.fp = int(fp)
self.fn = int(fn)
self.summary = BinaryClassificationSummary()

def get_summary(self) -> str:
Expand Down
11 changes: 10 additions & 1 deletion test/test_ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def bcr() -> BinaryClassificationRatios:
return BinaryClassificationRatios(tp=10, tn=9, fp=8, fn=7)


def test_classification_ratios_init() -> None:
def test_no_args_init() -> None:
"""."""
bcr = BinaryClassificationRatios()
assert bcr.get_f1_score() == pytest.approx(0.0)
Expand All @@ -20,6 +20,15 @@ def test_classification_ratios_init() -> None:
assert bcr.get_accuracy() == pytest.approx(0.0)


def test_convert_to_int() -> None:
"""."""
bcr = BinaryClassificationRatios(tp=10.0, tn=9.0, fp=8.0, fn=7.0)
assert isinstance(bcr.tp, int)
assert isinstance(bcr.tn, int)
assert isinstance(bcr.fp, int)
assert isinstance(bcr.fn, int)


def test_classification_ratios_meaningful(bcr: BinaryClassificationRatios) -> None:
"""."""
assert bcr.get_f1_score() == pytest.approx(0.5714285714285715)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.