Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
"""
|
|
|
|
|
To run this, you'll need to have installed.
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
* scikit-learn
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
Does two benchmarks
|
|
|
|
|
|
|
|
|
|
First, we fix a training set, increase the number of
|
|
|
|
|
samples to classify and plot number of classified samples as a
|
|
|
|
|
function of time.
|
|
|
|
|
|
|
|
|
|
In the second benchmark, we increase the number of dimensions of the
|
|
|
|
|
training set, classify a sample and plot the time taken as a function
|
|
|
|
|
of the number of dimensions.
|
|
|
|
|
"""
|
|
|
|
|
import numpy as np
|
|
|
|
|
import pylab as pl
|
|
|
|
|
import gc
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
# to store the results
|
|
|
|
|
scikit_classifier_results = []
|
|
|
|
|
scikit_regressor_results = []
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
mu_second = 0.0 + 10 ** 6 # number of microseconds in a second
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
|
2011-08-09 19:45:53 +08:00
|
|
|
def bench_scikit_tree_classifier(X, Y):
|
2013-05-28 14:27:20 +08:00
|
|
|
"""Benchmark with scikit-learn decision tree classifier"""
|
2011-09-03 17:35:07 +08:00
|
|
|
|
2011-09-03 20:04:27 +08:00
|
|
|
from sklearn.tree import DecisionTreeClassifier
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
gc.collect()
|
|
|
|
|
|
|
|
|
|
# start time
|
|
|
|
|
tstart = datetime.now()
|
2011-08-09 19:45:53 +08:00
|
|
|
clf = DecisionTreeClassifier()
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
clf.fit(X, Y).predict(X)
|
|
|
|
|
delta = (datetime.now() - tstart)
|
|
|
|
|
# stop time
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
scikit_classifier_results.append(
|
|
|
|
|
delta.seconds + delta.microseconds / mu_second)
|
|
|
|
|
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
def bench_scikit_tree_regressor(X, Y):
|
2013-05-28 14:27:20 +08:00
|
|
|
"""Benchmark with scikit-learn decision tree regressor"""
|
2011-09-03 17:35:07 +08:00
|
|
|
|
2011-09-04 02:58:20 +08:00
|
|
|
from sklearn.tree import DecisionTreeRegressor
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
gc.collect()
|
|
|
|
|
|
|
|
|
|
# start time
|
|
|
|
|
tstart = datetime.now()
|
|
|
|
|
clf = DecisionTreeRegressor()
|
|
|
|
|
clf.fit(X, Y).predict(X)
|
|
|
|
|
delta = (datetime.now() - tstart)
|
|
|
|
|
# stop time
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
scikit_regressor_results.append(
|
|
|
|
|
delta.seconds + delta.microseconds / mu_second)
|
|
|
|
|
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
2013-02-12 06:11:57 +08:00
|
|
|
print('============================================')
|
|
|
|
|
print('Warning: this is going to take a looong time')
|
|
|
|
|
print('============================================')
|
2011-08-09 19:45:53 +08:00
|
|
|
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
n = 10
|
2011-08-09 19:45:53 +08:00
|
|
|
step = 10000
|
|
|
|
|
n_samples = 10000
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
dim = 10
|
2011-09-04 16:54:21 +08:00
|
|
|
n_classes = 10
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
for i in range(n):
|
2013-02-12 06:11:57 +08:00
|
|
|
print('============================================')
|
|
|
|
|
print('Entering iteration %s of %s' % (i, n))
|
|
|
|
|
print('============================================')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
n_samples += step
|
|
|
|
|
X = np.random.randn(n_samples, dim)
|
2011-09-03 17:35:07 +08:00
|
|
|
Y = np.random.randint(0, n_classes, (n_samples,))
|
2011-08-09 19:45:53 +08:00
|
|
|
bench_scikit_tree_classifier(X, Y)
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
Y = np.random.randn(n_samples)
|
|
|
|
|
bench_scikit_tree_regressor(X, Y)
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
xx = range(0, n * step, step)
|
2013-05-28 14:27:20 +08:00
|
|
|
pl.figure('scikit-learn tree benchmark results')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
pl.subplot(211)
|
|
|
|
|
pl.title('Learning with varying number of samples')
|
|
|
|
|
pl.plot(xx, scikit_classifier_results, 'g-', label='classification')
|
|
|
|
|
pl.plot(xx, scikit_regressor_results, 'r-', label='regression')
|
2013-05-28 14:27:20 +08:00
|
|
|
pl.legend(loc='upper left')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
pl.xlabel('number of samples')
|
2013-05-28 14:27:20 +08:00
|
|
|
pl.ylabel('Time (s)')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
scikit_classifier_results = []
|
|
|
|
|
scikit_regressor_results = []
|
|
|
|
|
n = 10
|
2011-08-09 19:45:53 +08:00
|
|
|
step = 500
|
|
|
|
|
start_dim = 500
|
2011-09-04 16:54:21 +08:00
|
|
|
n_classes = 10
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
|
|
|
|
|
dim = start_dim
|
|
|
|
|
for i in range(0, n):
|
2013-02-12 06:11:57 +08:00
|
|
|
print('============================================')
|
|
|
|
|
print('Entering iteration %s of %s' % (i, n))
|
|
|
|
|
print('============================================')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
dim += step
|
|
|
|
|
X = np.random.randn(100, dim)
|
2011-09-03 17:35:07 +08:00
|
|
|
Y = np.random.randint(0, n_classes, (100,))
|
2011-08-09 19:45:53 +08:00
|
|
|
bench_scikit_tree_classifier(X, Y)
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
Y = np.random.randn(100)
|
|
|
|
|
bench_scikit_tree_regressor(X, Y)
|
|
|
|
|
|
2011-09-04 16:54:21 +08:00
|
|
|
xx = np.arange(start_dim, start_dim + n * step, step)
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
pl.subplot(212)
|
|
|
|
|
pl.title('Learning in high dimensional spaces')
|
|
|
|
|
pl.plot(xx, scikit_classifier_results, 'g-', label='classification')
|
|
|
|
|
pl.plot(xx, scikit_regressor_results, 'r-', label='regression')
|
2013-05-28 14:27:20 +08:00
|
|
|
pl.legend(loc='upper left')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
pl.xlabel('number of dimensions')
|
2013-05-28 14:27:20 +08:00
|
|
|
pl.ylabel('Time (s)')
|
Refactored decision trees and forests to support CART algorithm.
Notable changes:
1) Supports classification and regression
2) 3 classification criteria, 1 regression criterion
3) A new dataset is provided to test regression (Boston House Prices)
4) Weights are removed from the algorithm entirely. If the need for weights can be justified, I would welcome reintroducing them, but for the refactoring I left them out.
5) The subset of dimensions (F) to split on is fixed for the entire tree, not at each node. This is more in line with CART and RandomForests.
6) A max_depth parameter is offered to limit the size of the constructed trees.
7) Randomisation is fixed with python's random module, but can be seeded.
8) For classification, the number of classes must be provided when the tree is constructed. This is because the tree cannot necessarily infer the correct number of labels at the time of training if only a subset of the data is used for individual trees.
9) For classification, labels are not normalised internally. Labels must be provided to the algorithm in the range [0, ..., K)
10) For classification, the leaf nodes retain the distribution of classes. This means that it is possible to query the tree for the probability distribution of a test sample
2011-07-29 19:20:03 +08:00
|
|
|
pl.axis('tight')
|
|
|
|
|
pl.show()
|