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
6 changes: 3 additions & 3 deletions autosklearn/ensembles/ensemble_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def _calculate_weights(self):
def _sorted_initialization(self, predictions, labels, n_best):
perf = np.zeros([predictions.shape[0]])

for i, p in enumerate(predictions):
perf[i] = calculate_score(labels, predictions, self.task_type,
self.metric, predictions.shape[1])
for idx, prediction in enumerate(predictions):
perf[idx] = calculate_score(labels, prediction, self.task_type,
self.metric, predictions.shape[1])

indices = np.argsort(perf)[perf.shape[0] - n_best:]
return indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def fit(self, X, y, sample_weight=None):

self.max_features = float(self.max_features)
if self.max_depth == "None":
self.max_depth = None
max_depth = self.max_depth = None
else:
num_features = X.shape[1]
self.max_depth = int(self.max_depth)
max_depth = max(1, int(np.round(self.max_depth * num_features, 0)))
self.min_samples_split = int(self.min_samples_split)
self.min_samples_leaf = int(self.min_samples_leaf)
Expand Down
3 changes: 2 additions & 1 deletion autosklearn/pipeline/components/regression/decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def fit(self, X, y, sample_weight=None):

self.max_features = float(self.max_features)
if self.max_depth == "None":
self.max_depth = None
max_depth = self.max_depth = None
else:
num_features = X.shape[1]
self.max_depth = int(self.max_depth)
max_depth = max(1, int(np.round(self.max_depth * num_features, 0)))
self.min_samples_split = int(self.min_samples_split)
self.min_samples_leaf = int(self.min_samples_leaf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ class DecisionTreetComponentTest(unittest.TestCase):
def test_default_configuration(self):
for i in range(10):
predictions, targets = _test_classifier(DecisionTree)
self.assertAlmostEqual(0.92,
self.assertAlmostEqual(0.62,
sklearn.metrics.accuracy_score(predictions,
targets))

def test_default_configuration_sparse(self):
for i in range(10):
predictions, targets = _test_classifier(DecisionTree, sparse=True)
self.assertAlmostEqual(0.69999999999999996,
self.assertAlmostEqual(0.41999999999999998,
sklearn.metrics.accuracy_score(predictions,
targets))

def test_default_configuration_predict_proba(self):
for i in range(10):
predictions, targets = _test_classifier_predict_proba(
DecisionTree)
self.assertAlmostEqual(0.28069887755912964,
self.assertAlmostEqual(0.51333963481747835,
sklearn.metrics.log_loss(targets, predictions))

def test_default_configuration_binary(self):
Expand All @@ -43,7 +43,7 @@ def test_default_configuration_multilabel(self):
predictions, targets = _test_classifier(
DecisionTree, make_multilabel=True)
print(predictions, targets)
self.assertAlmostEqual(0.94120857699805072,
self.assertAlmostEqual(0.81108108108108112,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand All @@ -52,7 +52,7 @@ def test_default_configuration_multilabel_predict_proba(self):
predictions, targets = _test_classifier_predict_proba(
DecisionTree, make_multilabel=True)
self.assertEqual(predictions.shape, ((50, 3)))
self.assertAlmostEqual(0.94589326168273546,
self.assertAlmostEqual(0.83333333333333337,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_weighting_effect(self):

for name, clf, acc_no_weighting, acc_weighting in \
[('adaboost', AdaboostClassifier, 0.709, 0.658),
('decision_tree', DecisionTree, 0.683, 0.701),
('decision_tree', DecisionTree, 0.724, 0.692),
('extra_trees', ExtraTreesClassifier, 0.812, 0.8),
('gradient_boosting', GradientBoostingClassifier,
0.800, 0.760),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class DecisionTreetComponentTest(unittest.TestCase):
def test_default_configuration(self):
for i in range(10):
predictions, targets = _test_regressor(DecisionTree,)
self.assertAlmostEqual(0.14886750572325669,
self.assertAlmostEqual(0.1564592449511697,
sklearn.metrics.r2_score(targets,
predictions))

def test_default_configuration_sparse(self):
for i in range(10):
predictions, targets = _test_regressor(DecisionTree, sparse=True)
self.assertAlmostEqual(0.021778487309118133,
self.assertAlmostEqual(-0.020818312539637507,
sklearn.metrics.r2_score(targets,
predictions))