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
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ dependencies = [
"plotly<6.0.0,>=5.13.1",
"pandas>=2.2.3",
"polarstate==0.1.8",
"smoothstate>=0.1.0",
"statsmodels>=0.14.0",
"smoothstate>=0.1.1",
"polars>=1.31.0",
"reactable>=0.1.5",
"great-tables>=0.18.0",
Expand Down
12 changes: 4 additions & 8 deletions src/rtichoke/calibration/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import polars as pl
import numpy as np
from polarstate import predict_aj_estimates, prepare_event_table
from smoothstate import smooth_state_lowess
from ._secondary_cox import calculate_secondary_cox_smooth

# from rtichoke.helpers.send_post_request_to_r_rtichoke import send_requests_to_rtichoke_r
Expand Down Expand Up @@ -757,8 +758,6 @@ def _calculate_smooth_curve(
"""
Calculate the smoothed calibration curve using lowess.
"""
from statsmodels.nonparametric.smoothers_lowess import lowess

smooth_frames = []

# Helper function to process a single probability and real array
Expand All @@ -772,12 +771,9 @@ def process_single_array(p, r, group_name):
}
)
else:
# lowess returns a 2D array where the first column is x and the second is y
smoothed = lowess(r, p, it=0)
xout = np.linspace(0, 1, 101)
yout = np.clip(np.interp(xout, smoothed[:, 0], smoothed[:, 1]), 0.0, 1.0)
return pl.DataFrame(
{"x": xout, "y": yout, "reference_group": [group_name] * len(xout)}
smoothed = smooth_state_lowess(p, r)
return smoothed.with_columns(
pl.lit(group_name).alias("reference_group")
)

if isinstance(reals, dict):
Expand Down
Loading