uclamii / model_tuner

A library to tune the hyperparameters of common ML models. Supports calibration and custom pipelines.
Apache License 2.0
3 stars 0 forks source link

Moving towards custom pipeline steps #34

Closed elemets closed 1 month ago

elemets commented 1 month ago

Description

The current implementation of our model tuner supports custom steps in two ways: by using predefined steps like impute or by specifying a scaler type via the scaler_type variable, and by defining custom steps in the pipeline_steps. Managing compatibility between these two approaches is leading to complex code and interaction issues between these variables. We have decided to fully adopt the pipeline_steps approach.

This issue will focus on ensuring that all functionalities (such as ADASYN and SMOTE) work smoothly with pipeline_steps and cleaning up legacy code that still uses the older variables like impute or scaler_type.

Problem

Proposed Solution

Code

This code is a fix for the SMOTE and ADASYN sections but still contains support for the previous implementation.

        if self.impute:
            preproc_test = clone(self.estimator.named_steps["imputer"])
        elif self.pipeline:
            ### Need to detect what the name of a column transformer has been called
            ### if we are using custom pipeline steps
            preproc_test = clone(self.estimator.named_steps['Preprocessor'])
        else:
            pass

        resampler_test = clone(self.estimator.named_steps["Resampler"])