Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions autosklearn/metalearning/metafeatures/metafeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def _calculate(self, X, y, categorical):
class LandmarkLDA(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.discriminant_analysis
if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down Expand Up @@ -690,7 +690,7 @@ class LandmarkNaiveBayes(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.naive_bayes

if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down Expand Up @@ -719,7 +719,7 @@ class LandmarkDecisionTree(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.tree

if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down Expand Up @@ -755,7 +755,7 @@ class LandmarkDecisionNodeLearner(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.tree

if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down Expand Up @@ -784,7 +784,7 @@ class LandmarkRandomNodeLearner(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.tree

if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down Expand Up @@ -836,7 +836,7 @@ class Landmark1NN(MetaFeature):
def _calculate(self, X, y, categorical):
import sklearn.neighbors

if len(y.shape) == 1 or y.shape[1] == 1:
if type(y) in ('binary', 'multiclass'):
kf = sklearn.model_selection.StratifiedKFold(n_splits=5)
else:
kf = sklearn.model_selection.KFold(n_splits=5)
Expand Down
54 changes: 33 additions & 21 deletions autosklearn/pipeline/components/classification/extra_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,19 @@ def __init__(self, criterion, min_samples_leaf,
class_weight=None):

self.n_estimators = self.get_max_iter()
if criterion not in ("gini", "entropy"):
raise ValueError("'criterion' is not in ('gini', 'entropy'): "
"%s" % criterion)
self.criterion = criterion

if check_none(max_depth):
self.max_depth = None
else:
self.max_depth = int(max_depth)
if check_none(max_leaf_nodes):
self.max_leaf_nodes = None
else:
self.max_leaf_nodes = int(max_leaf_nodes)

self.min_samples_leaf = int(min_samples_leaf)
self.min_samples_split = int(min_samples_split)
self.max_features = float(max_features)
self.bootstrap = check_for_bool(bootstrap)
self.min_weight_fraction_leaf = float(min_weight_fraction_leaf)
self.min_impurity_decrease = float(min_impurity_decrease)
self.max_depth = max_depth
self.max_leaf_nodes = max_leaf_nodes
self.min_samples_leaf = min_samples_leaf
self.min_samples_split = min_samples_split
self.max_features = max_features
self.bootstrap = bootstrap
self.min_weight_fraction_leaf = min_weight_fraction_leaf
self.min_impurity_decrease = min_impurity_decrease
self.oob_score = oob_score
self.n_jobs = int(n_jobs)
self.n_jobs = n_jobs
self.random_state = random_state
self.verbose = int(verbose)
self.verbose = verbose
self.class_weight = class_weight
self.estimator = None

Expand All @@ -65,6 +54,29 @@ def iterative_fit(self, X, y, sample_weight=None, n_iter=1, refit=False):

if self.estimator is None:
max_features = int(X.shape[1] ** float(self.max_features))
if self.criterion not in ("gini", "entropy"):
raise ValueError("'criterion' is not in ('gini', 'entropy'): "
"%s" % self.criterion)

if check_none(self.max_depth):
self.max_depth = None
else:
self.max_depth = int(self.max_depth)
if check_none(self.max_leaf_nodes):
self.max_leaf_nodes = None
else:
self.max_leaf_nodes = int(self.max_leaf_nodes)

self.min_samples_leaf = int(self.min_samples_leaf)
self.min_samples_split = int(self.min_samples_split)
self.max_features = float(self.max_features)
self.min_impurity_decrease = float(self.min_impurity_decrease)
self.min_weight_fraction_leaf = float(self.min_weight_fraction_leaf)
self.oob_score = check_for_bool(self.oob_score)
self.bootstrap = check_for_bool(self.bootstrap)
self.n_jobs = int(self.n_jobs)
self.verbose = int(self.verbose)

self.estimator = ETC(n_estimators=n_iter,
criterion=self.criterion,
max_depth=self.max_depth,
Expand Down
24 changes: 13 additions & 11 deletions autosklearn/pipeline/components/regression/extra_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ class ExtraTreesRegressor(
):
def __init__(self, criterion, min_samples_leaf,
min_samples_split, max_features, bootstrap, max_leaf_nodes,
max_depth, min_impurity_decrease, oob_score=False, n_jobs=1,
random_state=None, verbose=0):
max_depth, min_weight_fraction_leaf, min_impurity_decrease,
oob_score=False, n_jobs=1, random_state=None, verbose=0):

self.n_estimators = self.get_max_iter()
self.criterion = criterion
self.max_depth = max_depth
self.max_leaf_nodes = max_leaf_nodes
self.min_samples_leaf = min_samples_leaf
self.min_samples_split = min_samples_split
self.max_features = max_features
self.min_impurity_decrease = min_impurity_decrease
self.bootstrap = bootstrap
self.max_depth = max_depth
self.min_weight_fraction_leaf = min_weight_fraction_leaf
self.min_impurity_decrease = min_impurity_decrease
self.oob_score = oob_score
self.n_jobs = n_jobs
self.random_state = random_state
Expand All @@ -38,14 +39,16 @@ def __init__(self, criterion, min_samples_leaf,
def get_max_iter():
return 512

def get_current_iter(self):
return self.estimator.n_estimators

def iterative_fit(self, X, y, n_iter=1, refit=False):
from sklearn.ensemble import ExtraTreesRegressor as ETR

if refit:
self.estimator = None

if self.estimator is None:

self.n_estimators = int(self.n_estimators)
if self.criterion not in ("mse", "friedman_mse", "mae"):
raise ValueError(
Expand All @@ -66,6 +69,8 @@ def iterative_fit(self, X, y, n_iter=1, refit=False):
self.min_samples_split = int(self.min_samples_split)
self.max_features = float(self.max_features)
self.min_impurity_decrease = float(self.min_impurity_decrease)
self.min_weight_fraction_leaf = float(self.min_weight_fraction_leaf)
self.oob_score = check_for_bool(self.oob_score)
self.bootstrap = check_for_bool(self.bootstrap)
self.n_jobs = int(self.n_jobs)
self.verbose = int(self.verbose)
Expand All @@ -78,6 +83,7 @@ def iterative_fit(self, X, y, n_iter=1, refit=False):
bootstrap=self.bootstrap,
max_features=self.max_features,
max_leaf_nodes=self.max_leaf_nodes,
min_weight_fraction_leaf=self.min_weight_fraction_leaf,
min_impurity_decrease=self.min_impurity_decrease,
oob_score=self.oob_score,
n_jobs=self.n_jobs,
Expand All @@ -103,11 +109,6 @@ def predict(self, X):
raise NotImplementedError
return self.estimator.predict(X)

def predict_proba(self, X):
if self.estimator is None:
raise NotImplementedError()
return self.estimator.predict_proba(X)

@staticmethod
def get_properties(dataset_properties=None):
return {'shortname': 'ET',
Expand All @@ -131,6 +132,7 @@ def get_hyperparameter_search_space(dataset_properties=None):
"max_features", 0.1, 1.0, default_value=1)

max_depth = UnParametrizedHyperparameter(name="max_depth", value="None")
min_weight_fraction_leaf = UnParametrizedHyperparameter('min_weight_fraction_leaf', 0.)
max_leaf_nodes = UnParametrizedHyperparameter("max_leaf_nodes", "None")

min_samples_split = UniformIntegerHyperparameter(
Expand All @@ -146,7 +148,7 @@ def get_hyperparameter_search_space(dataset_properties=None):

cs.add_hyperparameters([criterion, max_features,
max_depth, max_leaf_nodes, min_samples_split,
min_samples_leaf, min_impurity_decrease,
min_samples_leaf, min_impurity_decrease, min_weight_fraction_leaf,
bootstrap])

return cs
Loading