Skip to content

Commit

Permalink
config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
perib committed May 16, 2024
1 parent a007c13 commit bb94241
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
22 changes: 10 additions & 12 deletions tpot2/config/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import sklearn


def get_LogisticRegression_ConfigurationSpace(n_samples, n_features, random_state):

dual = n_samples<=n_features
def get_LogisticRegression_ConfigurationSpace(random_state):

dual = FALSE_SPECIAL_STRING

Expand Down Expand Up @@ -80,7 +78,7 @@ def get_DecisionTreeClassifier_ConfigurationSpace(n_featues, random_state):

space = {
'criterion': Categorical("criterion", ['gini', 'entropy']),
'max_depth': Integer("max_depth", bounds=(1, 2*n_featues)), #max of 20? log scale?
'max_depth': Integer("max_depth", bounds=(1, min(20,2*n_featues))), #max of 20? log scale?
'min_samples_split': Integer("min_samples_split", bounds=(1, 20)),
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 20)),
'max_features': Categorical("max_features", [NONE_SPECIAL_STRING, 'sqrt', 'log2']),
Expand Down Expand Up @@ -145,10 +143,10 @@ def get_SVC_ConfigurationSpace(random_state):
return cs


def get_RandomForestClassifier_ConfigurationSpace(n_features, random_state):
def get_RandomForestClassifier_ConfigurationSpace( random_state):
space = {
'n_estimators': 128, #as recommended by Oshiro et al. (2012
'max_features': Integer("max_features", bounds=(1, max(1, n_features))), #log scale like autosklearn?
'max_features': Float("max_features", bounds=(0.01,1)), #log scale like autosklearn?
'criterion': Categorical("criterion", ['gini', 'entropy']),
'min_samples_split': Integer("min_samples_split", bounds=(2, 20)),
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 20)),
Expand Down Expand Up @@ -211,7 +209,7 @@ def get_ExtraTreesClassifier_ConfigurationSpace(random_state):
space = {
'n_estimators': 100,
'criterion': Categorical("criterion", ["gini", "entropy"]),
'max_features': Float("max_features", bounds=(0.05, 1.00)),
'max_features': Float("max_features", bounds=(0.01, 1.00)),
'min_samples_split': Integer("min_samples_split", bounds=(2, 20)),
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 20)),
'bootstrap': Categorical("bootstrap", [True, False]),
Expand Down Expand Up @@ -333,7 +331,7 @@ def get_LinearDiscriminantAnalysis_ConfigurationSpace():

#### Gradient Boosting Classifiers

def get_GradientBoostingClassifier_ConfigurationSpace(n_classes, n_features, random_state):
def get_GradientBoostingClassifier_ConfigurationSpace(n_classes, random_state):
early_stop = Categorical("early_stop", ["off", "valid", "train"])
n_iter_no_change = Integer("n_iter_no_change",bounds=(1,20))
validation_fraction = Float("validation_fraction", bounds=(0.01, 0.4))
Expand All @@ -346,9 +344,9 @@ def get_GradientBoostingClassifier_ConfigurationSpace(n_classes, n_features, ran
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 200)),
'min_samples_split': Integer("min_samples_split", bounds=(2, 20)),
'subsample': Float("subsample", bounds=(0.1, 1.0)),
'max_features': Integer("max_features", bounds=(1, max(1, n_features))),
'max_features': Float("max_features", bounds=(0.01, 1.00)),
'max_leaf_nodes': Integer("max_leaf_nodes", bounds=(3, 2047)),
'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'max_depth':NONE_SPECIAL_STRING, # 'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'tol': 1e-4,
}

Expand Down Expand Up @@ -400,7 +398,7 @@ def GradientBoostingClassifier_hyperparameter_parser(params):


#only difference is l2_regularization
def get_HistGradientBoostingClassifier_ConfigurationSpace(n_features, random_state):
def get_HistGradientBoostingClassifier_ConfigurationSpace(random_state):
early_stop = Categorical("early_stop", ["off", "valid", "train"])
n_iter_no_change = Integer("n_iter_no_change",bounds=(1,20))
validation_fraction = Float("validation_fraction", bounds=(0.01, 0.4))
Expand All @@ -413,7 +411,7 @@ def get_HistGradientBoostingClassifier_ConfigurationSpace(n_features, random_sta
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 200)),
'max_features': Float("max_features", bounds=(0.1,1.0)),
'max_leaf_nodes': Integer("max_leaf_nodes", bounds=(3, 2047)),
'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'max_depth':NONE_SPECIAL_STRING, # 'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'l2_regularization': Float("l2_regularization", bounds=(1e-10, 1), log=True),
'tol': 1e-4,
}
Expand Down
16 changes: 8 additions & 8 deletions tpot2/config/get_configspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@



def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_state=None):
def get_configspace(name, n_classes=3, n_samples=1000, n_features=100, random_state=None):
match name:

#autoqtl_builtins.py
Expand All @@ -158,7 +158,7 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta
case "AdaBoostClassifier":
return classifiers.get_AdaBoostClassifier_ConfigurationSpace(random_state=random_state)
case "LogisticRegression":
return classifiers.get_LogisticRegression_ConfigurationSpace(n_samples=n_samples, n_features=n_features, random_state=random_state)
return classifiers.get_LogisticRegression_ConfigurationSpace(random_state=random_state)
case "KNeighborsClassifier":
return classifiers.get_KNeighborsClassifier_ConfigurationSpace(n_samples=n_samples)
case "DecisionTreeClassifier":
Expand All @@ -168,11 +168,11 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta
case "LinearSVC":
return classifiers.get_LinearSVC_ConfigurationSpace(random_state=random_state)
case "RandomForestClassifier":
return classifiers.get_RandomForestClassifier_ConfigurationSpace(n_features=n_features, random_state=random_state)
return classifiers.get_RandomForestClassifier_ConfigurationSpace(random_state=random_state)
case "GradientBoostingClassifier":
return classifiers.get_GradientBoostingClassifier_ConfigurationSpace(n_classes=n_classes, n_features=n_features, random_state=random_state)
return classifiers.get_GradientBoostingClassifier_ConfigurationSpace(n_classes=n_classes, random_state=random_state)
case "HistGradientBoostingClassifier":
return classifiers.get_HistGradientBoostingClassifier_ConfigurationSpace(n_features=n_features, random_state=random_state)
return classifiers.get_HistGradientBoostingClassifier_ConfigurationSpace(random_state=random_state)
case "XGBClassifier":
return classifiers.get_XGBClassifier_ConfigurationSpace(random_state=random_state)
case "LGBMClassifier":
Expand Down Expand Up @@ -232,7 +232,7 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta
case "Perceptron":
return regressors.get_Perceptron_ConfigurationSpace(random_state=random_state)
case "DecisionTreeRegressor":
return regressors.get_DecisionTreeRegressor_ConfigurationSpace(n_features=n_features, random_state=random_state)
return regressors.get_DecisionTreeRegressor_ConfigurationSpace(random_state=random_state)
case "LinearSVR":
return regressors.get_LinearSVR_ConfigurationSpace(random_state=random_state)
case "SVR":
Expand All @@ -244,9 +244,9 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta
case "ExtraTreesRegressor":
return regressors.get_ExtraTreesRegressor_ConfigurationSpace(random_state=random_state)
case "GradientBoostingRegressor":
return regressors.get_GradientBoostingRegressor_ConfigurationSpace(n_features=n_features, random_state=random_state)
return regressors.get_GradientBoostingRegressor_ConfigurationSpace(random_state=random_state)
case "HistGradientBoostingRegressor":
return regressors.get_HistGradientBoostingRegressor_ConfigurationSpace(n_features=n_features, random_state=random_state)
return regressors.get_HistGradientBoostingRegressor_ConfigurationSpace(random_state=random_state)
case "MLPRegressor":
return regressors.get_MLPRegressor_ConfigurationSpace(random_state=random_state)
case "KNeighborsRegressor":
Expand Down
17 changes: 10 additions & 7 deletions tpot2/config/regressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,17 @@ def get_Perceptron_ConfigurationSpace(random_state):



def get_DecisionTreeRegressor_ConfigurationSpace(n_features, random_state):
def get_DecisionTreeRegressor_ConfigurationSpace(random_state):
space = {
'criterion': Categorical("criterion", ['squared_error', 'friedman_mse', 'mae']),
'max_depth': Integer("max_depth", bounds=(1, n_features*2)),
# 'max_depth': Integer("max_depth", bounds=(1, n_features*2)),
'min_samples_split': Integer("min_samples_split", bounds=(2, 21)),
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 21)),
}

if random_state is not None: #This is required because configspace doesn't allow None as a value
space['random_state'] = random_state

return ConfigurationSpace(
space = space
)
Expand Down Expand Up @@ -382,7 +385,7 @@ def GaussianProcessRegressor_hyperparameter_parser(params):
return final_params

###
def get_GradientBoostingRegressor_ConfigurationSpace(n_features, random_state):
def get_GradientBoostingRegressor_ConfigurationSpace(random_state):
early_stop = Categorical("early_stop", ["off", "valid", "train"])
n_iter_no_change = Integer("n_iter_no_change",bounds=(1,20))
validation_fraction = Float("validation_fraction", bounds=(0.01, 0.4))
Expand All @@ -396,9 +399,9 @@ def get_GradientBoostingRegressor_ConfigurationSpace(n_features, random_state):
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 200)),
'min_samples_split': Integer("min_samples_split", bounds=(2, 20)),
'subsample': Float("subsample", bounds=(0.1, 1.0)),
'max_features': Integer("max_features", bounds=(1, max(1, n_features))),
'max_features': Float("max_features", bounds=(0.01, 1.00)),
'max_leaf_nodes': Integer("max_leaf_nodes", bounds=(3, 2047)),
'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'max_depth':NONE_SPECIAL_STRING, #'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'tol': 1e-4,
}

Expand Down Expand Up @@ -443,7 +446,7 @@ def GradientBoostingRegressor_hyperparameter_parser(params):
return final_params

#only difference is l2_regularization
def get_HistGradientBoostingRegressor_ConfigurationSpace(n_features, random_state):
def get_HistGradientBoostingRegressor_ConfigurationSpace(random_state):
early_stop = Categorical("early_stop", ["off", "valid", "train"])
n_iter_no_change = Integer("n_iter_no_change",bounds=(1,20))
validation_fraction = Float("validation_fraction", bounds=(0.01, 0.4))
Expand All @@ -457,7 +460,7 @@ def get_HistGradientBoostingRegressor_ConfigurationSpace(n_features, random_stat
'min_samples_leaf': Integer("min_samples_leaf", bounds=(1, 200)),
'max_features': Float("max_features", bounds=(0.1,1.0)),
'max_leaf_nodes': Integer("max_leaf_nodes", bounds=(3, 2047)),
'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'max_depth':NONE_SPECIAL_STRING, #'max_depth': Integer("max_depth", bounds=(1, 2*n_features)),
'l2_regularization': Float("l2_regularization", bounds=(1e-10, 1), log=True),
'tol': 1e-4,
}
Expand Down

0 comments on commit bb94241

Please sign in to comment.