Beispiel #1
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('MultinomialNB_')
        #self.classes_ = np.unique(y.astype(int))

        self.alpha = trial.suggest_loguniform(self.name + "alpha", 1e-2, 100)
        self.fit_prior = trial.suggest_categorical(self.name + "fit_prior",
                                                   [True, False])
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('HistGradientBoostingClassifier_')

        space_gen.generate_number(self.name + "learning_rate",
                                  0.1,
                                  depending_node=depending_node)
        space_gen.generate_number(self.name + "min_samples_leaf",
                                  20,
                                  depending_node=depending_node)
        space_gen.generate_number(self.name + "max_leaf_nodes",
                                  31,
                                  depending_node=depending_node)
        space_gen.generate_number(self.name + "l2_regularization",
                                  1E-10,
                                  depending_node=depending_node)
        space_gen.generate_cat(self.name + "early_stop",
                               ["off", "train", "valid"],
                               "off",
                               depending_node=depending_node)
        space_gen.generate_number(self.name + "n_iter_no_change",
                                  10,
                                  depending_node=depending_node)
        space_gen.generate_number(self.name + "validation_fraction",
                                  0.1,
                                  depending_node=depending_node)

        space_gen.generate_number(self.name + "max_iter",
                                  100,
                                  depending_node=depending_node)
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('GaussianRandomProjection_')

        self.n_components_fraction = trial.suggest_uniform(
            self.name + 'n_components_fraction', 0.0, 1.0)

        self.sparse = False
Beispiel #4
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('OneHotEncoder_')

        self.handle_unknown = 'ignore'

        self.sparse = trial.suggest_categorical(self.name + 'sparse',
                                                [True, False])
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('HistGradientBoostingClassifier_')
        self.loss = "auto"
        self.learning_rate = trial.suggest_loguniform(
            self.name + "learning_rate", 0.01, 1)
        self.min_samples_leaf = trial.suggest_int(self.name +
                                                  "min_samples_leaf",
                                                  1,
                                                  200,
                                                  log=True)
        self.max_depth = None
        self.max_leaf_nodes = trial.suggest_int(self.name + "max_leaf_nodes",
                                                3,
                                                2047,
                                                log=True)
        self.max_bins = 255
        self.l2_regularization = trial.suggest_loguniform(
            self.name + "l2_regularization", 1E-10, 1)
        self.early_stop = trial.suggest_categorical(self.name + "early_stop",
                                                    ["off", "train", "valid"])
        self.tol = 1e-7
        self.scoring = "loss"
        self.vn_iter_no_change = trial.suggest_int(
            self.name + "n_iter_no_change", 1, 20)
        self.validation_fraction = trial.suggest_uniform(
            self.name + "validation_fraction", 0.01, 0.4)
        self.classes_ = np.unique(y.astype(int))

        #new
        self.max_iter = trial.suggest_int(self.name + "max_iter",
                                          10,
                                          512,
                                          log=True)
Beispiel #6
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('SVC_')

        space_gen.generate_number(self.name + "C",
                                  1.0,
                                  depending_node=depending_node)
        category_kernel = space_gen.generate_cat(self.name + "kernel",
                                                 ["rbf", "poly", "sigmoid"],
                                                 "rbf",
                                                 depending_node=depending_node)

        space_gen.generate_number(self.name + "degree",
                                  3,
                                  depending_node=category_kernel[1])
        space_gen.generate_number(self.name + "gamma",
                                  0.1,
                                  depending_node=depending_node)
        space_gen.generate_number(
            self.name + "coef0", 0,
            depending_node=depending_node)  #todo: fix if we change to graph
        space_gen.generate_cat(self.name + "shrinking", [True, False],
                               True,
                               depending_node=depending_node)
        space_gen.generate_number(self.name + "tol",
                                  1e-3,
                                  depending_node=depending_node)
Beispiel #7
0
    def init_hyperparameters(self, trial, X, y, name_space=None):
        self.name = id_name('RandomForestClassifier_')

        if type(name_space) != type(None):
            self.name += '_' + name_space

        self.criterion = trial.suggest_categorical(self.name + "criterion",
                                                   ["gini", "entropy"])
        self.max_features = trial.suggest_uniform(self.name + "max_features",
                                                  0., 1.)
        self.max_depth = None
        self.min_samples_split = trial.suggest_int(self.name +
                                                   "min_samples_split",
                                                   2,
                                                   20,
                                                   log=False)
        self.min_samples_leaf = trial.suggest_int(self.name +
                                                  "min_samples_leaf",
                                                  1,
                                                  20,
                                                  log=False)
        self.min_weight_fraction_leaf = 0.
        self.max_leaf_nodes = None
        self.min_impurity_decrease = 0.0
        self.bootstrap = trial.suggest_categorical(self.name + "bootstrap",
                                                   [True, False])
        #self.classes_ = 2

        #hyperopt config
        #self.n_estimators = trial.suggest_int(self.name + "n_estimators", 10, 512, log=True)
        self.n_estimators = trial.suggest_int(self.name + "n_estimators",
                                              10,
                                              100,
                                              log=True)
Beispiel #8
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('ExtraTreesClassifier_')
        self.criterion = trial.suggest_categorical(self.name + "criterion",
                                                   ["gini", "entropy"])
        self.max_features = trial.suggest_uniform(self.name + "max_features",
                                                  0., 1.)
        self.min_samples_split = trial.suggest_int(self.name +
                                                   "min_samples_split",
                                                   2,
                                                   20,
                                                   log=False)
        self.min_samples_leaf = trial.suggest_int(self.name +
                                                  "min_samples_leaf",
                                                  1,
                                                  20,
                                                  log=False)
        self.max_depth = None
        self.min_weight_fraction_leaf = 0.
        self.max_leaf_nodes = None
        self.min_impurity_decrease = 0.0
        self.bootstrap = trial.suggest_categorical(self.name + "bootstrap",
                                                   [True, False])
        self.classes_ = np.unique(y.astype(int))

        # hyperopt config
        self.n_estimators = trial.suggest_int(self.name + "n_estimators",
                                              10,
                                              512,
                                              log=True)
Beispiel #9
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('FeatureAgglomeration_')

        space_gen.generate_number(self.name + 'n_components_fraction', 0.5, depending_node=depending_node)
        space_gen.generate_cat(self.name + "linkage", ["ward", "complete", "average"], "ward", depending_node=depending_node)
        space_gen.generate_cat(self.name + "affinity", ["euclidean", "manhattan", "cosine"], "euclidean", depending_node=depending_node)
        space_gen.generate_cat(self.name + "pooling_func", [np.mean, np.median, np.max], np.mean, depending_node=depending_node)
Beispiel #10
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('TruncatedSVD_')

        self.n_components_fraction = trial.suggest_uniform(
            self.name + 'n_components_fraction', 0.0, 1.0)

        self.sparse = False
Beispiel #11
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('PolynomialFeatures_')

        self.degree = trial.suggest_int(self.name + "degree", 2, 3)
        self.interaction_only = trial.suggest_categorical(self.name + "interaction_only", [False, True])
        self.include_bias = trial.suggest_categorical(self.name + "include_bias", [True, False])

        self.sparse = False
Beispiel #12
0
 def generate_hyperparameters(self, space_gen, depending_node=None):
     self.name = id_name('MultinomialNB_')
     space_gen.generate_number(self.name + "alpha",
                               1,
                               depending_node=depending_node)
     space_gen.generate_cat(self.name + "fit_prior", [True, False],
                            True,
                            depending_node=depending_node)
Beispiel #13
0
 def generate_hyperparameters(self, space_gen, depending_node=None):
     self.name = id_name('PrivateLogisticRegression_')
     space_gen.generate_number(self.name + "tol",
                               1e-4,
                               depending_node=depending_node)
     space_gen.generate_number(self.name + "C",
                               1.0,
                               depending_node=depending_node)
Beispiel #14
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('RBFSampler_')

        space_gen.generate_number(self.name + "gamma",
                                  1.0,
                                  depending_node=depending_node)
        space_gen.generate_number(self.name + "n_components",
                                  100,
                                  depending_node=depending_node)
Beispiel #15
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('PCA_')

        self.n_components = trial.suggest_uniform(self.name + "n_components",
                                                  0.5, 0.9999)
        self.whiten = trial.suggest_categorical(self.name + "whiten",
                                                [False, True])

        self.sparse = False
Beispiel #16
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('PCA_')

        space_gen.generate_number(self.name + "n_components",
                                  0.9999,
                                  depending_node=depending_node)
        space_gen.generate_cat(self.name + "whiten", [False, True],
                               False,
                               depending_node=depending_node)
Beispiel #17
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('RBFSampler_')

        self.gamma = trial.suggest_loguniform(self.name + "gamma",
                                              3.0517578125e-05, 8)
        self.n_components = trial.suggest_int(self.name + "n_components",
                                              50,
                                              10000,
                                              log=True)

        self.sparse = False
Beispiel #18
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('PassiveAggressive_')
        self.C = trial.suggest_loguniform(self.name + "C", 1e-5, 10)
        self.fit_intercept = True
        self.loss = trial.suggest_categorical(self.name + "loss",
                                              ["hinge", "squared_hinge"])
        self.tol = trial.suggest_loguniform(self.name + "tol", 1e-5, 1e-1)
        self.average = trial.suggest_categorical(self.name + "average",
                                                 [False, True])

        self.max_iter = trial.suggest_int(self.name + "max_iter",
                                          10,
                                          1024,
                                          log=False)
Beispiel #19
0
 def generate_hyperparameters(self, space_gen, depending_node=None):
     self.name = id_name('LinearSVC_')
     space_gen.generate_cat(self.name + "penalty", ["l1", "l2"],
                            "l2",
                            depending_node=depending_node)
     space_gen.generate_cat(self.name + "loss", ["hinge", "squared_hinge"],
                            "squared_hinge",
                            depending_node=depending_node)
     space_gen.generate_number(self.name + "tol",
                               1e-4,
                               depending_node=depending_node)
     space_gen.generate_number(self.name + "C",
                               1.0,
                               depending_node=depending_node)
 def generate_hyperparameters(self, space_gen, depending_node=None):
     self.name = id_name('DecisionTreeClassifier_')
     space_gen.generate_cat(self.name + "criterion", ["gini", "entropy"],
                            "gini",
                            depending_node=depending_node)
     space_gen.generate_number(self.name + 'max_depth_factor',
                               0.5,
                               depending_node=depending_node)
     space_gen.generate_number(self.name + "min_samples_split",
                               2,
                               depending_node=depending_node)
     space_gen.generate_number(self.name + "min_samples_leaf",
                               1,
                               depending_node=depending_node)
Beispiel #21
0
 def generate_hyperparameters(self, space_gen, depending_node=None):
     self.name = id_name('AdaBoostClassifier_')
     space_gen.generate_number(self.name + "n_estimators",
                               50,
                               depending_node=depending_node)
     space_gen.generate_number(self.name + "learning_rate",
                               0.1,
                               depending_node=depending_node)
     space_gen.generate_cat(self.name + "algorithm", ["SAMME.R", "SAMME"],
                            "SAMME.R",
                            depending_node=depending_node)
     space_gen.generate_number(self.name + "max_depth",
                               1,
                               depending_node=depending_node)
Beispiel #22
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('FeatureAgglomeration_')

        self.n_components_fraction = trial.suggest_uniform(self.name + 'n_components_fraction', 0.0, 1.0)

        self.linkage = trial.suggest_categorical(self.name + "linkage", ["ward", "complete", "average"])

        if self.linkage == 'ward':
            self.affinity = "euclidean"
        else:
            self.affinity = trial.suggest_categorical(self.name + "affinity", ["euclidean", "manhattan", "cosine"])

        self.pooling_func = trial.suggest_categorical(self.name + "pooling_func", [np.mean, np.median, np.max])

        self.sparse = False
Beispiel #23
0
 def init_hyperparameters(self, trial, X, y):
     self.name = id_name('AdaBoostClassifier_')
     self.n_estimators = trial.suggest_int(self.name + "n_estimators",
                                           50,
                                           500,
                                           log=False)
     self.learning_rate = trial.suggest_loguniform(
         self.name + "learning_rate", 0.01, 2)
     self.algorithm = trial.suggest_categorical(self.name + "algorithm",
                                                ["SAMME.R", "SAMME"])
     self.max_depth = trial.suggest_int(self.name + "max_depth",
                                        1,
                                        10,
                                        log=False)
     self.base_estimator = DecisionTreeClassifier(max_depth=self.max_depth)
     self.classes_ = np.unique(y.astype(int))
Beispiel #24
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('SGDClassifier_')

        space_gen.generate_cat(self.name + "loss", ["hinge", "log", "modified_huber", "squared_hinge", "perceptron"], "log", depending_node=depending_node)
        space_gen.generate_cat(self.name + "penalty", ["l1", "l2", "elasticnet"], "l2", depending_node=depending_node)
        space_gen.generate_number(self.name + "alpha", 0.0001, depending_node=depending_node)
        space_gen.generate_number(self.name + "l1_ratio", 0.15, depending_node=depending_node)
        space_gen.generate_number(self.name + "tol", 1e-4, depending_node=depending_node)
        space_gen.generate_number(self.name + "epsilon", 1e-4, depending_node=depending_node)
        category_learn = space_gen.generate_cat(self.name + "learning_rate", ["optimal", "invscaling", "constant"], "invscaling", depending_node=depending_node)

        space_gen.generate_number(self.name + "eta0", 0.01, depending_node=depending_node) #fix if we change to graph
        space_gen.generate_number(self.name + "power_t", 0.5, depending_node=category_learn[1])
        space_gen.generate_cat(self.name + "average", [False, True], False, depending_node=depending_node)

        space_gen.generate_number(self.name + "max_iter", 1000, depending_node=depending_node)
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('SparseRandomProjection_')

        self.n_components_fraction = trial.suggest_uniform(
            self.name + 'n_components_fraction', 0.0, 1.0)

        if trial.suggest_categorical(self.name + 'density_auto',
                                     [True, False]):
            self.density = 'auto'
        else:
            self.density = trial.suggest_uniform(self.name + 'density_def',
                                                 1e-6, 1)

        self.dense_output = trial.suggest_categorical(
            self.name + 'dense_output', [True, False])

        self.sparse = not self.dense_output
Beispiel #26
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('FastICA_')

        self.algorithm = trial.suggest_categorical(self.name + 'algorithm',
                                                   ['parallel', 'deflation'])
        self.whiten = trial.suggest_categorical(self.name + 'whiten',
                                                [False, True])

        self.n_components_fraction = None
        if self.whiten == True:
            self.n_components_fraction = trial.suggest_uniform(
                self.name + 'n_components_fraction', 0.0, 1.0)

        self.fun = trial.suggest_categorical(self.name + 'fun',
                                             ['logcosh', 'exp', 'cube'])

        self.sparse = False
Beispiel #27
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('RandomTreesEmbedding_')

        self.n_estimators = trial.suggest_int(self.name + "n_estimators", 10,
                                              100)
        self.max_depth = trial.suggest_int(self.name + "max_depth", 2, 10)
        self.min_samples_split = trial.suggest_int(
            self.name + "min_samples_split", 2, 20)
        self.min_samples_leaf = trial.suggest_int(
            self.name + "min_samples_leaf", 1, 20)
        self.min_weight_fraction_leaf = 0.0
        self.max_leaf_nodes = None
        self.bootstrap = trial.suggest_categorical(self.name + 'bootstrap',
                                                   [True, False])
        self.sparse_output = trial.suggest_categorical(
            self.name + 'sparse_output', [True, False])

        self.sparse = self.sparse_output
Beispiel #28
0
    def init_hyperparameters(self, trial, X, y):
        self.name = id_name('ConstructionTransformer_')

        #t = ConstructionTransformer(c_max=3, epsilon=-np.inf, scoring=auc, n_jobs=4, model=LogisticRegression(), cv=2, feature_names=attribute_names, feature_is_categorical=categorical_indicator,parameter_grid={'penalty': ['l2'], 'C': [1], 'solver': ['lbfgs'], 'class_weight': ['balanced'], 'max_iter': [10], 'multi_class':['auto']})

        self.c_max = trial.suggest_int(self.name + "c_max", 2, 4)
        self.epsilon = -np.inf
        self.cv = 2
        self.model = LogisticRegression()
        self.parameter_grid = {
            'penalty': ['l2'],
            'C': [1],
            'solver': ['lbfgs'],
            'class_weight': ['balanced'],
            'max_iter': [10],
            'multi_class': ['auto']
        }
        self.n_jobs = 1
Beispiel #29
0
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('SelectKBest')

        space_gen.generate_number(self.name + "k_fraction",
                                  0.5,
                                  depending_node=depending_node)
        category_fs = space_gen.generate_cat(self.name + 'score_func', [
            'chi2', 'f_classif', 'mutual_info', 'ExtraTreesClassifier',
            'LinearSVC', 'variance'
        ],
                                             "chi2",
                                             depending_node=depending_node)

        tree_catgory = category_fs[3]
        lr_catgory = category_fs[4]

        new_name = self.name + '_' + 'ExtraTreesClassifier' + '_'

        space_gen.generate_cat(new_name + "criterion", ["gini", "entropy"],
                               "gini",
                               depending_node=tree_catgory)
        space_gen.generate_number(new_name + "max_features",
                                  0.5,
                                  depending_node=tree_catgory)
        space_gen.generate_number(new_name + "min_samples_split",
                                  2,
                                  depending_node=tree_catgory)
        space_gen.generate_number(new_name + "min_samples_leaf",
                                  1,
                                  depending_node=tree_catgory)
        space_gen.generate_cat(new_name + "bootstrap", [True, False],
                               False,
                               depending_node=tree_catgory)

        new_name = self.name + '_' + 'LinearSVC' + '_'
        space_gen.generate_cat(new_name + "loss", ["hinge", "squared_hinge"],
                               "squared_hinge",
                               depending_node=lr_catgory)
        space_gen.generate_number(new_name + "tol",
                                  1e-4,
                                  depending_node=lr_catgory)
        space_gen.generate_number(new_name + "C",
                                  1.0,
                                  depending_node=lr_catgory)
    def generate_hyperparameters(self, space_gen, depending_node=None):
        self.name = id_name('SparseRandomProjection_')

        space_gen.generate_number(self.name + 'n_components_fraction',
                                  0.1,
                                  depending_node=depending_node)

        category_density = space_gen.generate_cat(
            self.name + 'density_auto', [True, False],
            True,
            depending_node=depending_node)

        space_gen.generate_number(self.name + 'density_def',
                                  'auto',
                                  depending_node=category_density[1])

        space_gen.generate_cat(self.name + 'dense_output', [True, False],
                               False,
                               depending_node=depending_node)