Skip to content

Commit f8dd249

Browse files
committed
build: bump version and update __init__.py
1 parent 15feab1 commit f8dd249

File tree

10 files changed

+233
-115
lines changed

10 files changed

+233
-115
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies = [
1515
"statsmodels>=0.14.0",
1616
]
1717
name = "rtichoke"
18-
version = "0.1.25"
18+
version = "0.1.26"
1919
description = "interactive visualizations for performance of predictive models"
2020
readme = "README.md"
2121

src/rtichoke/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from rtichoke.calibration.calibration import (
3434
create_calibration_curve as create_calibration_curve,
35+
create_calibration_curve_times as create_calibration_curve_times,
3536
)
3637

3738
from rtichoke.utility.decision import (
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Subpackage for Calibration
33
"""
4+
45
from .calibration import create_calibration_curve, create_calibration_curve_times
56

67
__all__ = ["create_calibration_curve", "create_calibration_curve_times"]

src/rtichoke/calibration/calibration.py

Lines changed: 157 additions & 72 deletions
Large diffs are not rendered by default.

src/rtichoke/processing/adjustments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import polars as pl
33
from polarstate import predict_aj_estimates
44
from polarstate import prepare_event_table
5-
from typing import Dict
65
from collections.abc import Sequence
6+
from rtichoke.processing.transforms import assign_and_explode_polars
77

88

99
def create_aj_data(

src/rtichoke/processing/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import polars as pl
33
from typing import Dict, Union
4-
from collections.abc import Sequence
4+
from rtichoke.processing.combinations import create_breaks_values
55

66

77
def add_cutoff_strata(data: pl.DataFrame, by: float, stratified_by) -> pl.DataFrame:
@@ -697,4 +697,4 @@ def _turn_cumulative_aj_to_performance_data(
697697
.alias("ppcr"),
698698
)
699699

700-
return performance_data
700+
return performance_data

tests/test_calibration.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
import numpy as np
3-
import polars as pl
42
from rtichoke.calibration.calibration import create_calibration_curve
53

4+
65
def test_create_calibration_curve_smooth():
76
probs = {"model_1": np.linspace(0, 1, 100)}
87
reals = np.random.randint(0, 2, 100)

tests/test_calibration_times.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import pytest
21
import numpy as np
3-
import polars as pl
42
from rtichoke.calibration import create_calibration_curve_times
53

4+
65
def test_create_calibration_curve_times():
76
probs = {"model_1": np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])}
87
reals = np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1])
98
times = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
109
fixed_time_horizons = [5, 10]
11-
heuristics_sets = [{"censoring_heuristic": "excluded", "competing_heuristic": "excluded"}]
10+
heuristics_sets = [
11+
{"censoring_heuristic": "excluded", "competing_heuristic": "excluded"}
12+
]
1213

1314
fig = create_calibration_curve_times(
1415
probs,

tests/test_heuristics.py

Lines changed: 64 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,95 @@
33
from polars.testing import assert_frame_equal
44
from rtichoke.calibration.calibration import _apply_heuristics_and_censoring
55

6+
67
@pytest.fixture
78
def sample_data():
8-
return pl.DataFrame({
9-
"real": [1, 0, 2, 1, 2, 0, 1],
10-
"time": [1, 2, 3, 8, 9, 10, 12],
11-
})
9+
return pl.DataFrame(
10+
{
11+
"real": [1, 0, 2, 1, 2, 0, 1],
12+
"time": [1, 2, 3, 8, 9, 10, 12],
13+
}
14+
)
15+
1216

1317
def test_competing_as_negative_logic(sample_data):
1418
# Heuristics that shouldn't change data before horizon
15-
result = _apply_heuristics_and_censoring(sample_data, 15, "adjusted", "adjusted_as_negative")
19+
result = _apply_heuristics_and_censoring(
20+
sample_data, 15, "adjusted", "adjusted_as_negative"
21+
)
1622
# Competing events at times 3 and 9 should become 0.
17-
expected = pl.DataFrame({
18-
"real": [1, 0, 0, 1, 0, 0, 1],
19-
"time": [1, 2, 3, 8, 9, 10, 12],
20-
})
23+
expected = pl.DataFrame(
24+
{
25+
"real": [1, 0, 0, 1, 0, 0, 1],
26+
"time": [1, 2, 3, 8, 9, 10, 12],
27+
}
28+
)
2129
assert_frame_equal(result, expected)
2230

31+
2332
def test_admin_censoring(sample_data):
24-
result = _apply_heuristics_and_censoring(sample_data, 7, "adjusted", "adjusted_as_negative")
33+
result = _apply_heuristics_and_censoring(
34+
sample_data, 7, "adjusted", "adjusted_as_negative"
35+
)
2536
# Admin censoring for times > 7. Competing event at time=3 becomes 0.
26-
expected = pl.DataFrame({
27-
"real": [1, 0, 0, 0, 0, 0, 0],
28-
"time": [1, 2, 3, 8, 9, 10, 12],
29-
})
37+
expected = pl.DataFrame(
38+
{
39+
"real": [1, 0, 0, 0, 0, 0, 0],
40+
"time": [1, 2, 3, 8, 9, 10, 12],
41+
}
42+
)
3043
assert_frame_equal(result, expected)
3144

45+
3246
def test_censoring_excluded(sample_data):
33-
result = _apply_heuristics_and_censoring(sample_data, 10, "excluded", "adjusted_as_negative")
47+
result = _apply_heuristics_and_censoring(
48+
sample_data, 10, "excluded", "adjusted_as_negative"
49+
)
3450
# Excludes censored at times 2, 10. Admin censors time > 10. Competing at 3,9 -> 0.
35-
expected = pl.DataFrame({
36-
"real": [1, 0, 1, 0, 0],
37-
"time": [1, 3, 8, 9, 12],
38-
})
51+
expected = pl.DataFrame(
52+
{
53+
"real": [1, 0, 1, 0, 0],
54+
"time": [1, 3, 8, 9, 12],
55+
}
56+
)
3957
assert_frame_equal(result.sort("time"), expected.sort("time"))
4058

59+
4160
def test_competing_excluded(sample_data):
4261
result = _apply_heuristics_and_censoring(sample_data, 10, "adjusted", "excluded")
4362
# Excludes competing at 3, 9. Admin censors time > 10.
44-
expected = pl.DataFrame({
45-
"real": [1, 0, 1, 0, 0],
46-
"time": [1, 2, 8, 10, 12],
47-
})
63+
expected = pl.DataFrame(
64+
{
65+
"real": [1, 0, 1, 0, 0],
66+
"time": [1, 2, 8, 10, 12],
67+
}
68+
)
4869
assert_frame_equal(result.sort("time"), expected.sort("time"))
4970

71+
5072
def test_competing_as_negative(sample_data):
51-
result = _apply_heuristics_and_censoring(sample_data, 10, "adjusted", "adjusted_as_negative")
73+
result = _apply_heuristics_and_censoring(
74+
sample_data, 10, "adjusted", "adjusted_as_negative"
75+
)
5276
# Competing at 3,9 -> 0. Admin censors time > 10.
53-
expected = pl.DataFrame({
54-
"real": [1, 0, 0, 1, 0, 0, 0],
55-
"time": [1, 2, 3, 8, 9, 10, 12],
56-
})
77+
expected = pl.DataFrame(
78+
{
79+
"real": [1, 0, 0, 1, 0, 0, 0],
80+
"time": [1, 2, 3, 8, 9, 10, 12],
81+
}
82+
)
5783
assert_frame_equal(result, expected)
5884

85+
5986
def test_competing_as_composite(sample_data):
60-
result = _apply_heuristics_and_censoring(sample_data, 10, "adjusted", "adjusted_as_composite")
87+
result = _apply_heuristics_and_censoring(
88+
sample_data, 10, "adjusted", "adjusted_as_composite"
89+
)
6190
# Competing at 3,9 -> 1. Admin censors time > 10.
62-
expected = pl.DataFrame({
63-
"real": [1, 0, 1, 1, 1, 0, 0],
64-
"time": [1, 2, 3, 8, 9, 10, 12],
65-
})
91+
expected = pl.DataFrame(
92+
{
93+
"real": [1, 0, 1, 1, 1, 0, 0],
94+
"time": [1, 2, 3, 8, 9, 10, 12],
95+
}
96+
)
6697
assert_frame_equal(result, expected)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)