Custom transformer for sklearn Pipeline that alters both X and y

前端 未结 3 2027
忘掉有多难
忘掉有多难 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:26

    Use "deep-copies" further on, down the pipeline and X, y remain protected

    .fit() can first assign on each call deep-copy to new class-variables

    self.X_without_NaNs = X.copy()
    self.y_without_NaNs = y.copy()
    

    and then reduce / transform these not to have more NaN-s than ordered by self.treshold

提交回复
热议问题