from deephyper.problem import HpProblem from deephyper.problem import config_space as cs # Problem definition Problem = HpProblem() x_hp = Problem.add_hyperparameter( name="x", value=(0, 10)) # or Problem.add_dim("x", (0, 10)) y_hp = Problem.add_hyperparameter( name="y", value=(0, 10)) # or Problem.add_dim("y", (0, 10)) not_zero = cs.ForbiddenAndConjunction(cs.ForbiddenEqualsClause(x_hp, 0), cs.ForbiddenEqualsClause(y_hp, 0)) Problem.add_forbidden_clause(not_zero) Problem.add_starting_point(x=1, y=1) # Definition of the function which runs the model def run(param_dict): x = param_dict["x"] y = param_dict["y"] res = np.log(1 / (y + x)) return res # the objective
value=["friedman_mse", "mse", "mae", "gini", "entropy"], default_value="gini", ) # GradientBoosting loss = Problem.add_hyperparameter(name="loss", value=["deviance", "exponential"]) learning_rate = Problem.add_hyperparameter(name="learning_rate", value=(0.01, 1.0)) subsample = Problem.add_hyperparameter(name="subsample", value=(0.01, 1.0)) gradient_boosting_hp = [loss, learning_rate, subsample] for hp_i in gradient_boosting_hp: Problem.add_condition( cs.EqualsCondition(hp_i, classifier, "GradientBoosting")) forbidden_criterion_rf = cs.ForbiddenAndConjunction( cs.ForbiddenEqualsClause(classifier, "RandomForest"), cs.ForbiddenInClause(criterion, ["friedman_mse", "mse", "mae"]), ) Problem.add_forbidden_clause(forbidden_criterion_rf) forbidden_criterion_gb = cs.ForbiddenAndConjunction( cs.ForbiddenEqualsClause(classifier, "GradientBoosting"), cs.ForbiddenInClause(criterion, ["gini", "entropy"]), ) Problem.add_forbidden_clause(forbidden_criterion_gb) if __name__ == "__main__": print(Problem)