Decision Trees

Machine Learning para finanzas con Python

Nathan George

Data Science Professor

Decision trees

basic decision tree

Machine Learning para finanzas con Python

Decision trees

decision tree with targets

Machine Learning para finanzas con Python

Decision tree splits

categorical decision tree split

Machine Learning para finanzas con Python

Decision tree splits

numerical decision tree split

Machine Learning para finanzas con Python

Bad tree

bad regression split

Machine Learning para finanzas con Python

Good tree

good regression split

Machine Learning para finanzas con Python

Decision tree regression

decision tree predictions

Machine Learning para finanzas con Python

Regression trees

from sklearn.tree import DecisionTreeRegressor

decision_tree = DecisionTreeRegressor(max_depth=5)

decision_tree.fit(train_features, train_targets)
Machine Learning para finanzas con Python

Decision tree hyperparameters

max depth of trees

Machine Learning para finanzas con Python

Max depth of 3

max depth of 3 decision tree

Machine Learning para finanzas con Python

Evaluate model

print(decision_tree.score(train_features, train_targets))
print(decision_tree.score(test_features, test_targets))
0.6662215501032416
-0.08917300191734268
train_predictions = decision_tree.predict(train_features)
test_predictions = decision_tree.predict(test_features)
plt.scatter(train_predictions, train_targets, label='train')
plt.scatter(test_predictions, test_targets, label='test')
plt.legend()
plt.show()
Machine Learning para finanzas con Python

predictions vs actual

Machine Learning para finanzas con Python

Grow some trees!

Machine Learning para finanzas con Python

Preparing Video For Download...