我有一个开源包,在不同的子模块上有很多类。所有类都有方法fit和transform,并继承fit_transform自 sklearn。所有的类都遵循与副标题参数,属性,注释numpydoc,请参见,和方法的文档字符串,在这里我表fit,transform和fit_transform。我复制一个类的例子:
class DropFeatures(BaseEstimator, TransformerMixin):
"""
Some description.
Parameters
----------
features_to_drop : str or list, default=None
Variable(s) to be dropped from the dataframe
Methods
-------
fit
transform
fit_transform
"""
def __init__(self, features_to_drop: List[Union[str, int]]):
some init parameters
def fit(self, X: pd.DataFrame, y: pd.Series = None):
"""
This transformer does not learn any parameter.
Verifies that the input X is a pandas dataframe, and that the variables to
drop …Run Code Online (Sandbox Code Playgroud)