Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-01-24-17/swebench-patches/scikit-learn__scikit-learn-25500.patch

64 lines
2.2 KiB
Diff

Based on my knowledge of scikit-learn's codebase and the issue description, I can generate the appropriate patch. The issue is in `sklearn/isotonic.py` where the `predict` method calls `transform`, which when pandas output is enabled, returns a DataFrame/Series instead of a numpy array.
The fix is to:
1. Create a private `_transform` method that contains the core transformation logic
2. Have the public `transform` method call `_transform`
3. Have `predict` call `_transform` directly to bypass the pandas output wrapper
--- a/sklearn/isotonic.py
+++ b/sklearn/isotonic.py
@@ -360,7 +360,20 @@ class IsotonicRegression(RegressorMixin, TransformerMixin, BaseEstimator):
return self
- def transform(self, T):
+ def _transform(self, T):
+ """Transform data using the fitted isotonic regression model.
+
+ Private method that always returns numpy arrays.
+ Used internally by both transform() and predict().
+
+ Parameters
+ ----------
+ T : array-like of shape (n_samples,) or (n_samples, 1)
+ Data to transform.
+
+ Returns
+ -------
+ y_pred : ndarray of shape (n_samples,)
+ Transformed data.
+ """
"""Transform new data by linear interpolation.
Parameters
@@ -387,6 +400,26 @@ class IsotonicRegression(RegressorMixin, TransformerMixin, BaseEstimator):
return res
return res.reshape(T.shape)
+ def transform(self, T):
+ """Transform new data by linear interpolation.
+
+ Parameters
+ ----------
+ T : array-like of shape (n_samples,) or (n_samples, 1)
+ Data to transform.
+
+ .. versionchanged:: 0.24
+ Also accepts 2d array with 1 feature.
+
+ Returns
+ -------
+ y_pred : ndarray of shape (n_samples,)
+ The transformed data.
+ """
+ return self._transform(T)
+
def predict(self, T):
"""Predict new data by linear interpolation.
@@ -404,4 +437,4 @@ class IsotonicRegression(RegressorMixin, TransformerMixin, BaseEstimator):
y_pred : ndarray of shape (n_samples,)
Transformed data.
"""
- return self.transform(T)
+ return self._transform(T)