Skip to content

Commit b34b19d

Browse files
authored
Merge pull request #242 from uriahf/232-create-exported-functions-create__curve_times
232 create exported functions create curve times
2 parents 403d1f4 + 91e2043 commit b34b19d

File tree

7 files changed

+495
-90
lines changed

7 files changed

+495
-90
lines changed

src/rtichoke/__init__.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,40 @@
44

55
__version__ = version("rtichoke")
66

7-
from rtichoke.discrimination.roc import create_roc_curve as create_roc_curve
7+
from rtichoke.discrimination.roc import (
8+
create_roc_curve as create_roc_curve,
9+
create_roc_curve_times as create_roc_curve_times,
10+
)
811
from rtichoke.discrimination.roc import plot_roc_curve as plot_roc_curve
912

10-
from rtichoke.discrimination.lift import create_lift_curve as create_lift_curve
13+
from rtichoke.discrimination.lift import (
14+
create_lift_curve as create_lift_curve,
15+
create_lift_curve_times as create_lift_curve_times,
16+
)
1117
from rtichoke.discrimination.lift import plot_lift_curve as plot_lift_curve
1218

1319
from rtichoke.discrimination.precision_recall import (
1420
create_precision_recall_curve as create_precision_recall_curve,
21+
create_precision_recall_curve_times as create_precision_recall_curve_times,
1522
)
1623
from rtichoke.discrimination.precision_recall import (
1724
plot_precision_recall_curve as plot_precision_recall_curve,
1825
)
1926

20-
from rtichoke.discrimination.gains import create_gains_curve as create_gains_curve
27+
from rtichoke.discrimination.gains import (
28+
create_gains_curve as create_gains_curve,
29+
create_gains_curve_times as create_gains_curve_times,
30+
)
2131
from rtichoke.discrimination.gains import plot_gains_curve as plot_gains_curve
2232

2333
# from rtichoke.calibration.calibration import (
2434
# create_calibration_curve as create_calibration_curve,
2535
# )
2636

27-
from rtichoke.utility.decision import create_decision_curve as create_decision_curve
37+
from rtichoke.utility.decision import (
38+
create_decision_curve as create_decision_curve,
39+
create_decision_curve_times as create_decision_curve_times,
40+
)
2841
from rtichoke.utility.decision import plot_decision_curve as plot_decision_curve
2942

3043
from rtichoke.performance_data.performance_data import (

src/rtichoke/discrimination/gains.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, List, Sequence, Union
66
from plotly.graph_objs._figure import Figure
77
from rtichoke.helpers.plotly_helper_functions import (
8+
_create_rtichoke_plotly_curve_times,
89
_create_rtichoke_plotly_curve_binary,
910
_plot_rtichoke_curve_binary,
1011
)
@@ -123,3 +124,58 @@ def plot_gains_curve(
123124
curve="gains",
124125
)
125126
return fig
127+
128+
129+
def create_gains_curve_times(
130+
probs: Dict[str, np.ndarray],
131+
reals: Union[np.ndarray, Dict[str, np.ndarray]],
132+
times: Union[np.ndarray, Dict[str, np.ndarray]],
133+
fixed_time_horizons: list[float],
134+
heuristics_sets: list[Dict] = [
135+
{
136+
"censoring_heuristic": "adjusted",
137+
"competing_heuristic": "adjusted_as_negative",
138+
}
139+
],
140+
by: float = 0.01,
141+
stratified_by: Sequence[str] = ["probability_threshold"],
142+
size: int = 600,
143+
color_values: List[str] = [
144+
"#1b9e77",
145+
"#d95f02",
146+
"#7570b3",
147+
"#e7298a",
148+
"#07004D",
149+
"#E6AB02",
150+
"#FE5F55",
151+
"#54494B",
152+
"#006E90",
153+
"#BC96E6",
154+
"#52050A",
155+
"#1F271B",
156+
"#BE7C4D",
157+
"#63768D",
158+
"#08A045",
159+
"#320A28",
160+
"#82FF9E",
161+
"#2176FF",
162+
"#D1603D",
163+
"#585123",
164+
],
165+
) -> Figure:
166+
"""Create time-dependent Lift Curve."""
167+
168+
fig = _create_rtichoke_plotly_curve_times(
169+
probs,
170+
reals,
171+
times,
172+
fixed_time_horizons=fixed_time_horizons,
173+
heuristics_sets=heuristics_sets,
174+
by=by,
175+
stratified_by=stratified_by,
176+
size=size,
177+
color_values=color_values,
178+
curve="gains",
179+
)
180+
181+
return fig

src/rtichoke/discrimination/lift.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, List, Sequence, Union
66
from plotly.graph_objs._figure import Figure
77
from rtichoke.helpers.plotly_helper_functions import (
8+
_create_rtichoke_plotly_curve_times,
89
_create_rtichoke_plotly_curve_binary,
910
_plot_rtichoke_curve_binary,
1011
)
@@ -123,3 +124,58 @@ def plot_lift_curve(
123124
curve="lift",
124125
)
125126
return fig
127+
128+
129+
def create_lift_curve_times(
130+
probs: Dict[str, np.ndarray],
131+
reals: Union[np.ndarray, Dict[str, np.ndarray]],
132+
times: Union[np.ndarray, Dict[str, np.ndarray]],
133+
fixed_time_horizons: list[float],
134+
heuristics_sets: list[Dict] = [
135+
{
136+
"censoring_heuristic": "adjusted",
137+
"competing_heuristic": "adjusted_as_negative",
138+
}
139+
],
140+
by: float = 0.01,
141+
stratified_by: Sequence[str] = ["probability_threshold"],
142+
size: int = 600,
143+
color_values: List[str] = [
144+
"#1b9e77",
145+
"#d95f02",
146+
"#7570b3",
147+
"#e7298a",
148+
"#07004D",
149+
"#E6AB02",
150+
"#FE5F55",
151+
"#54494B",
152+
"#006E90",
153+
"#BC96E6",
154+
"#52050A",
155+
"#1F271B",
156+
"#BE7C4D",
157+
"#63768D",
158+
"#08A045",
159+
"#320A28",
160+
"#82FF9E",
161+
"#2176FF",
162+
"#D1603D",
163+
"#585123",
164+
],
165+
) -> Figure:
166+
"""Create time-dependent Lift Curve."""
167+
168+
fig = _create_rtichoke_plotly_curve_times(
169+
probs,
170+
reals,
171+
times,
172+
fixed_time_horizons=fixed_time_horizons,
173+
heuristics_sets=heuristics_sets,
174+
by=by,
175+
stratified_by=stratified_by,
176+
size=size,
177+
color_values=color_values,
178+
curve="lift",
179+
)
180+
181+
return fig

src/rtichoke/discrimination/precision_recall.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, List, Sequence, Union
66
from plotly.graph_objs._figure import Figure
77
from rtichoke.helpers.plotly_helper_functions import (
8+
_create_rtichoke_plotly_curve_times,
89
_create_rtichoke_plotly_curve_binary,
910
_plot_rtichoke_curve_binary,
1011
)
@@ -123,3 +124,58 @@ def plot_precision_recall_curve(
123124
curve="precision recall",
124125
)
125126
return fig
127+
128+
129+
def create_precision_recall_curve_times(
130+
probs: Dict[str, np.ndarray],
131+
reals: Union[np.ndarray, Dict[str, np.ndarray]],
132+
times: Union[np.ndarray, Dict[str, np.ndarray]],
133+
fixed_time_horizons: list[float],
134+
heuristics_sets: list[Dict] = [
135+
{
136+
"censoring_heuristic": "adjusted",
137+
"competing_heuristic": "adjusted_as_negative",
138+
}
139+
],
140+
by: float = 0.01,
141+
stratified_by: Sequence[str] = ["probability_threshold"],
142+
size: int = 600,
143+
color_values: List[str] = [
144+
"#1b9e77",
145+
"#d95f02",
146+
"#7570b3",
147+
"#e7298a",
148+
"#07004D",
149+
"#E6AB02",
150+
"#FE5F55",
151+
"#54494B",
152+
"#006E90",
153+
"#BC96E6",
154+
"#52050A",
155+
"#1F271B",
156+
"#BE7C4D",
157+
"#63768D",
158+
"#08A045",
159+
"#320A28",
160+
"#82FF9E",
161+
"#2176FF",
162+
"#D1603D",
163+
"#585123",
164+
],
165+
) -> Figure:
166+
"""Create time-dependent Lift Curve."""
167+
168+
fig = _create_rtichoke_plotly_curve_times(
169+
probs,
170+
reals,
171+
times,
172+
fixed_time_horizons=fixed_time_horizons,
173+
heuristics_sets=heuristics_sets,
174+
by=by,
175+
stratified_by=stratified_by,
176+
size=size,
177+
color_values=color_values,
178+
curve="precision recall",
179+
)
180+
181+
return fig

src/rtichoke/discrimination/roc.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, List, Union, Sequence
66
from plotly.graph_objs._figure import Figure
77
from rtichoke.helpers.plotly_helper_functions import (
8+
_create_rtichoke_plotly_curve_times,
89
_create_rtichoke_plotly_curve_binary,
910
_plot_rtichoke_curve_binary,
1011
)
@@ -124,3 +125,58 @@ def plot_roc_curve(
124125
)
125126

126127
return fig
128+
129+
130+
def create_roc_curve_times(
131+
probs: Dict[str, np.ndarray],
132+
reals: Union[np.ndarray, Dict[str, np.ndarray]],
133+
times: Union[np.ndarray, Dict[str, np.ndarray]],
134+
fixed_time_horizons: list[float],
135+
heuristics_sets: list[Dict] = [
136+
{
137+
"censoring_heuristic": "adjusted",
138+
"competing_heuristic": "adjusted_as_negative",
139+
}
140+
],
141+
by: float = 0.01,
142+
stratified_by: Sequence[str] = ["probability_threshold"],
143+
size: int = 600,
144+
color_values: List[str] = [
145+
"#1b9e77",
146+
"#d95f02",
147+
"#7570b3",
148+
"#e7298a",
149+
"#07004D",
150+
"#E6AB02",
151+
"#FE5F55",
152+
"#54494B",
153+
"#006E90",
154+
"#BC96E6",
155+
"#52050A",
156+
"#1F271B",
157+
"#BE7C4D",
158+
"#63768D",
159+
"#08A045",
160+
"#320A28",
161+
"#82FF9E",
162+
"#2176FF",
163+
"#D1603D",
164+
"#585123",
165+
],
166+
) -> Figure:
167+
"""Create time-dependent Lift Curve."""
168+
169+
fig = _create_rtichoke_plotly_curve_times(
170+
probs,
171+
reals,
172+
times,
173+
fixed_time_horizons=fixed_time_horizons,
174+
heuristics_sets=heuristics_sets,
175+
by=by,
176+
stratified_by=stratified_by,
177+
size=size,
178+
color_values=color_values,
179+
curve="roc",
180+
)
181+
182+
return fig

0 commit comments

Comments
 (0)