Repository: Zeroto521/my-data-toolkit

Issue:
DEP: add `DeprecationWarning` for `dtoolkit.transformer.MinMaxScaler`
<!--
Thanks for contributing a pull request!

Please follow these standard acronyms to start the commit message:

- ENH: enhancement
- BUG: bug fix
- DOC: documentation
- TYP: type annotations
- TST: addition or modification of tests
- MAINT: maintenance commit (refactoring, typos, etc.)
- BLD: change related to building
- REL: related to releasing
- API: an (incompatible) API change
- DEP: deprecate something, or remove a deprecated object
- DEV: development tool or utility
- REV: revert an earlier commit
- PERF: performance improvement
- BOT: always commit via a bot
- CI: related to CI or CD
- CLN: Code cleanup
-->

- [x] closes #431
- [x] whatsnew entry

Since PR#431 has been done, `dtoolkit.transformer.MinMaxScaler` is duplicated to `sklearn.preprocessing.MinMaxScaler` in functional way.


Discussion:

Resolving patch:
diff --git a/dtoolkit/transformer/__init__.py b/dtoolkit/transformer/__init__.py
--- a/dtoolkit/transformer/__init__.py
+++ b/dtoolkit/transformer/__init__.py
@@ -19,5 +19,4 @@
 from dtoolkit.transformer.pipeline import make_pipeline  # noqa
 from dtoolkit.transformer.pipeline import make_union  # noqa
 from dtoolkit.transformer.pipeline import Pipeline  # noqa
-from dtoolkit.transformer.sklearn import MinMaxScaler  # noqa
 from dtoolkit.transformer.sklearn import OneHotEncoder  # noqa
diff --git a/dtoolkit/transformer/sklearn.py b/dtoolkit/transformer/sklearn.py
--- a/dtoolkit/transformer/sklearn.py
+++ b/dtoolkit/transformer/sklearn.py
@@ -3,143 +3,19 @@
 from textwrap import dedent
 from typing import TYPE_CHECKING
 
-import numpy as np
 import pandas as pd
 from pandas.util._decorators import doc
-from sklearn.preprocessing import MinMaxScaler as SKMinMaxScaler
 from sklearn.preprocessing import OneHotEncoder as SKOneHotEncoder
 
 from dtoolkit.accessor.dataframe import cols  # noqa
 from dtoolkit.accessor.series import cols  # noqa
-from dtoolkit.transformer._util import transform_array_to_frame
-from dtoolkit.transformer._util import transform_frame_to_series
-from dtoolkit.transformer._util import transform_series_to_frame
 
 if TYPE_CHECKING:
     from scipy.sparse import csr_matrix
 
-    from dtoolkit._typing import SeriesOrFrame
     from dtoolkit._typing import TwoDimArray
 
 
-class MinMaxScaler(SKMinMaxScaler):
-    """
-    Transform features by scaling each feature to a given range.
-
-    .. warning::
-        Transformer :class:`dtoolkit.transformer.MinMaxScaler` is deprecated and
-        will be removed in 0.0.13.
-        Please use :class:`sklearn.preprocessing.MinMaxScaler` instead.
-        (Warning added DToolKit 0.0.12)
-
-    The transformation is given by::
-
-        X_std = (X - X.min(axis=0)) / (X.max(axis=0) - X.min(axis=0))
-        X_scaled = X_std * (max - min) + min
-
-    where :exc:`min, max = feature_range`.
-
-    Examples
-    --------
-    >>> from dtoolkit.transformer import MinMaxScaler
-    >>> data = [[-1, 2], [-0.5, 6], [0, 10], [1, 18]]
-    >>> scaler = MinMaxScaler()
-    >>> scaler.fit(data)
-    MinMaxScaler()
-    >>> scaler.data_max_
-    array([ 1., 18.])
-    >>> scaler.transform(data)
-    array([[0.  , 0.  ],
-           [0.25, 0.25],
-           [0.5 , 0.5 ],
-           [1.  , 1.  ]])
-    >>> scaler.transform([[2, 2]])
-    array([[1.5, 0. ]])
-
-    Notes
-    -----
-    Different to :obj:`sklearn.preprocessing.MinMaxScaler`.
-    This would let :obj:`~pandas.DataFrame` in and
-    :obj:`~pandas.DataFrame` out.
-    """
-
-    @doc(SKMinMaxScaler.__init__)
-    def __init__(self, feature_range=(0, 1), *, copy=True, clip=False):
-        from warnings import warn
-
-        warn(
-            "Transformer 'dtoolkit.transformer.MinMaxScaler' is deprecated and "
-            "will be removed in 0.0.13. "
-            "Please use 'sklearn.preprocessing.MinMaxScaler' instead. "
-            "(Warning added DToolKit 0.0.12)",
-            DeprecationWarning,
-        )
-
-        super().__init__(
-            feature_range=feature_range,
-            copy=copy,
-            clip=clip,
-        )
-
-    @doc(SKMinMaxScaler.fit)
-    def fit(self, X, y=None):
-        X = transform_series_to_frame(X)
-
-        return super().fit(X, y)
-
-    def transform(self, X: TwoDimArray) -> TwoDimArray:
-        """
-        Scale features of X according to feature_range.
-
-        Parameters
-        ----------
-        X : DataFrame or array-like of shape `(n_samples, n_features)`
-            Input data that will be transformed.
-
-        Returns
-        -------
-        DataFrame or ndarray of shape `(n_samples, n_features)`
-            Transformed data.
-
-        Notes
-        -----
-        This would let :obj:`~pandas.DataFrame` in and
-        :obj:`~pandas.DataFrame` out.
-        """
-
-        X = transform_series_to_frame(X)
-        Xt = super().transform(X)
-        Xt = transform_array_to_frame(Xt, X)
-
-        return transform_frame_to_series(Xt)
-
-    def inverse_transform(self, X: SeriesOrFrame | np.ndarray) -> TwoDimArray:
-        """
-        Undo the scaling of X according to feature_range.
-
-        Parameters
-        ----------
-        X : Series, DataFrame or array-like of shape `(n_samples, n_features)`
-            Input data that will be transformed. It cannot be sparse.
-
-        Returns
-        -------
-        DataFrame or ndarray of shape (n_samples, n_features)
-            Transformed data.
-
-        Notes
-        -----
-        This would let :obj:`~pandas.DataFrame` in and
-        :obj:`~pandas.DataFrame` out.
-        """
-
-        X = transform_series_to_frame(X)
-        Xt = super().inverse_transform(X)
-        Xt = transform_array_to_frame(Xt, X)
-
-        return transform_frame_to_series(Xt)
-
-
 class OneHotEncoder(SKOneHotEncoder):
     """
     Encode categorical features as a one-hot numeric array.


Test patch:
diff --git a/test/transformer/test_sklearn.py b/test/transformer/test_sklearn.py
--- a/test/transformer/test_sklearn.py
+++ b/test/transformer/test_sklearn.py
@@ -1,33 +1,11 @@
-from test.transformer import df_iris
 from test.transformer import df_label
-from test.transformer import s
 
 import pandas as pd
 from scipy import sparse
 
-from dtoolkit.transformer import MinMaxScaler
 from dtoolkit.transformer import OneHotEncoder
 
 
-class TestMinMaxscaler:
-    def test_work(self):
-        tf = MinMaxScaler().fit(df_iris)
-
-        data_transformed = tf.transform(df_iris)
-        data = tf.inverse_transform(data_transformed)
-        data = data.round(2)
-
-        assert df_iris.equals(data)
-
-    def test_series_in_series_out(self):
-        tf = MinMaxScaler()
-        tf.fit(s.to_frame())
-        result = tf.inverse_transform(s)
-
-        assert isinstance(s, pd.Series)
-        assert isinstance(result, pd.Series)
-
-
 class TestOneHotEncoder:
     def test_dataframe_in_dataframe_out(self):
         tf = OneHotEncoder()