Keras Sklearn Tuner module ‘sklearn’ has no attribute ‘pipeline’

from sklearn import ensemble
from sklearn import linear_model

def build_model(hp):
    model_type = hp.Choice('model_type', ['random_forest', 'ridge'])
    if model_type == 'random_forest':
        with hp.conditional_scope('model_type', 'random_forest'):
            model = ensemble.RandomForestClassifier(
                n_estimators=hp.Int('n_estimators', 10, 50, step=10),
                max_depth=hp.Int('max_depth', 3, 10))
    elif model_type == 'ridge':
        with hp.conditional_scope('model_type', 'ridge'):
            model = linear_model.RidgeClassifier(
                alpha=hp.Float('alpha', 1e-3, 1, sampling='log'))
        raise ValueError('Unrecognized model_type')
    return model

tuner = kt.tuners.Sklearn(
            objective=kt.Objective('score', 'max'),

X, y = datasets.load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = model_selection.train_test_split(
    X, y, test_size=0.2), y_train)

best_model = tuner.get_best_models(num_models=1)[0]

on execution of this code from the samples on keras-tuner

I am getting the error shown below. What should be the fix? in run_trial(self, trial, X, y, sample_weight, groups)
    161                 sample_weight[train_indices] if sample_weight is not None else None
    162             )
--> 163 
    164             model =
    165             #if isinstance(model, Pipeline):

AttributeError: module 'sklearn' has no attribute 'pipeline'


Adding import sklearn.pipeline would temporarily fix the problem.

This is a very recent issue and will be fixed in the next release.

You can find more about it here