Skip to content

Commit 1059656

Browse files
authored
Merge pull request #175 from uriahf/100-create-prepare_performance_data-and-prepare_performance_data_times-functions
feat: close #171
2 parents c3e278f + a12a682 commit 1059656

File tree

7 files changed

+207
-81
lines changed

7 files changed

+207
-81
lines changed

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/.quarto/
2+
3+
**/*.quarto_ipynb

docs/_quarto.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ quartodoc:
1616
package: rtichoke
1717
sidebar: "_sidebar.yml"
1818
sections:
19+
- title: Performance Data
20+
desc: Functions for creating performance data.
21+
contents:
22+
- prepare_performance_data_times
1923
- title: Calibration
2024
desc: Functions for Calibration.
2125
contents:

docs/_sidebar.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ website:
22
sidebar:
33
- contents:
44
- reference/index.qmd
5+
- contents:
6+
- reference/prepare_performance_data_times.qmd
7+
section: Performance Data
58
- contents:
69
- reference/create_calibration_curve.qmd
710
section: Calibration

docs/small_data_example.py

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _():
3232

3333
@app.cell
3434
def _(np, pl):
35-
probs_test = {
35+
probs_dict_test = {
3636
"small_data_set": np.array(
3737
[0.9, 0.85, 0.95, 0.88, 0.6, 0.7, 0.51, 0.2, 0.1, 0.33]
3838
)
@@ -50,7 +50,7 @@ def _(np, pl):
5050
)
5151

5252
data_to_adjust
53-
return probs_test, reals_dict_test, times_dict_test
53+
return probs_dict_test, reals_dict_test, times_dict_test
5454

5555

5656
@app.cell
@@ -60,6 +60,8 @@ def _(create_aj_data_combinations, create_breaks_values):
6060
stratified_by = ["probability_threshold", "ppcr"]
6161
# stratified_by = ["probability_threshold"]
6262

63+
fixed_time_horizons = [10.0, 20.0, 30.0, 40.0, 50.0]
64+
6365
# stratified_by = ["ppcr"]
6466

6567
heuristics_sets = [
@@ -100,7 +102,7 @@ def _(create_aj_data_combinations, create_breaks_values):
100102
aj_data_combinations = create_aj_data_combinations(
101103
["small_data_set"],
102104
heuristics_sets=heuristics_sets,
103-
fixed_time_horizons=[10.0, 20.0, 30.0, 40.0, 50.0],
105+
fixed_time_horizons=fixed_time_horizons,
104106
stratified_by=stratified_by,
105107
by=by,
106108
breaks=breaks,
@@ -110,22 +112,29 @@ def _(create_aj_data_combinations, create_breaks_values):
110112
# aj_data_combinations
111113

112114
aj_data_combinations
113-
return aj_data_combinations, breaks, by, heuristics_sets, stratified_by
115+
return (
116+
aj_data_combinations,
117+
breaks,
118+
by,
119+
fixed_time_horizons,
120+
heuristics_sets,
121+
stratified_by,
122+
)
114123

115124

116125
@app.cell
117126
def _(
118127
aj_data_combinations,
119128
by,
120129
create_list_data_to_adjust,
121-
probs_test,
130+
probs_dict_test,
122131
reals_dict_test,
123132
stratified_by,
124133
times_dict_test,
125134
):
126135
list_data_to_adjust_polars_probability_threshold = create_list_data_to_adjust(
127136
aj_data_combinations,
128-
probs_test,
137+
probs_dict_test,
129138
reals_dict_test,
130139
times_dict_test,
131140
stratified_by=stratified_by,
@@ -140,14 +149,15 @@ def _(
140149
def _(
141150
breaks,
142151
create_adjusted_data,
152+
fixed_time_horizons,
143153
heuristics_sets,
144154
list_data_to_adjust_polars_probability_threshold,
145155
stratified_by,
146156
):
147157
adjusted_data = create_adjusted_data(
148158
list_data_to_adjust_polars_probability_threshold,
149159
heuristics_sets=heuristics_sets,
150-
fixed_time_horizons=[10.0, 20.0, 30.0, 40.0, 50.0],
160+
fixed_time_horizons=fixed_time_horizons,
151161
breaks=breaks,
152162
stratified_by=stratified_by,
153163
# risk_set_scope = ["pooled_by_cutoff"]
@@ -192,7 +202,50 @@ def _(cumulative_aj_data):
192202
return
193203

194204

195-
@app.cell(column=1, hide_code=True)
205+
@app.cell(column=1)
206+
def _():
207+
from rtichoke.performance_data.performance_data_times import (
208+
prepare_performance_data_times,
209+
)
210+
211+
return (prepare_performance_data_times,)
212+
213+
214+
@app.cell
215+
def _(
216+
fixed_time_horizons,
217+
prepare_performance_data_times,
218+
probs_dict_test,
219+
reals_dict_test,
220+
times_dict_test,
221+
):
222+
prepare_performance_data_times(
223+
probs_dict_test, reals_dict_test, times_dict_test, fixed_time_horizons, by=0.1
224+
)
225+
return
226+
227+
228+
@app.cell
229+
def _(np):
230+
probs_dict_test = {
231+
"small_data_set": np.array(
232+
[0.9, 0.85, 0.95, 0.88, 0.6, 0.7, 0.51, 0.2, 0.1, 0.33]
233+
)
234+
}
235+
reals_dict_test = [1, 1, 1, 1, 0, 2, 1, 2, 0, 1]
236+
times_dict_test = [24.1, 9.7, 49.9, 18.6, 34.8, 14.2, 39.2, 46.0, 31.5, 4.3]
237+
238+
fixed_time_horizons = [10.0, 20.0, 30.0, 40.0, 50.0]
239+
240+
return (
241+
fixed_time_horizons,
242+
probs_dict_test,
243+
reals_dict_test,
244+
times_dict_test,
245+
)
246+
247+
248+
@app.cell(column=2, hide_code=True)
196249
def _(mo):
197250
fill_color_radio = mo.ui.radio(
198251
options=["classification_outcome", "reals_labels"],
@@ -275,7 +328,7 @@ def _(mo):
275328
return (competing_heuristic_radio,)
276329

277330

278-
@app.cell(column=2, hide_code=True)
331+
@app.cell(column=3, hide_code=True)
279332
def _(
280333
by,
281334
censoring_heuristic_radio,

src/rtichoke/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
prepare_performance_data as prepare_performance_data,
3232
)
3333

34+
from rtichoke.performance_data.performance_data_times import (
35+
prepare_performance_data_times as prepare_performance_data_times,
36+
)
37+
3438
from rtichoke.summary_report.summary_report import (
3539
create_summary_report as create_summary_report,
3640
)
@@ -48,5 +52,6 @@
4852
"create_decision_curve",
4953
"plot_decision_curve",
5054
"prepare_performance_data",
55+
"prepare_performance_data_times",
5156
"create_summary_report",
5257
]

0 commit comments

Comments
 (0)