## Making Algorithms Useful

I’m currently engaged writing Machine Learning for Dummies. The book is interesting because it turns math into something more than a way to calculate. Machine learning is about having inputs and a desired result, and then asking the machine to create an algorithm that will produce the desired result from the inputs. It’s about generalization. You know the specific inputs and the specific results, but you want an algorithm that will provide similar results given similar inputs for any set of random inputs. This is more than just math. In fact, there are five schools of thought (tribes) regarding machine learning algorithms that Luca and I introduce you to in Machine Learning for Dummies:

• Symbolists: The origin of this tribe is in logic and philosophy. This group relies on inverse deduction to solve problems.
• Connectionists: The origin of this tribe is in neuroscience. This group relies on backpropagation to solve problems.
• Evolutionaries: The origin of this tribe is in evolutionary biology. This group relies on genetic programming to solve problems.
• Bayesians: This origin of this tribe is in statistics. This group relies on probabilistic inference to solve problems.
• Analogizers: The origin of this tribe is in psychology. This group relies on kernel machines to solve problems.

Of course, the problem with any technology is making it useful. I’m not talking about useful in a theoretical sense, but useful in a way that affects everyone. In other words, you must create a need for the technology so that people will continue to fund it. Machine learning is already part of many of the things you do online. For example, when you go to Amazon and buy a product, then Amazon makes suggestions on products that you might want to add to your cart, you’re seeing the result of machine learning. Part of the content for the chapters of our book is devoted to pointing out these real world uses for machine learning.

## Using CodeBlocks 10.05 – Part 6

This post is a continuation of the series that began with . The purpose is to help people use CodeBlocks 10.05 with , which is currently written to rely on CodeBlocks 8.02 (which is actually the previous edition, despite the odd numbering disparity). You can find a complete list of these posts in the C++ All-in-One for Dummies category archive. This post starts with a review of the updates for the source code found in Book IV Chapter 5.

There is a section entitled, “Templatizing a Function” that begins on page 528. You can see the code for this example in \Author\BookIV\Chapter05\FunctionOverloadingAndTemplates. The initial example is designed to fail, as explained on page 531. You’ll see the same error message and recommendations for both versions of CodeBlocks. In order to see this example work, you must comment out the line that reads:

`cout << AbsoluteValue(10.5) << endl;`

by highlighting the line of code and pressing Ctrl+Shift+C or by choosing Edit > Comment. Of course, you can simply add the comment manually by typing // at the beginning of the line. You must also comment these two functions out:

`int` `AbsoluteValue(``int` `x)`
`{`
`    ``if` `(x >= 0)`
`        ``return` `x;`
`    ``else`
`        ``return` `-x;`
`}`

`float` `AbsoluteValue(``float` `x)`
`{`
`    ``if` `(x >= 0)`
`        ``return` `x;`
`    ``else`
`        ``return` `-x;`
`}`

After you comment these lines out, you can uncomment the templated version of the function:

`template` `<``typename` `T> T AbsoluteValue(T x)`
`{`
`    ``if` `(x >= 0)`
`        ``return` `x;`
`    ``else`
`        ``return` `-x;`
`}`

by highlighting the required lines of code and pressing Ctrl+Shift+X or choosing Edit > Uncomment. In addition, you must uncomment these lines of code to exercise the template:

`cout << AbsoluteValue<``int``>(10) << endl;`
`cout << AbsoluteValue<``float``>(10.5) << endl;`

At this point, the example will compile and run as expected. You’ll receive the same results in both CodeBlocks 8.02 and 10.05. Because so many people have complained about this particular example, I plan to provide two completely different source code files for the next edition of the book (so it won’t be necessary to comment/uncomment anything). Even so, the lines you must uncomment are clearly marked in the current source code file. The example found in the \Author\BookIV\Chapter05\ImFree folder requires similar commenting and uncommenting to see the full potential of the example, but this example doesn’t produce an error at the outset. The other examples in this chapter should work precisely as expected.

On to Book IV Chapter 6 (the last chapter in this mini-book). On page 555 you see Listing 6-8, which contains the code for \Author\BookIV\Chapter06\Sets2. This example won’t currently compile properly and you’ll find the explanation on page 557. In order to run, you must add another library, algorithm, to the group so that the list of includes looks like this:

`#include <iostream>`
`#include <set>`
`#include <algorithm>`

All of the other examples in this chapter run in CodeBlocks 10.05 without a problem on my system (let me know if you experience any problems on your system). In the next post I’ll start
with Book V Chapter 1. In the meantime, let me know if you have any