Custom transformer for sklearn Pipeline that alters both X and y

前端 未结 3 2030
忘掉有多难
忘掉有多难 2020-12-15 06:25

I want to create my own transformer for use with the sklearn Pipeline. Hence I am creating a class that implements both fit and transform methods. The purpose of the transfo

3条回答
  •  抹茶落季
    2020-12-15 07:20

    Modifying the sample axis, e.g. removing samples, does not (yet?) comply with the scikit-learn transformer API. So if you need to do this, you should do it outside any calls to scikit learn, as preprocessing.

    As it is now, the transformer API is used to transform the features of a given sample into something new. This can implicitly contain information from other samples, but samples are never deleted.

    Another option is to attempt to impute the missing values. But again, if you need to delete samples, treat it as preprocessing before using scikit learn.

提交回复
热议问题