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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ ignore = [
"PYI001",
"PYI002",
"PYI017",
"PYI019", # Request for more autofixes: https://github.com/astral-sh/ruff/issues/15798
"PYI024",
"PYI048",
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
Expand Down
7 changes: 3 additions & 4 deletions stubs/sklearn/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import re
import warnings
from collections import defaultdict as defaultdict
from collections.abc import Iterable
from typing import Any, ClassVar, TypeVar
from typing import Any, ClassVar
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -18,16 +19,14 @@ from .utils._param_validation import validate_parameter_constraints as validate_
from .utils._set_output import _SetOutputMixin
from .utils.validation import check_array as check_array, check_is_fitted as check_is_fitted, check_X_y as check_X_y

BaseEstimator_Self = TypeVar("BaseEstimator_Self", bound=BaseEstimator)

# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# License: BSD 3 clause

def clone(estimator: BaseEstimator | Iterable[BaseEstimator], *, safe: bool = True) -> Any: ...

class BaseEstimator:
def get_params(self, deep: bool = True) -> dict: ...
def set_params(self: BaseEstimator_Self, **params) -> BaseEstimator_Self: ...
def set_params(self, **params) -> Self: ...
def __repr__(self, N_CHAR_MAX: int = 700) -> str: ...
def __getstate__(self): ...
def __setstate__(self, state) -> None: ...
Expand Down
14 changes: 6 additions & 8 deletions stubs/sklearn/calibration.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ from functools import partial as partial
from inspect import signature as signature
from math import log as log
from numbers import Integral as Integral
from typing import ClassVar, Literal, TypeVar
from typing import ClassVar, Literal
from typing_extensions import Self

import numpy as np
from matplotlib.artist import Artist
Expand Down Expand Up @@ -33,9 +34,6 @@ from .utils.multiclass import check_classification_targets as check_classificati
from .utils.parallel import Parallel as Parallel, delayed as delayed
from .utils.validation import check_consistent_length as check_consistent_length, check_is_fitted as check_is_fitted

CalibratedClassifierCV_Self = TypeVar("CalibratedClassifierCV_Self", bound=CalibratedClassifierCV)
_SigmoidCalibration_Self = TypeVar("_SigmoidCalibration_Self", bound=_SigmoidCalibration)

class CalibratedClassifierCV(ClassifierMixin, MetaEstimatorMixin, BaseEstimator):
calibrated_classifiers_: list = ...
feature_names_in_: ndarray = ...
Expand All @@ -55,12 +53,12 @@ class CalibratedClassifierCV(ClassifierMixin, MetaEstimatorMixin, BaseEstimator)
base_estimator: str | BaseEstimator = "deprecated",
) -> None: ...
def fit(
self: CalibratedClassifierCV_Self,
self,
X: MatrixLike,
y: ArrayLike,
sample_weight: None | ArrayLike = None,
**fit_params,
) -> CalibratedClassifierCV_Self: ...
) -> Self: ...
def predict_proba(self, X: MatrixLike) -> ndarray: ...
def predict(self, X: MatrixLike) -> ndarray: ...

Expand All @@ -80,11 +78,11 @@ class _SigmoidCalibration(RegressorMixin, BaseEstimator):
a_: float = ...

def fit(
self: _SigmoidCalibration_Self,
self,
X: ArrayLike,
y: ArrayLike,
sample_weight: None | ArrayLike = None,
) -> _SigmoidCalibration_Self: ...
) -> Self: ...
def predict(self, T: ArrayLike) -> ndarray: ...

def calibration_curve(
Expand Down
7 changes: 3 additions & 4 deletions stubs/sklearn/cluster/_affinity_propagation.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from numbers import Integral as Integral, Real as Real
from typing import Any, ClassVar, Literal, TypeVar
from typing import Any, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -15,8 +16,6 @@ from ..utils import as_float_array as as_float_array, check_random_state as chec
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ..utils.validation import check_is_fitted as check_is_fitted

AffinityPropagation_Self = TypeVar("AffinityPropagation_Self", bound=AffinityPropagation)

###############################################################################
# Public API

Expand Down Expand Up @@ -56,6 +55,6 @@ class AffinityPropagation(ClusterMixin, BaseEstimator):
verbose: bool = False,
random_state: RandomState | None | Int = None,
) -> None: ...
def fit(self: AffinityPropagation_Self, X: MatrixLike, y: Any = None) -> AffinityPropagation_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def predict(self, X: MatrixLike | ArrayLike) -> ndarray: ...
def fit_predict(self, X: MatrixLike, y: Any = None) -> ndarray: ...
10 changes: 4 additions & 6 deletions stubs/sklearn/cluster/_agglomerative.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from heapq import heapify as heapify, heappop as heappop, heappush as heappush, heappushpop as heappushpop
from numbers import Integral as Integral, Real as Real
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from joblib import Memory
Expand All @@ -21,9 +22,6 @@ from ..utils._param_validation import HasMethods as HasMethods, Hidden as Hidden
from ..utils.validation import check_memory as check_memory
from ._feature_agglomeration import AgglomerationTransform

FeatureAgglomeration_Self = TypeVar("FeatureAgglomeration_Self", bound=FeatureAgglomeration)
AgglomerativeClustering_Self = TypeVar("AgglomerativeClustering_Self", bound=AgglomerativeClustering)

###############################################################################
# Hierarchical tree building functions

Expand Down Expand Up @@ -74,7 +72,7 @@ class AgglomerativeClustering(ClusterMixin, BaseEstimator):
distance_threshold: None | Float = None,
compute_distances: bool = False,
) -> None: ...
def fit(self: AgglomerativeClustering_Self, X: MatrixLike, y: Any = None) -> AgglomerativeClustering_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def fit_predict(self, X: MatrixLike, y: Any = None) -> ndarray: ...

class FeatureAgglomeration(ClassNamePrefixFeaturesOutMixin, AgglomerativeClustering, AgglomerationTransform):
Expand Down Expand Up @@ -103,5 +101,5 @@ class FeatureAgglomeration(ClassNamePrefixFeaturesOutMixin, AgglomerativeCluster
distance_threshold: None | Float = None,
compute_distances: bool = False,
) -> None: ...
def fit(self: FeatureAgglomeration_Self, X: MatrixLike, y: Any = None) -> FeatureAgglomeration_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def fit_predict(self): ...
7 changes: 3 additions & 4 deletions stubs/sklearn/cluster/_bicluster.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABCMeta, abstractmethod
from numbers import Integral as Integral
from typing import Any, ClassVar, Literal, TypeVar
from typing import Any, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -21,8 +22,6 @@ from ..utils.extmath import (
from ..utils.validation import assert_all_finite as assert_all_finite
from . import KMeans as KMeans, MiniBatchKMeans as MiniBatchKMeans

BaseSpectral_Self = TypeVar("BaseSpectral_Self", bound=BaseSpectral)

__all__ = ["SpectralCoclustering", "SpectralBiclustering"]

class BaseSpectral(BiclusterMixin, BaseEstimator, metaclass=ABCMeta):
Expand All @@ -39,7 +38,7 @@ class BaseSpectral(BiclusterMixin, BaseEstimator, metaclass=ABCMeta):
n_init: int = 10,
random_state: None | int = None,
) -> None: ...
def fit(self: BaseSpectral_Self, X: MatrixLike, y: Any = None) -> BaseSpectral_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...

class SpectralCoclustering(BaseSpectral):
feature_names_in_: ndarray = ...
Expand Down
9 changes: 4 additions & 5 deletions stubs/sklearn/cluster/_birch.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from math import sqrt as sqrt
from numbers import Integral as Integral, Real as Real
from typing import Any, ClassVar, TypeVar
from typing import Any, ClassVar
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -19,8 +20,6 @@ from ..utils.extmath import row_norms as row_norms
from ..utils.validation import check_is_fitted as check_is_fitted
from . import AgglomerativeClustering as AgglomerativeClustering

Birch_Self = TypeVar("Birch_Self", bound=Birch)

# Authors: Manoj Kumar <manojkumarsivaraj334@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Joel Nothman <joel.nothman@gmail.com>
Expand Down Expand Up @@ -86,7 +85,7 @@ class Birch(ClassNamePrefixFeaturesOutMixin, ClusterMixin, TransformerMixin, Bas
compute_labels: bool = True,
copy: bool = True,
) -> None: ...
def fit(self: Birch_Self, X: MatrixLike | ArrayLike, y: Any = None) -> Birch_Self: ...
def partial_fit(self: Birch_Self, X: None | MatrixLike | ArrayLike = None, y: Any = None) -> Birch_Self: ...
def fit(self, X: MatrixLike | ArrayLike, y: Any = None) -> Self: ...
def partial_fit(self, X: None | MatrixLike | ArrayLike = None, y: Any = None) -> Self: ...
def predict(self, X: MatrixLike | ArrayLike) -> ndarray: ...
def transform(self, X: MatrixLike | ArrayLike) -> ndarray | spmatrix: ...
9 changes: 4 additions & 5 deletions stubs/sklearn/cluster/_bisect_k_means.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from collections.abc import Iterator
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
import scipy.sparse as sp
Expand All @@ -13,8 +14,6 @@ from ..utils.extmath import row_norms as row_norms
from ..utils.validation import check_is_fitted as check_is_fitted, check_random_state as check_random_state
from ._kmeans import _BaseKMeans

BisectingKMeans_Self = TypeVar("BisectingKMeans_Self", bound=BisectingKMeans)

# Author: Michal Krawczyk <mkrwczyk.1@gmail.com>

class _BisectingTree:
Expand Down Expand Up @@ -47,9 +46,9 @@ class BisectingKMeans(_BaseKMeans):
bisecting_strategy: Literal["biggest_inertia", "largest_cluster"] = "biggest_inertia",
) -> None: ...
def fit(
self: BisectingKMeans_Self,
self,
X: MatrixLike | ArrayLike,
y: Any = None,
sample_weight: None | ArrayLike = None,
) -> BisectingKMeans_Self: ...
) -> Self: ...
def predict(self, X: MatrixLike | ArrayLike) -> ndarray: ...
9 changes: 4 additions & 5 deletions stubs/sklearn/cluster/_dbscan.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from numbers import Integral as Integral, Real as Real
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -12,8 +13,6 @@ from ..neighbors import NearestNeighbors as NearestNeighbors
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ._dbscan_inner import dbscan_inner as dbscan_inner

DBSCAN_Self = TypeVar("DBSCAN_Self", bound=DBSCAN)

# Author: Robert Layton <robertlayton@gmail.com>
# Joel Nothman <joel.nothman@gmail.com>
# Lars Buitinck
Expand Down Expand Up @@ -56,9 +55,9 @@ class DBSCAN(ClusterMixin, BaseEstimator):
n_jobs: None | Int = None,
) -> None: ...
def fit(
self: DBSCAN_Self,
self,
X: MatrixLike,
y: Any = None,
sample_weight: None | ArrayLike = None,
) -> DBSCAN_Self: ...
) -> Self: ...
def fit_predict(self, X: MatrixLike, y: Any = None, sample_weight: None | ArrayLike = None) -> ndarray: ...
18 changes: 8 additions & 10 deletions stubs/sklearn/cluster/_kmeans.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from abc import ABC, abstractmethod as abstractmethod
from numbers import Integral as Integral, Real as Real
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
import scipy.sparse as sp
Expand Down Expand Up @@ -36,9 +37,6 @@ from ._k_means_lloyd import (
lloyd_iter_chunked_sparse as lloyd_iter_chunked_sparse,
)

KMeans_Self = TypeVar("KMeans_Self", bound=KMeans)
MiniBatchKMeans_Self = TypeVar("MiniBatchKMeans_Self", bound=MiniBatchKMeans)

###############################################################################
# Initialization heuristic

Expand Down Expand Up @@ -125,11 +123,11 @@ class KMeans(_BaseKMeans):
algorithm: Literal["lloyd", "elkan", "auto", "full"] = "lloyd",
) -> None: ...
def fit(
self: KMeans_Self,
self,
X: MatrixLike | ArrayLike,
y: Any = None,
sample_weight: None | ArrayLike = None,
) -> KMeans_Self: ...
) -> Self: ...

class MiniBatchKMeans(_BaseKMeans):
feature_names_in_: ndarray = ...
Expand Down Expand Up @@ -159,14 +157,14 @@ class MiniBatchKMeans(_BaseKMeans):
reassignment_ratio: Float = 0.01,
) -> None: ...
def fit(
self: MiniBatchKMeans_Self,
self,
X: MatrixLike | ArrayLike,
y: Any = None,
sample_weight: None | ArrayLike = None,
) -> MiniBatchKMeans_Self: ...
) -> Self: ...
def partial_fit(
self: MiniBatchKMeans_Self,
self,
X: MatrixLike | ArrayLike,
y: Any = None,
sample_weight: None | ArrayLike = None,
) -> MiniBatchKMeans_Self: ...
) -> Self: ...
7 changes: 3 additions & 4 deletions stubs/sklearn/cluster/_mean_shift.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from collections import defaultdict as defaultdict
from numbers import Integral as Integral, Real as Real
from typing import Any, ClassVar, TypeVar
from typing import Any, ClassVar
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -17,8 +18,6 @@ from ..utils._param_validation import Interval as Interval
from ..utils.parallel import Parallel as Parallel, delayed as delayed
from ..utils.validation import check_is_fitted as check_is_fitted

MeanShift_Self = TypeVar("MeanShift_Self", bound=MeanShift)

# Authors: Conrad Lee <conradlee@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Gael Varoquaux <gael.varoquaux@normalesup.org>
Expand Down Expand Up @@ -65,5 +64,5 @@ class MeanShift(ClusterMixin, BaseEstimator):
n_jobs: None | Int = None,
max_iter: Int = 300,
) -> None: ...
def fit(self: MeanShift_Self, X: MatrixLike, y: Any = None) -> MeanShift_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def predict(self, X: MatrixLike) -> ndarray: ...
7 changes: 3 additions & 4 deletions stubs/sklearn/cluster/_optics.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from numbers import Integral as Integral, Real as Real
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from joblib import Memory
Expand All @@ -17,8 +18,6 @@ from ..utils import gen_batches as gen_batches, get_chunk_n_rows as get_chunk_n_
from ..utils._param_validation import HasMethods as HasMethods, Interval as Interval, StrOptions as StrOptions
from ..utils.validation import check_memory as check_memory

OPTICS_Self = TypeVar("OPTICS_Self", bound=OPTICS)

class OPTICS(ClusterMixin, BaseEstimator):
feature_names_in_: ndarray = ...
n_features_in_: int = ...
Expand Down Expand Up @@ -49,7 +48,7 @@ class OPTICS(ClusterMixin, BaseEstimator):
memory: None | Memory | str = None,
n_jobs: None | Int = None,
) -> None: ...
def fit(self: OPTICS_Self, X: MatrixLike, y: Any = None) -> OPTICS_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...

def compute_optics_graph(
X: MatrixLike,
Expand Down
7 changes: 3 additions & 4 deletions stubs/sklearn/cluster/_spectral.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from collections.abc import Mapping
from numbers import Integral as Integral, Real as Real
from typing import Any, Callable, ClassVar, Literal, TypeVar
from typing import Any, Callable, ClassVar, Literal
from typing_extensions import Self

import numpy as np
from numpy import ndarray
Expand All @@ -19,8 +20,6 @@ from ..utils import as_float_array as as_float_array, check_random_state as chec
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ._kmeans import k_means as k_means

SpectralClustering_Self = TypeVar("SpectralClustering_Self", bound=SpectralClustering)

def cluster_qr(vectors: MatrixLike) -> ndarray: ...
def discretize(
vectors: MatrixLike,
Expand Down Expand Up @@ -70,5 +69,5 @@ class SpectralClustering(ClusterMixin, BaseEstimator):
n_jobs: None | Int = None,
verbose: bool = False,
) -> None: ...
def fit(self: SpectralClustering_Self, X: MatrixLike, y: Any = None) -> SpectralClustering_Self: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def fit_predict(self, X: MatrixLike, y: Any = None) -> ndarray: ...
Loading