O'Reilly logo

Genetic Algorithms and Machine Learning for Programmers by Frances Buontempo

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

Did It Work?

It’s time to check how well the classifier did. You can measure the performance of classifiers in various ways. You can find the accuracy by calculating the percentage correctly classified. For numeric data, you can use an error function, such as the mean squared error (MSE) which finds the average of the squares of the errors or difference between the predicted and actual values. For each problem, you need to decide how to test your algorithm.

How well has your decision tree performed? Try it on the four coordinates:

 data = [[0, 0, False], [1, 0, False], [0, 1, True], [1, 1, True]]
 label = [​'x'​, ​'y'​, ​'out'​]
 
 tree = create_tree(data, label)
 print​(as_rule_str(tree, label))

You get this rule:

 if y = 0 then False. ...

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