Modify the default search space for components
masterEach component (like svc or sgd_classifier) comes with a default search space. You can override these defaults or hold parameters constant by passing keyword arguments to the component function. These arguments should be hyperopt search space objects (e.g., using hp.pchoice or hp.loguniform) or constant values.
from hpsklearn import HyperoptEstimator, sgd_classifier
from hyperopt import hp
import numpy as np
# Hold penalty constant
sgd_penalty = "l2"
# Modify search space for loss and alpha
sgd_loss = hp.pchoice("loss", [(0.50, "hinge"), (0.25, "log"), (0.25, "huber")])
sgd_alpha = hp.loguniform("alpha", low=np.log(1e-5), high=np.log(1))
if __name__ == "__main__":
estim = HyperoptEstimator(classifier=sgd_classifier("my_sgd", penalty=sgd_penalty, loss=sgd_loss, alpha=sgd_alpha))
estim.fit(X_train, y_train)