@@ -34,6 +34,7 @@ def _decision_curve_v2_spec_from_performance_data(
3434 * ,
3535 min_p_threshold : float = 0.0 ,
3636 max_p_threshold : float = 1.0 ,
37+ operating_point_dimension : str | None = "probability_threshold" ,
3738) -> dict [str , object ]:
3839 """Build canonical static Decision Curve v2 from production quantities."""
3940 missing = _REQUIRED_COLUMNS .difference (performance_data .columns )
@@ -163,7 +164,7 @@ def _decision_curve_v2_spec_from_performance_data(
163164 }
164165 )
165166
166- return {
167+ spec = {
167168 "schemaVersion" : "2.0" ,
168169 "type" : "decision_curve" ,
169170 "evaluations" : evaluations ,
@@ -178,6 +179,13 @@ def _decision_curve_v2_spec_from_performance_data(
178179 "yAxis" : {"label" : "Net benefit" },
179180 "references" : references ,
180181 }
182+ if operating_point_dimension is not None :
183+ if operating_point_dimension not in {"probability_threshold" , "ppcr" }:
184+ raise ValueError (
185+ f"Invalid operating_point_dimension: { operating_point_dimension !r} ."
186+ )
187+ spec ["operatingPoint" ] = {"dimension" : operating_point_dimension }
188+ return spec
181189
182190
183191def _decision_curve_times_v2_spec_from_performance_data (
@@ -186,6 +194,7 @@ def _decision_curve_times_v2_spec_from_performance_data(
186194 * ,
187195 min_p_threshold : float = 0.0 ,
188196 max_p_threshold : float = 1.0 ,
197+ operating_point_dimension : str | None = "probability_threshold" ,
189198) -> dict [str , object ]:
190199 """Build canonical time-dependent Decision Curve v2 from production quantities."""
191200 missing = _REQUIRED_TIMES_COLUMNS .difference (performance_data .columns )
@@ -372,7 +381,7 @@ def _decision_curve_times_v2_spec_from_performance_data(
372381 }
373382 )
374383
375- return {
384+ spec = {
376385 "schemaVersion" : "2.0" ,
377386 "type" : "decision_curve" ,
378387 "evaluations" : evaluations ,
@@ -387,3 +396,10 @@ def _decision_curve_times_v2_spec_from_performance_data(
387396 "yAxis" : {"label" : "Net benefit" },
388397 "references" : references ,
389398 }
399+ if operating_point_dimension is not None :
400+ if operating_point_dimension not in {"probability_threshold" , "ppcr" }:
401+ raise ValueError (
402+ f"Invalid operating_point_dimension: { operating_point_dimension !r} ."
403+ )
404+ spec ["operatingPoint" ] = {"dimension" : operating_point_dimension }
405+ return spec
0 commit comments