Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I'm training some neural networks using NEAT C++, and would like to use the cross-entropy error function: $$E = -t\ln(y) -(1-t)\ln(1-y)$$ to train a network for a two-class classification problem.

NEAT C++ is a C++ library that allows one to use a special kind of neuro evolution (namely that of augmenting topologies) to train the networks. Yet to be able to use it, one needs to define a fitness function (and not an error function, such as the one above).

Question:

How can I construct a fitness function from the cross-entropy error function?

Everything below this line is wrong I guess because $E\in [0,\infty]$, and thus it's impossible to define a maximum. How should I do it then?


I was thinking about this: calculate the maximum error $E_{\text{max}}$ somehow and define the fitness, given a certain network output $y$, as: $$f(y)=E_{\text{max}} - E(y)$$ This way the fitness will be $0$ when $E(y)=E_{\text{max}}$ and it should reach a maximum if $E(y)=0$.

Is this the right method? If so how do I calculate the maximum error $E_{\text{max}}$?

note: NEAT does not allow the use of negative fitness functions, so using $f(y)=-E(y)$ would not work. Also I would like to refrain from using arbitrary stuff such as $f(y)=10000000 - E(y)$.

share|improve this question
    
if you take exponential of -E, isn't it the likelihood, thus always positive with the same rank ordering? –  Memming Apr 11 '12 at 15:09
    
@Memming: how stupid of me not to think about that... –  romeovs Apr 11 '12 at 15:15
    
@Memming This would lead to $E=y^t(1-y)^{1-t}$. But then wouldn't that be the same as using the absolute distance as error $E = t-y$ and defining the fitness as I did above: $f(y) = E_{\text{max}} - E(y)$. Because $t$ can only be $0$ or $1$, one of $y^{1-t}$ and $y^t$ will equal $1$, and for the other one the exponent is $1$, leaving $f=y$ or $f=(1-y)$ depending on the value of $t$. –  romeovs Apr 11 '12 at 15:24

2 Answers 2

First of all: NEAT is an algorithm that is usually used for reinforcement learning. I guess it won't work very well in your case. You should rather find a good network architecture by cross-validation and train your network with stochastic gradient descent, conjugate gradient, ...

Since it is just a fitness function it usually does not matter if it has an upper bound. You almost certainly will not find a perfect solution in every classification problem. So you should think about another stop criterion than "find the maximal fitness".

However, you could take -E. Its upper bound is 0.

share|improve this answer
    
$-E$ wont't work because, for some reason, NEAT doesn't play well with negative fitness. Also, this is for a school project so wheter NEAT is the best choice doesn't matter very much. What would you recommend for stopping criterium? –  romeovs Apr 17 '12 at 19:58
    
@alfa NEAT is genetic algorithm for evolving neural networks, see the wiki page, although it wouldn't surprise me if there was a similarly named RL algorithm which is causing the confusion. –  alto Jul 14 '12 at 12:24
    
You can find some publications about NEAT at the NEAT user page (cs.ucf.edu/~kstanley/neat.html#papers). Its original purpose was reinforcement learning and I have never seen anything about NEAT and supervised learning. –  alfa Jul 14 '12 at 13:03
    
@alfa I see I was the one confused, sorry about that. So, I know next to nothing about GAs and I'm having trouble picturing how a optimization technique which doesn't explicitly work with the form of the function being optimized can be "for" reinforcement learning. Mind explaining? –  alto Jul 14 '12 at 15:15
    
I did not really understand this question. Can you rephrase it? –  alfa Jul 14 '12 at 18:17

You'll also see the function you've described referred to as the log loss in the machine learning literature. It is a loss function, you do not want to maximize it, you want to minimize it.

If you have a minimization problem, you can simply negate it to obtain a maximization problem.

Since you need non-negative values just add the minimum value of your negated objective. You can find this minimum because your data is finite, i.e. the worst you can do is get everything wrong.

edit: An alternative, still assuming your problem is binary prediction, would be to simply maximize $$\sum\mathbf{1}\{y = t\},$$ since you generally don't need a differentiable function for genetic algorithms anyway.

share|improve this answer
1  
Speaking from experience, it helps if fitness functions are smooth. Just minimizing the empirical risk will probably fail. –  bayerj Sep 12 '12 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.