# 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, where it's written

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

I have not yet learned calculus, so I can't understand this formula. So, can someone please explain what the calculation means?

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

$$\sum$$ - there just means sum. It is the 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 taking the 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.

The $$\sum$$ means that they take a sum of the squared difference of each pair of expected/predicted values ($$e_i$$) and actual values ($$a_i$$)

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.