Repository: scikit-learn/scikit-learn
File: sklearn/svm/_base.py (Python)

Code before:
                X,
                y,
                dtype=np.float64,
                order="C",
                accept_sparse="csr",
                accept_large_sparse=False,
            )

        y = self._validate_targets(y)

        sample_weight = np.asarray(
            [] if sample_weight is None else sample_weight, dtype=np.float64
        )
        solver_type = LIBSVM_IMPL.index(self._impl)

        if self._impl in ["c_svc", "nu_svc"]:
            est_dep = "SVC" if self._impl == "c_scv" else "NuSVC"
            if self.probability != "deprecated":
                warnings.warn(
                    f"parameter `probability` will be deprecated in version 1.8, "
                    f"use `CalibratedClassifierCV({est_dep}(), ensemble=False)` "
                    f"instead of `{est_dep}(probability=True)`",
                    FutureWarning,
                )
            else:
                self.probability = False

        # input validation
        n_samples = _num_samples(X)
        if solver_type != 2 and n_samples != y.shape[0]:
            raise ValueError(
                "X and y have incompatible shapes.\n"
                + "X has %s samples, but y has %s." % (n_samples, y.shape[0])
            )

        if self.kernel == "precomputed" and n_samples != X.shape[1]:
            raise ValueError(
                "Precomputed matrix must be a square matrix."
                " Input is a {}x{} matrix.".format(X.shape[0], X.shape[1])
            )

        if sample_weight.shape[0] > 0 and sample_weight.shape[0] != n_samples:
            raise ValueError(
                "sample_weight and X have incompatible shapes: "
                "%r vs %r\n"
                "Note: Sparse matrices cannot be indexed w/"
                "boolean masks (use `indices=True` in CV)."
                % (sample_weight.shape, X.shape)
            )

        kernel = "precomputed" if callable(self.kernel) else self.kernel

Review comment (suggestion):
As per scikit-learn estimator API, `fit` should not change the value of a public attribute set in the constructor. Instead, define a local variable named `probability` and set it to `self.probability` when `self.probability != "deprecated"` and `False` otherwise.

Code after:
                X,
                y,
                dtype=np.float64,
                order="C",
                accept_sparse="csr",
                accept_large_sparse=False,
            )

        y = self._validate_targets(y)

        sample_weight = np.asarray(
            [] if sample_weight is None else sample_weight, dtype=np.float64
        )
        solver_type = LIBSVM_IMPL.index(self._impl)

        # TODO(1.11): remove probability
        self._effective_probability = self.probability
        if self._impl in ["c_svc", "nu_svc"]:
            if self._impl == "nu_scv":
                est_dep = "NuSVC"
            else:
                est_dep = "SVC"
            if self.probability != "deprecated":
                warnings.warn(
                    f"The `probability` parameter was deprecated in 1.9 and "
                    f"will be removed in version 1.11. "
                    f"Use `CalibratedClassifierCV({est_dep}(), ensemble=False)` "
                    f"instead of `{est_dep}(probability=True)`",
                    FutureWarning,
                )
            else:
                self._effective_probability = False

        # input validation
        n_samples = _num_samples(X)
        if solver_type != 2 and n_samples != y.shape[0]:
            raise ValueError(
                "X and y have incompatible shapes.\n"
                + "X has %s samples, but y has %s." % (n_samples, y.shape[0])
            )

        if self.kernel == "precomputed" and n_samples != X.shape[1]:
            raise ValueError(
                "Precomputed matrix must be a square matrix."
                " Input is a {}x{} matrix.".format(X.shape[0], X.shape[1])
            )

        if sample_weight.shape[0] > 0 and sample_weight.shape[0] != n_samples:
            raise ValueError(
                "sample_weight and X have incompatible shapes: "
                "%r vs %r\n"