O'Reilly logo

Test-Driven Machine Learning by Justin Bozonier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developing testable documentation

In this part of the chapter, we'll just explore different classifier algorithms, and learn the ins and outs of each.

Decision trees

Let's start with decision trees. scikit-learn has some great documentation, which you can find at http://scikit-learn.org/stable/. So, let's jump over there, and look up an example that states how to use their decision tree. The following is a test with the details greatly simplified to get to the simplest possible example:

from sklearn.tree import DecisionTreeRegressor def decision_tree_can_predict_perfect_linear_relationship_test(): decision_tree = DecisionTreeRegressor() decision_tree.fit([[1],[1.1],[2]], [[0],[0],[1]]) predicted_value = decision_tree.predict([[-1],[5]]) assert list(predicted_value) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required