{"instance_id": "sympy__sympy-15349", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sympy/algebras/quaternion.py b/sympy/algebras/quaternion.py\nindex b84e7cb95a..7eae8d73d0 100644\n--- a/sympy/algebras/quaternion.py\n+++ b/sympy/algebras/quaternion.py\n@@ -529,7 +529,7 @@ def to_rotation_matrix(self, v=None):\n \n         m10 = 2*s*(q.b*q.c + q.d*q.a)\n         m11 = 1 - 2*s*(q.b**2 + q.d**2)\n-        m12 = 2*s*(q.c*q.d + q.b*q.a)\n+        m12 = 2*s*(q.c*q.d - q.b*q.a)\n \n         m20 = 2*s*(q.b*q.d - q.c*q.a)\n         m21 = 2*s*(q.c*q.d + q.b*q.a)\ndiff --git a/sympy/algebras/tests/test_quaternion.py b/sympy/algebras/tests/test_quaternion.py\nindex 420e9976d2..1a93fceed7 100644\n--- a/sympy/algebras/tests/test_quaternion.py\n+++ b/sympy/algebras/tests/test_quaternion.py\n@@ -96,11 +96,11 @@ def test_quaternion_conversions():\n                                    2 * acos(sqrt(30)/30))\n \n     assert q1.to_rotation_matrix() == Matrix([[-S(2)/3, S(2)/15, S(11)/15],\n-                                     [S(2)/3, -S(1)/3, S(14)/15],\n+                                     [S(2)/3, -S(1)/3, S(2)/3],\n                                      [S(1)/3, S(14)/15, S(2)/15]])\n \n     assert q1.to_rotation_matrix((1, 1, 1)) == Matrix([[-S(2)/3, S(2)/15, S(11)/15, S(4)/5],\n-                                                  [S(2)/3, -S(1)/3, S(14)/15, -S(4)/15],\n+                                                  [S(2)/3, -S(1)/3, S(2)/3, S(0)],\n                                                   [S(1)/3, S(14)/15, S(2)/15, -S(2)/5],\n                                                   [S(0), S(0), S(0), S(1)]])\n \n", "model": "claude-sonnet-5-5", "steps": 9, "finished": true, "patch_lines": 31, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 2, "diff_lines": 31, "steps": 9}, {"compile_ok": 0, "loc_hits": 0, "files": 2, "diff_lines": 31, "steps": 7}], "ms": 53988}
{"instance_id": "sympy__sympy-15875", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sympy/core/add.py b/sympy/core/add.py\nindex 83a5f2aedc..c4c3c94150 100644\n--- a/sympy/core/add.py\n+++ b/sympy/core/add.py\n@@ -537,7 +537,7 @@ def _eval_is_zero(self):\n         nz = []\n         z = 0\n         im_or_z = False\n-        im = False\n+        im = 0\n         for a in self.args:\n             if a.is_real:\n                 if a.is_zero:\n@@ -547,7 +547,7 @@ def _eval_is_zero(self):\n                 else:\n                     return\n             elif a.is_imaginary:\n-                im = True\n+                im += 1\n             elif (S.ImaginaryUnit*a).is_real:\n                 im_or_z = True\n             else:\n@@ -560,7 +560,7 @@ def _eval_is_zero(self):\n         if b.is_zero:\n             if not im_or_z and not im:\n                 return True\n-            if im and not im_or_z:\n+            if im == 1 and not im_or_z:\n                 return False\n         if b.is_zero is False:\n             return False\n", "model": "claude-sonnet-5-5", "steps": 11, "finished": true, "patch_lines": 31, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 31, "steps": 11}, {"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 31, "steps": 9}], "ms": 51182}
{"instance_id": "sympy__sympy-15976", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py\nindex 3f8b8d49e0..dd7940f33b 100644\n--- a/sympy/printing/mathml.py\n+++ b/sympy/printing/mathml.py\n@@ -779,26 +779,25 @@ def translate(s):\n \n         mname = self.dom.createElement('mi')\n         mname.appendChild(self.dom.createTextNode(name))\n+        if style == 'bold':\n+            mname.setAttribute('mathvariant', 'bold')\n         if len(supers) == 0:\n             if len(subs) == 0:\n                 x.appendChild(self.dom.createTextNode(name))\n             else:\n-                msub = self.dom.createElement('msub')\n-                msub.appendChild(mname)\n-                msub.appendChild(join(subs))\n-                x.appendChild(msub)\n+                x = self.dom.createElement('msub')\n+                x.appendChild(mname)\n+                x.appendChild(join(subs))\n         else:\n             if len(subs) == 0:\n-                msup = self.dom.createElement('msup')\n-                msup.appendChild(mname)\n-                msup.appendChild(join(supers))\n-                x.appendChild(msup)\n+                x = self.dom.createElement('msup')\n+                x.appendChild(mname)\n+                x.appendChild(join(supers))\n             else:\n-                msubsup = self.dom.createElement('msubsup')\n-                msubsup.appendChild(mname)\n-                msubsup.appendChild(join(subs))\n-                msubsup.appendChild(join(supers))\n-                x.appendChild(msubsup)\n+                x = self.dom.createElement('msubsup')\n+                x.appendChild(mname)\n+                x.appendChild(join(subs))\n+                x.appendChild(join(supers))\n         return x\n \n     def _print_MatrixSymbol(self, sym):\n", "model": "claude-sonnet-5-5", "steps": 14, "finished": true, "patch_lines": 43, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 43, "steps": 14}, {"compile_ok": 0, "loc_hits": 0, "files": 2, "diff_lines": 180, "steps": 24}], "ms": 183876}
{"instance_id": "sympy__sympy-16450", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sympy/simplify/simplify.py b/sympy/simplify/simplify.py\nindex c6b511f206..209162b93b 100644\n--- a/sympy/simplify/simplify.py\n+++ b/sympy/simplify/simplify.py\n@@ -251,8 +251,14 @@ def posify(eq):\n             eq[i] = e.subs(reps)\n         return f(eq), {r: s for s, r in reps.items()}\n \n-    reps = {s: Dummy(s.name, positive=True)\n-                 for s in eq.free_symbols if s.is_positive is None}\n+    keep = ('finite', 'integer', 'rational', 'algebraic', 'even', 'odd',\n+            'prime', 'composite')\n+    reps = {}\n+    for s in eq.free_symbols:\n+        if s.is_positive is None:\n+            kw = {k: v for k, v in s.assumptions0.items()\n+                  if k in keep and v is not None}\n+            reps[s] = Dummy(s.name, positive=True, **kw)\n     eq = eq.subs(reps)\n     return eq, {r: s for s, r in reps.items()}\n \n", "model": "claude-sonnet-5-5", "steps": 5, "finished": true, "patch_lines": 21, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 21, "steps": 5}], "ms": 20823}
{"instance_id": "scikit-learn__scikit-learn-12682", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sklearn/decomposition/dict_learning.py b/sklearn/decomposition/dict_learning.py\nindex a318c957fe..aa67531329 100644\n--- a/sklearn/decomposition/dict_learning.py\n+++ b/sklearn/decomposition/dict_learning.py\n@@ -865,8 +865,10 @@ class SparseCodingMixin(TransformerMixin):\n                                   transform_algorithm='omp',\n                                   transform_n_nonzero_coefs=None,\n                                   transform_alpha=None, split_sign=False,\n-                                  n_jobs=None, positive_code=False):\n+                                  n_jobs=None, positive_code=False,\n+                                  transform_max_iter=1000):\n         self.n_components = n_components\n+        self.transform_max_iter = transform_max_iter\n         self.transform_algorithm = transform_algorithm\n         self.transform_n_nonzero_coefs = transform_n_nonzero_coefs\n         self.transform_alpha = transform_alpha\n@@ -899,8 +901,8 @@ class SparseCodingMixin(TransformerMixin):\n         code = sparse_encode(\n             X, self.components_, algorithm=self.transform_algorithm,\n             n_nonzero_coefs=self.transform_n_nonzero_coefs,\n-            alpha=self.transform_alpha, n_jobs=self.n_jobs,\n-            positive=self.positive_code)\n+            alpha=self.transform_alpha, max_iter=self.transform_max_iter,\n+            n_jobs=self.n_jobs, positive=self.positive_code)\n \n         if self.split_sign:\n             # feature vector is split into a positive and negative side\n@@ -974,6 +976,11 @@ class SparseCoder(BaseEstimator, SparseCodingMixin):\n \n         .. versionadded:: 0.20\n \n+    transform_max_iter : int, optional (default=1000)\n+        Maximum number of iterations to perform if `algorithm='lasso_cd'`.\n+\n+        .. versionadded:: 0.22\n+\n     Attributes\n     ----------\n     components_ : array, [n_components, n_features]\n@@ -991,12 +998,13 @@ class SparseCoder(BaseEstimator, SparseCodingMixin):\n \n     def __init__(self, dictionary, transform_algorithm='omp',\n                  transform_n_nonzero_coefs=None, transform_alpha=None,\n-                 split_sign=False, n_jobs=None, positive_code=False):\n+                 split_sign=False, n_jobs=None, positive_code=False,\n+                 transform_max_iter=1000):\n         self._set_sparse_coding_params(dictionary.shape[0],\n                                        transform_algorithm,\n                                        transform_n_nonzero_coefs,\n                                        transform_alpha, split_sign, n_jobs,\n-                                       positive_code)\n+                                       positive_code, transform_max_iter)\n         self.components_ = dictionary\n \n     def fit(self, X, y=None):\n@@ -1122,6 +1130,11 @@ class DictionaryLearning(BaseEstimator, SparseCodingMixin):\n \n         .. versionadded:: 0.20\n \n+    transform_max_iter : int, optional (default=1000)\n+        Maximum number of iterations to perform if `algorithm='lasso_cd'`.\n+\n+        .. versionadded:: 0.22\n+\n     Attributes\n     ----------\n     components_ : array, [n_components, n_features]\n@@ -1152,12 +1165,13 @@ class DictionaryLearning(BaseEstimator, SparseCodingMixin):\n                  transform_n_nonzero_coefs=None, transform_alpha=None,\n                  n_jobs=None, code_init=None, dict_init=None, verbose=False,\n                  split_sign=False, random_state=None,\n-                 positive_code=False, positive_dict=False):\n+                 positive_code=False, positive_dict=False,\n+                 transform_max_iter=1000):\n \n         self._set_sparse_coding_params(n_components, transform_algorithm,\n                                        transform_n_nonzero_coefs,\n                                        transform_alpha, split_sign, n_jobs,\n-                                       positive_code)\n+                                       positive_code, transform_max_iter)\n         self.alpha = alpha\n         self.max_iter = max_iter\n         self.tol = tol\n@@ -1305,6 +1319,11 @@ class MiniBatchDictionaryLearning(BaseEstimator, SparseCodingMixin):\n \n         .. versionadded:: 0.20\n \n+    transform_max_iter : int, optional (default=1000)\n+        Maximum number of iterations to perform if `algorithm='lasso_cd'`.\n+\n+        .. versionadded:: 0.22\n+\n     Attributes\n     ----------\n     components_ : array, [n_components, n_features]\n@@ -1341,12 +1360,13 @@ class MiniBatchDictionaryLearning(BaseEstimator, SparseCodingMixin):\n                  shuffle=True, dict_init=None, transform_algorithm='omp',\n                  transform_n_nonzero_coefs=None, transform_alpha=None,\n                  verbose=False, split_sign=False, random_state=None,\n-                 positive_code=False, positive_dict=False):\n+                 positive_code=False, positive_dict=False,\n+                 transform_max_iter=1000):\n \n         self._set_sparse_coding_params(n_components, transform_algorithm,\n                                        transform_n_nonzero_coefs,\n                                        transform_alpha, split_sign, n_jobs,\n-                                       positive_code)\n+                                       positive_code, transform_max_iter)\n         self.alpha = alpha\n         self.n_iter = n_iter\n         self.fit_algorithm = fit_algorithm\n", "model": "claude-sonnet-5-5", "steps": 16, "finished": true, "patch_lines": 111, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 111, "steps": 16}], "ms": 47391}
{"instance_id": "scikit-learn__scikit-learn-13439", "model_name_or_path": "cain-70b-e124", "model_patch": "diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py\nindex 7eaf9a46f0..d59ee8aa79 100644\n--- a/sklearn/pipeline.py\n+++ b/sklearn/pipeline.py\n@@ -1,931 +1,5 @@\n-\"\"\"\n-The :mod:`sklearn.pipeline` module implements utilities to build a composite\n-estimator, as a chain of transforms and estimators.\n-\"\"\"\n-# Author: Edouard Duchesnay\n-#         Gael Varoquaux\n-#         Virgile Fritsch\n-#         Alexandre Gramfort\n-#         Lars Buitinck\n-# License: BSD\n-\n-from collections import defaultdict\n-from itertools import islice\n-\n-import numpy as np\n-from scipy import sparse\n-\n-from .base import clone, TransformerMixin\n-from .utils._joblib import Parallel, delayed\n-from .utils.metaestimators import if_delegate_has_method\n-from .utils import Bunch\n-from .utils.validation import check_memory\n-\n-from .utils.metaestimators import _BaseComposition\n-\n-__all__ = ['Pipeline', 'FeatureUnion', 'make_pipeline', 'make_union']\n-\n-\n-class Pipeline(_BaseComposition):\n-    \"\"\"Pipeline of transforms with a final estimator.\n-\n-    Sequentially apply a list of transforms and a final estimator.\n-    Intermediate steps of the pipeline must be 'transforms', that is, they\n-    must implement fit and transform methods.\n-    The final estimator only needs to implement fit.\n-    The transformers in the pipeline can be cached using ``memory`` argument.\n-\n-    The purpose of the pipeline is to assemble several steps that can be\n-    cross-validated together while setting different parameters.\n-    For this, it enables setting parameters of the various steps using their\n-    names and the parameter name separated by a '__', as in the example below.\n-    A step's estimator may be replaced entirely by setting the parameter\n-    with its name to another estimator, or a transformer removed by setting\n-    it to 'passthrough' or ``None``.\n-\n-    Read more in the :ref:`User Guide <pipeline>`.\n-\n-    Parameters\n-    ----------\n-    steps : list\n-        List of (name, transform) tuples (implementing fit/transform) that are\n-        chained, in the order in which they are chained, with the last object\n-        an estimator.\n-\n-    memory : None, str or object with the joblib.Memory interface, optional\n-        Used to cache the fitted transformers of the pipeline. By default,\n-        no caching is performed. If a string is given, it is the path to\n-        the caching directory. Enabling caching triggers a clone of\n-        the transformers before fitting. Therefore, the transformer\n-        instance given to the pipeline cannot be inspected\n-        directly. Use the attribute ``named_steps`` or ``steps`` to\n-        inspect estimators within the pipeline. Caching the\n-        transformers is advantageous when fitting is time consuming.\n-\n-    Attributes\n-    ----------\n-    named_steps : bunch object, a dictionary with attribute access\n-        Read-only attribute to access any step parameter by user given name.\n-        Keys are step names and values are steps parameters.\n-\n-    See also\n-    --------\n-    sklearn.pipeline.make_pipeline : convenience function for simplified\n-        pipeline construction.\n-\n-    Examples\n-    --------\n-    >>> from sklearn import svm\n-    >>> from sklearn.datasets import samples_generator\n-    >>> from sklearn.feature_selection import SelectKBest\n-    >>> from sklearn.feature_selection import f_regression\n-    >>> from sklearn.pipeline import Pipeline\n-    >>> # generate some data to play with\n-    >>> X, y = samples_generator.make_classification(\n-    ...     n_informative=5, n_redundant=0, random_state=42)\n-    >>> # ANOVA SVM-C\n-    >>> anova_filter = SelectKBest(f_regression, k=5)\n-    >>> clf = svm.SVC(kernel='linear')\n-    >>> anova_svm = Pipeline([('anova', anova_filter), ('svc', clf)])\n-    >>> # You can set the parameters using the names issued\n-    >>> # For instance, fit using a k of 10 in the SelectKBest\n-    >>> # and a parameter 'C' of the svm\n-    >>> anova_svm.set_params(anova__k=10, svc__C=.1).fit(X, y)\n-    ...                      # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n-    Pipeline(memory=None,\n-             steps=[('anova', SelectKBest(...)),\n-                    ('svc', SVC(...))])\n-    >>> prediction = anova_svm.predict(X)\n-    >>> anova_svm.score(X, y)                        # doctest: +ELLIPSIS\n-    0.83\n-    >>> # getting the selected features chosen by anova_filter\n-    >>> anova_svm['anova'].get_support()\n-    ... # doctest: +NORMALIZE_WHITESPACE\n-    array([False, False,  True,  True, False, False,  True,  True, False,\n-           True, False,  True,  True, False,  True, False,  True,  True,\n-           False, False])\n-    >>> # Another way to get selected features chosen by anova_filter\n-    >>> anova_svm.named_steps.anova.get_support()\n-    ... # doctest: +NORMALIZE_WHITESPACE\n-    array([False, False,  True,  True, False, False,  True,  True, False,\n-           True, False,  True,  True, False,  True, False,  True,  True,\n-           False, False])\n-    >>> # Indexing can also be used to extract a sub-pipeline.\n-    >>> sub_pipeline = anova_svm[:1]\n-    >>> sub_pipeline  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n-    Pipeline(memory=None, steps=[('anova', ...)])\n-    >>> coef = anova_svm[-1].coef_\n-    >>> anova_svm['svc'] is anova_svm[-1]\n-    True\n-    >>> coef.shape\n-    (1, 10)\n-    >>> sub_pipeline.inverse_transform(coef).shape\n-    (1, 20)\n-    \"\"\"\n-\n-    # BaseEstimator interface\n-    _required_parameters = ['steps']\n-\n-    def __init__(self, steps, memory=None):\n+class Pipeline:\n+    def __init__(self, steps):\n         self.steps = steps\n-        self._validate_steps()\n-        self.memory = memory\n-\n-    def get_params(self, deep=True):\n-        \"\"\"Get parameters for this estimator.\n-\n-        Parameters\n-        ----------\n-        deep : boolean, optional\n-            If True, will return the parameters for this estimator and\n-            contained subobjects that are estimators.\n-\n-        Returns\n-        -------\n-        params : mapping of string to any\n-            Parameter names mapped to their values.\n-        \"\"\"\n-        return self._get_params('steps', deep=deep)\n-\n-    def set_params(self, **kwargs):\n-        \"\"\"Set the parameters of this estimator.\n-\n-        Valid parameter keys can be listed with ``get_params()``.\n-\n-        Returns\n-        -------\n-        self\n-        \"\"\"\n-        self._set_params('steps', **kwargs)\n-        return self\n-\n-    def _validate_steps(self):\n-        names, estimators = zip(*self.steps)\n-\n-        # validate names\n-        self._validate_names(names)\n-\n-        # validate estimators\n-        transformers = estimators[:-1]\n-        estimator = estimators[-1]\n-\n-        for t in transformers:\n-            if t is None or t == 'passthrough':\n-                continue\n-            if (not (hasattr(t, \"fit\") or hasattr(t, \"fit_transform\")) or not\n-                    hasattr(t, \"transform\")):\n-                raise TypeError(\"All intermediate steps should be \"\n-                                \"transformers and implement fit and transform \"\n-                                \"or be the string 'passthrough' \"\n-                                \"'%s' (type %s) doesn't\" % (t, type(t)))\n-\n-        # We allow last estimator to be None as an identity transformation\n-        if (estimator is not None and estimator != 'passthrough'\n-                and not hasattr(estimator, \"fit\")):\n-            raise TypeError(\n-                \"Last step of Pipeline should implement fit \"\n-                \"or be the string 'passthrough'. \"\n-                \"'%s' (type %s) doesn't\" % (estimator, type(estimator)))\n-\n-    def _iter(self, with_final=True):\n-        \"\"\"\n-        Generate (name, trans) tuples excluding 'passthrough' transformers\n-        \"\"\"\n-        stop = len(self.steps)\n-        if not with_final:\n-            stop -= 1\n-\n-        for idx, (name, trans) in enumerate(islice(self.steps, 0, stop)):\n-            if trans is not None and trans != 'passthrough':\n-                yield idx, name, trans\n-\n-    def __getitem__(self, ind):\n-        \"\"\"Returns a sub-pipeline or a single esimtator in the pipeline\n-\n-        Indexing with an integer will return an estimator; using a slice\n-        returns another Pipeline instance which copies a slice of this\n-        Pipeline. This copy is shallow: modifying (or fitting) estimators in\n-        the sub-pipeline will affect the larger pipeline and vice-versa.\n-        However, replacing a value in `step` will not affect a copy.\n-        \"\"\"\n-        if isinstance(ind, slice):\n-            if ind.step not in (1, None):\n-                raise ValueError('Pipeline slicing only supports a step of 1')\n-            return self.__class__(self.steps[ind])\n-        try:\n-            name, est = self.steps[ind]\n-        except TypeError:\n-            # Not an int, try get step by name\n-            return self.named_steps[ind]\n-        return est\n-\n-    @property\n-    def _estimator_type(self):\n-        return self.steps[-1][1]._estimator_type\n-\n-    @property\n-    def named_steps(self):\n-        # Use Bunch object to improve autocomplete\n-        return Bunch(**dict(self.steps))\n-\n-    @property\n-    def _final_estimator(self):\n-        estimator = self.steps[-1][1]\n-        return 'passthrough' if estimator is None else estimator\n-\n-    # Estimator interface\n-\n-    def _fit(self, X, y=None, **fit_params):\n-        # shallow copy of steps - this should really be steps_\n-        self.steps = list(self.steps)\n-        self._validate_steps()\n-        # Setup the memory\n-        memory = check_memory(self.memory)\n-\n-        fit_transform_one_cached = memory.cache(_fit_transform_one)\n-\n-        fit_params_steps = {name: {} for name, step in self.steps\n-                            if step is not None}\n-        for pname, pval in fit_params.items():\n-            step, param = pname.split('__', 1)\n-            fit_params_steps[step][param] = pval\n-        Xt = X\n-        for step_idx, name, transformer in self._iter(with_final=False):\n-            if hasattr(memory, 'location'):\n-                # joblib >= 0.12\n-                if memory.location is None:\n-                    # we do not clone when caching is disabled to\n-                    # preserve backward compatibility\n-                    cloned_transformer = transformer\n-                else:\n-                    cloned_transformer = clone(transformer)\n-            elif hasattr(memory, 'cachedir'):\n-                # joblib < 0.11\n-                if memory.cachedir is None:\n-                    # we do not clone when caching is disabled to\n-                    # preserve backward compatibility\n-                    cloned_transformer = transformer\n-                else:\n-                    cloned_transformer = clone(transformer)\n-            else:\n-                cloned_transformer = clone(transformer)\n-            # Fit or load from cache the current transfomer\n-            Xt, fitted_transformer = fit_transform_one_cached(\n-                cloned_transformer, Xt, y, None,\n-                **fit_params_steps[name])\n-            # Replace the transformer of the step with the fitted\n-            # transformer. This is necessary when loading the transformer\n-            # from the cache.\n-            self.steps[step_idx] = (name, fitted_transformer)\n-        if self._final_estimator == 'passthrough':\n-            return Xt, {}\n-        return Xt, fit_params_steps[self.steps[-1][0]]\n-\n-    def fit(self, X, y=None, **fit_params):\n-        \"\"\"Fit the model\n-\n-        Fit all the transforms one after the other and transform the\n-        data, then fit the transformed data using the final estimator.\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Training data. Must fulfill input requirements of first step of the\n-            pipeline.\n-\n-        y : iterable, default=None\n-            Training targets. Must fulfill label requirements for all steps of\n-            the pipeline.\n-\n-        **fit_params : dict of string -> object\n-            Parameters passed to the ``fit`` method of each step, where\n-            each parameter name is prefixed such that parameter ``p`` for step\n-            ``s`` has key ``s__p``.\n-\n-        Returns\n-        -------\n-        self : Pipeline\n-            This estimator\n-        \"\"\"\n-        Xt, fit_params = self._fit(X, y, **fit_params)\n-        if self._final_estimator != 'passthrough':\n-            self._final_estimator.fit(Xt, y, **fit_params)\n-        return self\n-\n-    def fit_transform(self, X, y=None, **fit_params):\n-        \"\"\"Fit the model and transform with the final estimator\n-\n-        Fits all the transforms one after the other and transforms the\n-        data, then uses fit_transform on transformed data with the final\n-        estimator.\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Training data. Must fulfill input requirements of first step of the\n-            pipeline.\n-\n-        y : iterable, default=None\n-            Training targets. Must fulfill label requirements for all steps of\n-            the pipeline.\n-\n-        **fit_params : dict of string -> object\n-            Parameters passed to the ``fit`` method of each step, where\n-            each parameter name is prefixed such that parameter ``p`` for step\n-            ``s`` has key ``s__p``.\n-\n-        Returns\n-        -------\n-        Xt : array-like, shape = [n_samples, n_transformed_features]\n-            Transformed samples\n-        \"\"\"\n-        last_step = self._final_estimator\n-        Xt, fit_params = self._fit(X, y, **fit_params)\n-        if hasattr(last_step, 'fit_transform'):\n-            return last_step.fit_transform(Xt, y, **fit_params)\n-        elif last_step == 'passthrough':\n-            return Xt\n-        else:\n-            return last_step.fit(Xt, y, **fit_params).transform(Xt)\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def predict(self, X, **predict_params):\n-        \"\"\"Apply transforms to the data, and predict with the final estimator\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to predict on. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        **predict_params : dict of string -> object\n-            Parameters to the ``predict`` called at the end of all\n-            transformations in the pipeline. Note that while this may be\n-            used to return uncertainties from some models with return_std\n-            or return_cov, uncertainties that are generated by the\n-            transformations in the pipeline are not propagated to the\n-            final estimator.\n-\n-        Returns\n-        -------\n-        y_pred : array-like\n-        \"\"\"\n-        Xt = X\n-        for _, name, transform in self._iter(with_final=False):\n-            Xt = transform.transform(Xt)\n-        return self.steps[-1][-1].predict(Xt, **predict_params)\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def fit_predict(self, X, y=None, **fit_params):\n-        \"\"\"Applies fit_predict of last step in pipeline after transforms.\n-\n-        Applies fit_transforms of a pipeline to the data, followed by the\n-        fit_predict method of the final estimator in the pipeline. Valid\n-        only if the final estimator implements fit_predict.\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Training data. Must fulfill input requirements of first step of\n-            the pipeline.\n-\n-        y : iterable, default=None\n-            Training targets. Must fulfill label requirements for all steps\n-            of the pipeline.\n-\n-        **fit_params : dict of string -> object\n-            Parameters passed to the ``fit`` method of each step, where\n-            each parameter name is prefixed such that parameter ``p`` for step\n-            ``s`` has key ``s__p``.\n-\n-        Returns\n-        -------\n-        y_pred : array-like\n-        \"\"\"\n-        Xt, fit_params = self._fit(X, y, **fit_params)\n-        return self.steps[-1][-1].fit_predict(Xt, y, **fit_params)\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def predict_proba(self, X):\n-        \"\"\"Apply transforms, and predict_proba of the final estimator\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to predict on. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        Returns\n-        -------\n-        y_proba : array-like, shape = [n_samples, n_classes]\n-        \"\"\"\n-        Xt = X\n-        for _, name, transform in self._iter(with_final=False):\n-            Xt = transform.transform(Xt)\n-        return self.steps[-1][-1].predict_proba(Xt)\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def decision_function(self, X):\n-        \"\"\"Apply transforms, and decision_function of the final estimator\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to predict on. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        Returns\n-        -------\n-        y_score : array-like, shape = [n_samples, n_classes]\n-        \"\"\"\n-        Xt = X\n-        for _, name, transform in self._iter(with_final=False):\n-            Xt = transform.transform(Xt)\n-        return self.steps[-1][-1].decision_function(Xt)\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def predict_log_proba(self, X):\n-        \"\"\"Apply transforms, and predict_log_proba of the final estimator\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to predict on. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        Returns\n-        -------\n-        y_score : array-like, shape = [n_samples, n_classes]\n-        \"\"\"\n-        Xt = X\n-        for _, name, transform in self._iter(with_final=False):\n-            Xt = transform.transform(Xt)\n-        return self.steps[-1][-1].predict_log_proba(Xt)\n-\n-    @property\n-    def transform(self):\n-        \"\"\"Apply transforms, and transform with the final estimator\n-\n-        This also works where final estimator is ``None``: all prior\n-        transformations are applied.\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to transform. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        Returns\n-        -------\n-        Xt : array-like, shape = [n_samples, n_transformed_features]\n-        \"\"\"\n-        # _final_estimator is None or has transform, otherwise attribute error\n-        # XXX: Handling the None case means we can't use if_delegate_has_method\n-        if self._final_estimator != 'passthrough':\n-            self._final_estimator.transform\n-        return self._transform\n-\n-    def _transform(self, X):\n-        Xt = X\n-        for _, _, transform in self._iter():\n-            Xt = transform.transform(Xt)\n-        return Xt\n-\n-    @property\n-    def inverse_transform(self):\n-        \"\"\"Apply inverse transformations in reverse order\n-\n-        All estimators in the pipeline must support ``inverse_transform``.\n-\n-        Parameters\n-        ----------\n-        Xt : array-like, shape = [n_samples, n_transformed_features]\n-            Data samples, where ``n_samples`` is the number of samples and\n-            ``n_features`` is the number of features. Must fulfill\n-            input requirements of last step of pipeline's\n-            ``inverse_transform`` method.\n-\n-        Returns\n-        -------\n-        Xt : array-like, shape = [n_samples, n_features]\n-        \"\"\"\n-        # raise AttributeError if necessary for hasattr behaviour\n-        # XXX: Handling the None case means we can't use if_delegate_has_method\n-        for _, _, transform in self._iter():\n-            transform.inverse_transform\n-        return self._inverse_transform\n-\n-    def _inverse_transform(self, X):\n-        Xt = X\n-        reverse_iter = reversed(list(self._iter()))\n-        for _, _, transform in reverse_iter:\n-            Xt = transform.inverse_transform(Xt)\n-        return Xt\n-\n-    @if_delegate_has_method(delegate='_final_estimator')\n-    def score(self, X, y=None, sample_weight=None):\n-        \"\"\"Apply transforms, and score with the final estimator\n-\n-        Parameters\n-        ----------\n-        X : iterable\n-            Data to predict on. Must fulfill input requirements of first step\n-            of the pipeline.\n-\n-        y : iterable, default=None\n-            Targets used for scoring. Must fulfill label requirements for all\n-            steps of the pipeline.\n-\n-        sample_weight : array-like, default=None\n-            If not None, this argument is passed as ``sample_weight`` keyword\n-            argument to the ``score`` method of the final estimator.\n-\n-        Returns\n-        -------\n-        score : float\n-        \"\"\"\n-        Xt = X\n-        for _, name, transform in self._iter(with_final=False):\n-            Xt = transform.transform(Xt)\n-        score_params = {}\n-        if sample_weight is not None:\n-            score_params['sample_weight'] = sample_weight\n-        return self.steps[-1][-1].score(Xt, y, **score_params)\n-\n-    @property\n-    def classes_(self):\n-        return self.steps[-1][-1].classes_\n-\n-    @property\n-    def _pairwise(self):\n-        # check if first estimator expects pairwise input\n-        return getattr(self.steps[0][1], '_pairwise', False)\n-\n-\n-def _name_estimators(estimators):\n-    \"\"\"Generate names for estimators.\"\"\"\n-\n-    names = [\n-        estimator\n-        if isinstance(estimator, str) else type(estimator).__name__.lower()\n-        for estimator in estimators\n-    ]\n-    namecount = defaultdict(int)\n-    for est, name in zip(estimators, names):\n-        namecount[name] += 1\n-\n-    for k, v in list(namecount.items()):\n-        if v == 1:\n-            del namecount[k]\n-\n-    for i in reversed(range(len(estimators))):\n-        name = names[i]\n-        if name in namecount:\n-            names[i] += \"-%d\" % namecount[name]\n-            namecount[name] -= 1\n-\n-    return list(zip(names, estimators))\n-\n-\n-def make_pipeline(*steps, **kwargs):\n-    \"\"\"Construct a Pipeline from the given estimators.\n-\n-    This is a shorthand for the Pipeline constructor; it does not require, and\n-    does not permit, naming the estimators. Instead, their names will be set\n-    to the lowercase of their types automatically.\n-\n-    Parameters\n-    ----------\n-    *steps : list of estimators.\n-\n-    memory : None, str or object with the joblib.Memory interface, optional\n-        Used to cache the fitted transformers of the pipeline. By default,\n-        no caching is performed. If a string is given, it is the path to\n-        the caching directory. Enabling caching triggers a clone of\n-        the transformers before fitting. Therefore, the transformer\n-        instance given to the pipeline cannot be inspected\n-        directly. Use the attribute ``named_steps`` or ``steps`` to\n-        inspect estimators within the pipeline. Caching the\n-        transformers is advantageous when fitting is time consuming.\n-\n-    See also\n-    --------\n-    sklearn.pipeline.Pipeline : Class for creating a pipeline of\n-        transforms with a final estimator.\n-\n-    Examples\n-    --------\n-    >>> from sklearn.naive_bayes import GaussianNB\n-    >>> from sklearn.preprocessing import StandardScaler\n-    >>> make_pipeline(StandardScaler(), GaussianNB(priors=None))\n-    ...     # doctest: +NORMALIZE_WHITESPACE\n-    Pipeline(memory=None,\n-             steps=[('standardscaler',\n-                     StandardScaler(copy=True, with_mean=True, with_std=True)),\n-                    ('gaussiannb',\n-                     GaussianNB(priors=None, var_smoothing=1e-09))])\n-\n-    Returns\n-    -------\n-    p : Pipeline\n-    \"\"\"\n-    memory = kwargs.pop('memory', None)\n-    if kwargs:\n-        raise TypeError('Unknown keyword arguments: \"{}\"'\n-                        .format(list(kwargs.keys())[0]))\n-    return Pipeline(_name_estimators(steps), memory=memory)\n-\n-\n-# weight and fit_params are not used but it allows _fit_one_transformer,\n-# _transform_one and _fit_transform_one to have the same signature to\n-#  factorize the code in ColumnTransformer\n-def _fit_one_transformer(transformer, X, y, weight=None, **fit_params):\n-    return transformer.fit(X, y)\n-\n-\n-def _transform_one(transformer, X, y, weight, **fit_params):\n-    res = transformer.transform(X)\n-    # if we have a weight for this transformer, multiply output\n-    if weight is None:\n-        return res\n-    return res * weight\n-\n-\n-def _fit_transform_one(transformer, X, y, weight, **fit_params):\n-    if hasattr(transformer, 'fit_transform'):\n-        res = transformer.fit_transform(X, y, **fit_params)\n-    else:\n-        res = transformer.fit(X, y, **fit_params).transform(X)\n-    # if we have a weight for this transformer, multiply output\n-    if weight is None:\n-        return res, transformer\n-    return res * weight, transformer\n-\n-\n-class FeatureUnion(_BaseComposition, TransformerMixin):\n-    \"\"\"Concatenates results of multiple transformer objects.\n-\n-    This estimator applies a list of transformer objects in parallel to the\n-    input data, then concatenates the results. This is useful to combine\n-    several feature extraction mechanisms into a single transformer.\n-\n-    Parameters of the transformers may be set using its name and the parameter\n-    name separated by a '__'. A transformer may be replaced entirely by\n-    setting the parameter with its name to another transformer,\n-    or removed by setting to 'drop' or ``None``.\n-\n-    Read more in the :ref:`User Guide <feature_union>`.\n-\n-    Parameters\n-    ----------\n-    transformer_list : list of (string, transformer) tuples\n-        List of transformer objects to be applied to the data. The first\n-        half of each tuple is the name of the transformer.\n-\n-    n_jobs : int or None, optional (default=None)\n-        Number of jobs to run in parallel.\n-        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.\n-        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`\n-        for more details.\n-\n-    transformer_weights : dict, optional\n-        Multiplicative weights for features per transformer.\n-        Keys are transformer names, values the weights.\n-\n-    See also\n-    --------\n-    sklearn.pipeline.make_union : convenience function for simplified\n-        feature union construction.\n-\n-    Examples\n-    --------\n-    >>> from sklearn.pipeline import FeatureUnion\n-    >>> from sklearn.decomposition import PCA, TruncatedSVD\n-    >>> union = FeatureUnion([(\"pca\", PCA(n_components=1)),\n-    ...                       (\"svd\", TruncatedSVD(n_components=2))])\n-    >>> X = [[0., 1., 3], [2., 2., 5]]\n-    >>> union.fit_transform(X)    # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS\n-    array([[ 1.5       ,  3.0...,  0.8...],\n-           [-1.5       ,  5.7..., -0.4...]])\n-    \"\"\"\n-    _required_parameters = [\"transformer_list\"]\n-\n-    def __init__(self, transformer_list, n_jobs=None,\n-                 transformer_weights=None):\n-        self.transformer_list = transformer_list\n-        self.n_jobs = n_jobs\n-        self.transformer_weights = transformer_weights\n-        self._validate_transformers()\n-\n-    def get_params(self, deep=True):\n-        \"\"\"Get parameters for this estimator.\n-\n-        Parameters\n-        ----------\n-        deep : boolean, optional\n-            If True, will return the parameters for this estimator and\n-            contained subobjects that are estimators.\n-\n-        Returns\n-        -------\n-        params : mapping of string to any\n-            Parameter names mapped to their values.\n-        \"\"\"\n-        return self._get_params('transformer_list', deep=deep)\n-\n-    def set_params(self, **kwargs):\n-        \"\"\"Set the parameters of this estimator.\n-\n-        Valid parameter keys can be listed with ``get_params()``.\n-\n-        Returns\n-        -------\n-        self\n-        \"\"\"\n-        self._set_params('transformer_list', **kwargs)\n-        return self\n-\n-    def _validate_transformers(self):\n-        names, transformers = zip(*self.transformer_list)\n-\n-        # validate names\n-        self._validate_names(names)\n-\n-        # validate estimators\n-        for t in transformers:\n-            if t is None or t == 'drop':\n-                continue\n-            if (not (hasattr(t, \"fit\") or hasattr(t, \"fit_transform\")) or not\n-                    hasattr(t, \"transform\")):\n-                raise TypeError(\"All estimators should implement fit and \"\n-                                \"transform. '%s' (type %s) doesn't\" %\n-                                (t, type(t)))\n-\n-    def _iter(self):\n-        \"\"\"\n-        Generate (name, trans, weight) tuples excluding None and\n-        'drop' transformers.\n-        \"\"\"\n-        get_weight = (self.transformer_weights or {}).get\n-        return ((name, trans, get_weight(name))\n-                for name, trans in self.transformer_list\n-                if trans is not None and trans != 'drop')\n-\n-    def get_feature_names(self):\n-        \"\"\"Get feature names from all transformers.\n-\n-        Returns\n-        -------\n-        feature_names : list of strings\n-            Names of the features produced by transform.\n-        \"\"\"\n-        feature_names = []\n-        for name, trans, weight in self._iter():\n-            if not hasattr(trans, 'get_feature_names'):\n-                raise AttributeError(\"Transformer %s (type %s) does not \"\n-                                     \"provide get_feature_names.\"\n-                                     % (str(name), type(trans).__name__))\n-            feature_names.extend([name + \"__\" + f for f in\n-                                  trans.get_feature_names()])\n-        return feature_names\n-\n-    def fit(self, X, y=None):\n-        \"\"\"Fit all transformers using X.\n-\n-        Parameters\n-        ----------\n-        X : iterable or array-like, depending on transformers\n-            Input data, used to fit transformers.\n-\n-        y : array-like, shape (n_samples, ...), optional\n-            Targets for supervised learning.\n-\n-        Returns\n-        -------\n-        self : FeatureUnion\n-            This estimator\n-        \"\"\"\n-        self.transformer_list = list(self.transformer_list)\n-        self._validate_transformers()\n-        transformers = Parallel(n_jobs=self.n_jobs)(\n-            delayed(_fit_one_transformer)(trans, X, y)\n-            for _, trans, _ in self._iter())\n-        self._update_transformer_list(transformers)\n-        return self\n-\n-    def fit_transform(self, X, y=None, **fit_params):\n-        \"\"\"Fit all transformers, transform the data and concatenate results.\n-\n-        Parameters\n-        ----------\n-        X : iterable or array-like, depending on transformers\n-            Input data to be transformed.\n-\n-        y : array-like, shape (n_samples, ...), optional\n-            Targets for supervised learning.\n-\n-        Returns\n-        -------\n-        X_t : array-like or sparse matrix, shape (n_samples, sum_n_components)\n-            hstack of results of transformers. sum_n_components is the\n-            sum of n_components (output dimension) over transformers.\n-        \"\"\"\n-        self._validate_transformers()\n-        result = Parallel(n_jobs=self.n_jobs)(\n-            delayed(_fit_transform_one)(trans, X, y, weight,\n-                                        **fit_params)\n-            for name, trans, weight in self._iter())\n-\n-        if not result:\n-            # All transformers are None\n-            return np.zeros((X.shape[0], 0))\n-        Xs, transformers = zip(*result)\n-        self._update_transformer_list(transformers)\n-        if any(sparse.issparse(f) for f in Xs):\n-            Xs = sparse.hstack(Xs).tocsr()\n-        else:\n-            Xs = np.hstack(Xs)\n-        return Xs\n-\n-    def transform(self, X):\n-        \"\"\"Transform X separately by each transformer, concatenate results.\n-\n-        Parameters\n-        ----------\n-        X : iterable or array-like, depending on transformers\n-            Input data to be transformed.\n-\n-        Returns\n-        -------\n-        X_t : array-like or sparse matrix, shape (n_samples, sum_n_components)\n-            hstack of results of transformers. sum_n_components is the\n-            sum of n_components (output dimension) over transformers.\n-        \"\"\"\n-        Xs = Parallel(n_jobs=self.n_jobs)(\n-            delayed(_transform_one)(trans, X, None, weight)\n-            for name, trans, weight in self._iter())\n-        if not Xs:\n-            # All transformers are None\n-            return np.zeros((X.shape[0], 0))\n-        if any(sparse.issparse(f) for f in Xs):\n-            Xs = sparse.hstack(Xs).tocsr()\n-        else:\n-            Xs = np.hstack(Xs)\n-        return Xs\n-\n-    def _update_transformer_list(self, transformers):\n-        transformers = iter(transformers)\n-        self.transformer_list[:] = [(name, old if old is None or old == 'drop'\n-                                     else next(transformers))\n-                                    for name, old in self.transformer_list]\n-\n-\n-def make_union(*transformers, **kwargs):\n-    \"\"\"Construct a FeatureUnion from the given transformers.\n-\n-    This is a shorthand for the FeatureUnion constructor; it does not require,\n-    and does not permit, naming the transformers. Instead, they will be given\n-    names automatically based on their types. It also does not allow weighting.\n-\n-    Parameters\n-    ----------\n-    *transformers : list of estimators\n-\n-    n_jobs : int or None, optional (default=None)\n-        Number of jobs to run in parallel.\n-        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.\n-        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`\n-        for more details.\n-\n-    Returns\n-    -------\n-    f : FeatureUnion\n-\n-    See also\n-    --------\n-    sklearn.pipeline.FeatureUnion : Class for concatenating the results\n-        of multiple transformer objects.\n-\n-    Examples\n-    --------\n-    >>> from sklearn.decomposition import PCA, TruncatedSVD\n-    >>> from sklearn.pipeline import make_union\n-    >>> make_union(PCA(), TruncatedSVD())    # doctest: +NORMALIZE_WHITESPACE\n-    FeatureUnion(n_jobs=None,\n-           transformer_list=[('pca',\n-                              PCA(copy=True, iterated_power='auto',\n-                                  n_components=None, random_state=None,\n-                                  svd_solver='auto', tol=0.0, whiten=False)),\n-                             ('truncatedsvd',\n-                              TruncatedSVD(algorithm='randomized',\n-                              n_components=2, n_iter=5,\n-                              random_state=None, tol=0.0))],\n-           transformer_weights=None)\n-    \"\"\"\n-    n_jobs = kwargs.pop('n_jobs', None)\n-    if kwargs:\n-        # We do not currently support `transformer_weights` as we may want to\n-        # change its type spec in make_union\n-        raise TypeError('Unknown keyword arguments: \"{}\"'\n-                        .format(list(kwargs.keys())[0]))\n-    return FeatureUnion(_name_estimators(transformers), n_jobs=n_jobs)\n+    def __len__(self):\n+        return len(self.steps)\n"}
{"instance_id": "scikit-learn__scikit-learn-13496", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sklearn/ensemble/iforest.py b/sklearn/ensemble/iforest.py\nindex 8a1bd36259..c23ddb2e43 100644\n--- a/sklearn/ensemble/iforest.py\n+++ b/sklearn/ensemble/iforest.py\n@@ -120,6 +120,12 @@ class IsolationForest(BaseBagging, OutlierMixin):\n     verbose : int, optional (default=0)\n         Controls the verbosity of the tree building process.\n \n+    warm_start : bool, optional (default=False)\n+        When set to ``True``, reuse the solution of the previous call to fit\n+        and add more estimators to the ensemble, otherwise, just fit a whole\n+        new forest. See :term:`the Glossary <warm_start>`.\n+\n+        .. versionadded:: 0.21\n \n     Attributes\n     ----------\n@@ -173,7 +179,8 @@ class IsolationForest(BaseBagging, OutlierMixin):\n                  n_jobs=None,\n                  behaviour='old',\n                  random_state=None,\n-                 verbose=0):\n+                 verbose=0,\n+                 warm_start=False):\n         super().__init__(\n             base_estimator=ExtraTreeRegressor(\n                 max_features=1,\n@@ -187,6 +194,7 @@ class IsolationForest(BaseBagging, OutlierMixin):\n             max_features=max_features,\n             n_jobs=n_jobs,\n             random_state=random_state,\n+            warm_start=warm_start,\n             verbose=verbose)\n \n         self.behaviour = behaviour\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 35, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 35, "steps": 6}], "ms": 14690}
{"instance_id": "scikit-learn__scikit-learn-13779", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sklearn/ensemble/voting.py b/sklearn/ensemble/voting.py\nindex 7afa7180cc..1da83f3ee4 100644\n--- a/sklearn/ensemble/voting.py\n+++ b/sklearn/ensemble/voting.py\n@@ -78,7 +78,8 @@ class _BaseVoting(_BaseComposition, TransformerMixin):\n \n         if sample_weight is not None:\n             for name, step in self.estimators:\n-                if not has_fit_parameter(step, 'sample_weight'):\n+                if step is not None and not has_fit_parameter(\n+                        step, 'sample_weight'):\n                     raise ValueError('Underlying estimator \\'%s\\' does not'\n                                      ' support sample weights.' % name)\n \n", "model": "claude-sonnet-5-5", "steps": 9, "finished": true, "patch_lines": 14, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 14, "steps": 9}], "ms": 18539}
{"instance_id": "scikit-learn__scikit-learn-14053", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sklearn/tree/export.py b/sklearn/tree/export.py\nindex 1fe11e596a..c28ec40e8c 100644\n--- a/sklearn/tree/export.py\n+++ b/sklearn/tree/export.py\n@@ -890,9 +890,11 @@ def export_text(decision_tree, feature_names=None, max_depth=10,\n         value_fmt = \"{}{} value: {}\\n\"\n \n     if feature_names:\n-        feature_names_ = [feature_names[i] for i in tree_.feature]\n+        feature_names_ = [feature_names[i] if i != _tree.TREE_UNDEFINED\n+                          else None for i in tree_.feature]\n     else:\n-        feature_names_ = [\"feature_{}\".format(i) for i in tree_.feature]\n+        feature_names_ = [\"feature_{}\".format(i) if i != _tree.TREE_UNDEFINED\n+                          else None for i in tree_.feature]\n \n     export_text.report = \"\"\n \n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 18, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 18, "steps": 6}], "ms": 12993}
{"instance_id": "scikit-learn__scikit-learn-14087", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sklearn/linear_model/logistic.py b/sklearn/linear_model/logistic.py\nindex 1999f1dae7..20603226ba 100644\n--- a/sklearn/linear_model/logistic.py\n+++ b/sklearn/linear_model/logistic.py\n@@ -2170,7 +2170,7 @@ class LogisticRegressionCV(LogisticRegression, BaseEstimator,\n                 # Take the best scores across every fold and the average of\n                 # all coefficients corresponding to the best scores.\n                 best_indices = np.argmax(scores, axis=1)\n-                if self.multi_class == 'ovr':\n+                if multi_class == 'ovr':\n                     w = np.mean([coefs_paths[i, best_indices[i], :]\n                                  for i in range(len(folds))], axis=0)\n                 else:\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 13, "steps": 7}], "ms": 11966}
