# What does the formula $1-\sum_i(e_i-a_i)^2$ mean in this NEAT Python API?

I have looked at the documentation for the NEAT Python API found here, but it shows calculus like this:

The error for each genome is $$1-\sum_i(e_i-a_i)^2$$

I haven't learned calculus at the moment. So, can someone please explain what the calculation means?

• Hi and welcome to this community! This website is better suited for more specific questions. For example, you could ask a question regarding a specific concept regarding NEAT. – nbro Apr 19 at 14:09
• @nbro Thanks! I have added more on what concepts are confusing me the most in a recent edit. – A Twizzler Apr 19 at 14:59
• I removed the rest of the post. I think the link to the Python API is not correct. – nbro Apr 19 at 15:08
• @nbro the link doesn't work or the source is wrong? – A Twizzler Apr 19 at 15:28
• Maybe this page? The explanation is in the text, though. – Philip Raeisghasem Apr 19 at 18:18

The Sigma means that they take a sum of the squared difference of each pair of expected/predicted values (e) and actual values (a)

1 - that gives them an error metric of how far off they are from their desired result. The goal is generally to optimize the algorithms against such an error function, in this case, to get it as close to one as possible.

$$1-\sum_i(e_i-a_i)^2$$

$$\sum$$ - there just means sum. It is greek letter for S. You can rewrite the above formula as

$$1 -[(e_1 - a_1)^2+(e_2-a_2)^2+(e_3-a_3)^2+\ldots ]$$

$$\sum$$ just helps us avoid writing dozens of $$+$$ signs. Read more here.

What they are doing here is subtracting taking difference of expected value $$e_1$$ and the actual value $$a_1$$ for the 1st example and so on. The difference can be positive ($$e_1 > a_1$$) or negative ($$e_1 < a_1$$), so usually we square the difference to make it positive number.

The rest is there in the docs. Try putting in concrete imagined values for $$a_i$$ and $$e_i$$.

It sums the squared error for the output vs the expected output, this isnt something you need to do for each experiment they are simply telling you the metric they are using as fitness for the genomes in the xor example experiment, in other experiments you could use something else. If you were training it to play video games you set your fitness to be a numerical representation of how well the genome played the game, so you dont always need to have an expected value as long as your fitness function uses a meaningful metric as the fitness value.