@@ -13,7 +13,7 @@ from ..base import BaseEstimator, OneToOneFeatureMixin, TransformerMixin
13
13
# Joris Van den Bossche <jorisvandenbossche@gmail.com>
14
14
# License: BSD 3 clause
15
15
16
- __all__ = ["OneHotEncoder" , "OrdinalEncoder" ]
16
+ __all__ = ["OneHotEncoder" , "OrdinalEncoder" , "TargetEncoder" ]
17
17
18
18
class _BaseEncoder (TransformerMixin , BaseEstimator ): ...
19
19
@@ -67,3 +67,29 @@ class OrdinalEncoder(OneToOneFeatureMixin, _BaseEncoder):
67
67
def fit (self , X : MatrixLike , y : Series | None = None ) -> Self : ...
68
68
def transform (self , X : MatrixLike ) -> ndarray : ...
69
69
def inverse_transform (self , X : MatrixLike ) -> ndarray : ...
70
+
71
+ class TargetEncoder (OneToOneFeatureMixin , _BaseEncoder ):
72
+ feature_names_in_ : ndarray = ...
73
+ n_features_in_ : int = ...
74
+ categories_ : list [ndarray ] = ...
75
+ encodings_ : list [ndarray ] = ...
76
+ target_type_ : str = ...
77
+ target_mean_ : float = ...
78
+ classes_ : ndarray | None = ...
79
+
80
+ _parameter_constraints : ClassVar [dict ] = ...
81
+
82
+ def __init__ (
83
+ self ,
84
+ * ,
85
+ categories : Sequence [ArrayLike ] | Literal ["auto" ] = "auto" ,
86
+ target_type : Literal ["auto" , "continuous" , "binary" , "multiclass" ] = "auto" ,
87
+ smooth : Literal ["auto" ] | float = "auto" ,
88
+ cv : int = 5 ,
89
+ shuffle : bool = True ,
90
+ random_state : Int | None = None ,
91
+ ) -> None : ...
92
+ def fit (self , X : MatrixLike , y : ArrayLike ) -> Self : ...
93
+ def transform (self , X : MatrixLike ) -> ndarray : ...
94
+ def fit_transform (self , X : MatrixLike , y : ArrayLike ) -> ndarray : ...
95
+ def get_feature_names_out (self , input_features : None | ArrayLike = None ) -> ndarray : ...
0 commit comments