Eval Dilemma

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: Eval Dilemma

Post by MattieShoes »

Okay, excellent!

One question... Say our result is 50% and the error bar calculation comes out to 10%. Would they go from 40-60% or from 45-55%?

I'm assuming our hypothesis is that the engines are equal and we're trying to disprove it by having the difference be larger than the gauntlet error bar. So I made up some numbers for playing with using 240 games and the win% specified:

Code: Select all

A: +30 -144 =66 (.2625)
B: +38 -129 =73 (.31042)
Diff = .04792

1-Sigma
     A: 2.281% error bar
     B: 2.398% error bar

     For the gauntlet:
     3.309%
So for this confidence interval, we've disproved the null hypothesis, right?

ninety-five
     A: 4.562%
     B: 4.796%

     For the gauntlet:
     6.619%
So for this confidence interval, we have NOT disproved the null hypothesis, right?
So the borderline confidence interval is somewhere between 84% and 95%, assuming I haven't made any blunders...
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: Eval Dilemma

Post by MattieShoes »

I'm poking around on a spreadsheet trying to make everything stick in my brain. Assuming I'm interpreting what Dr. Muller said correctly (dangerous assumption, I know)...

For 52% score vs 48% score:
Assuming 0% draws, it would take about 1228 games
Assuming 35% draws, it would take about 811 games

For very raw engines where the difference might be extreme, testing with 95% confidence interval still seems viable without a setup like Dr. Hyatt has. for example, going 25% vs 35% score would be more like 95 games for 95% confidence interval.
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: Eval Dilemma

Post by diep »

michiguel wrote:
diep wrote:
michiguel wrote:
diep wrote:
hgm wrote:
MattieShoes wrote:Can you or anybody point me to how the error bars are calculated?
I think the rule-of-thumb Error = 40%/sqrt(numberOfGames) is accurate enough in practice, for scores in the 65%-35% range. (This is for the 1-sigma or 84% confidence level; for 95% confidence, double it.) For very unbalanced scores, you would have to take into account the fact that the 40% goes down; the exact formula for this is

100%*sqrt(score*(1-score) - 0.25*drawFraction)

where the score is given as a fraction. The 40% is based on 35% draws, and a score of 0.5. In the case mentioned (score around 0.25, presumably 15% win and 20% draws, you would get 100%*sqrt(0.25*0.75-0.25*0.2) = 37%. So in 240 games you woud have 2.4% error bar (1 sigma).

When comparing the results from two independent gauntlets, the error bar in the diffrence is the Pythagorean sum of the individua error bars (i.e. sqrt(error1^2 + error2^2) ). For results that had equal numbers of games, this means multiplying the individual error bars by sqrt(2).
To get a score difference of 30% (35% ==> 65%) that's so big, that if you add just 1 pattern to your evaluation with such a huge impact, that obviously we might hope that's not the 'average pattern' that you add.

More likely it is that you see a score difference of 1 point at a 200 games when adding just 1 tiny pattern.

Vincent
He was not talking about increases from 35% to 65%. The formula is valid if both score A and score B (from versions A and B) are within 35% to 65%. In other words, if score A is 48% and score B is 52%, you can apply the formula. If score A is 8% and score B is 12%, you cannot.

Miguel
If A scores 48% and B scores 52%, that's basically blowing 2 games with maybe in total just 2 very bad moves, as that can give a 4 point swing in total.

First of all odds these 2 bad moves were caused by the specific pattern is tiny. It could be some fluctuation or book learning or whatever effect.

So you really soon will conclude you need THOUSANDS of games for real good statistical significance. I'm going usually for 95%.

Vincent
Going from 50-50 to 52-48 is an increase of ~15 Elo points. Yes, you need thousands of games to make sure it is real with a good level of confidence.

Miguel
Additionally they have to be preferably on the hardware and time control you want to play tournament in.

Jonathan Schaeffer: "You have to test with what you play".
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Eval Dilemma

Post by mcostalba »

Edsel Apostol wrote:
Gian-Carlo Pascutto wrote:
240 games / 4 opponents = 60 games per program.

With 60 games per program it is completely meaningless to talk about "perform better against this or that".

Your problem is that you do not respect statistics.
I know its too few games. I would have run tons of games if I do have the resources but I don't. I mostly rely on intuition to decide from the small data that I have which is better.
If I were you probably I would try to test only against previous version of your engine instead of a gauntlet of engines.

240 games are too few in any case and I know that playing against one engine only can be misleading but at least it would not seem to me totally unuseful.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: Eval Dilemma

Post by Edsel Apostol »

mcostalba wrote:
Edsel Apostol wrote:
Gian-Carlo Pascutto wrote:
240 games / 4 opponents = 60 games per program.

With 60 games per program it is completely meaningless to talk about "perform better against this or that".

Your problem is that you do not respect statistics.
I know its too few games. I would have run tons of games if I do have the resources but I don't. I mostly rely on intuition to decide from the small data that I have which is better.
If I were you probably I would try to test only against previous version of your engine instead of a gauntlet of engines.

240 games are too few in any case and I know that playing against one engine only can be misleading but at least it would not seem to me totally unuseful.
I don't know if playing against previous versions will produce significant results. There are discussions here before about the merit of testing against previous versions. Maybe Bob, HG and the other experts here could clarify this.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: Eval Dilemma

Post by Edsel Apostol »

michiguel wrote:
Edsel Apostol wrote:
bob wrote:
Edsel Apostol wrote:I guess some of you may have encountered this. It's somewhat annoying. I'm currently in the process of trying out some new things on my eval function. Let's say I have an old eval feature I'm going to denote as F1 and a new implementation of this eval feature as F2.

I have tested F1 against a set of opponents using a set of test positions in a blitz tournament.

I then replaced F1 by F2 but on some twist of fate I accidentally enabled F2 for the white side only and F1 for the black side. I tested it and it scored way higher compared to F1 in the same test condition. I said to myself, the new implementation works well, but then when I reviewed the code I found out that it was not implemented as I wanted to.

I then fixed the asymmetry bug and went on to implement the correct F2 feature. To my surprise it scored only between the F1 and the F1/F2 combination. Note that I have not tried F2 for white and F1 for black to see if it still performs well.

Now here's my dilemma, if you're in my place, would you keep the bug that performs well or implement the correct feature that doesn't perform as well?
I never accept bugs just because they are better. The idea is to understand what is going on, and _why_ the bug is making it play better (this is assuming it really is, which may well require a ton of games to verify) and go from there. Once you understand the "why" then you can probably come up with an implementation that is symmetric and still works well.
Since I do lack the resources to test them thoroughly I mostly rely on intuition. Since this one is so counter intuitive, I don't know what to decide. Well I guess I will just have to choose the right implementation even if it seems to be weaker in my limited tests.
You said that you knew it was too few games. But I do not think you knew the magnitude of games needed to come up with a conclusion. What Giancarlo was pointing out can be translated to: "Both versions do not look any weaker or stronger than the other". So, your test does not look counter intuitive.

To make a decision based only on the numbers of wins you had in your tests, is almost as basing it on flipping coins. The difference you got was ~10 wins on 240 games. You had a performance of ~33%. This is not the same (because you have draws) but just to have an idea, throw a dice 240 times and count how many times you get 1 or 2 (33% chances). Do it again and again. The number will oscillate around 80, but getting close to 70 or 90 is not that unlikely. This is pretty well established. The fact that you are using only 20 positions and 4 engines make differences even less significant (statistically speaking).

Miguel
I'm using 30 positions played for both colors, so 60 positions per opponent multiplied by four opponents equals 240.

I don't think that basing a decision from just 240 games is like basing it on flipping coins. What I know is that there is a certain difference in percentage of wins that you could declare if a version is better than the other if there error bar doesn't overlap.

For example I have a version with a performance of 2400 +-40 and I have another version with a performance of 2600 +-40. The upper limit of the first version is 2440 and the lower limit of the second version is 2560, they doesn't overlap so in this case I could say that the second version is better than the first version even if I only have a few hundred games.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: Eval Dilemma

Post by Edsel Apostol »

diep wrote:
michiguel wrote:
diep wrote:
michiguel wrote:
diep wrote:
hgm wrote:
MattieShoes wrote:Can you or anybody point me to how the error bars are calculated?
I think the rule-of-thumb Error = 40%/sqrt(numberOfGames) is accurate enough in practice, for scores in the 65%-35% range. (This is for the 1-sigma or 84% confidence level; for 95% confidence, double it.) For very unbalanced scores, you would have to take into account the fact that the 40% goes down; the exact formula for this is

100%*sqrt(score*(1-score) - 0.25*drawFraction)

where the score is given as a fraction. The 40% is based on 35% draws, and a score of 0.5. In the case mentioned (score around 0.25, presumably 15% win and 20% draws, you would get 100%*sqrt(0.25*0.75-0.25*0.2) = 37%. So in 240 games you woud have 2.4% error bar (1 sigma).

When comparing the results from two independent gauntlets, the error bar in the diffrence is the Pythagorean sum of the individua error bars (i.e. sqrt(error1^2 + error2^2) ). For results that had equal numbers of games, this means multiplying the individual error bars by sqrt(2).
To get a score difference of 30% (35% ==> 65%) that's so big, that if you add just 1 pattern to your evaluation with such a huge impact, that obviously we might hope that's not the 'average pattern' that you add.

More likely it is that you see a score difference of 1 point at a 200 games when adding just 1 tiny pattern.

Vincent
He was not talking about increases from 35% to 65%. The formula is valid if both score A and score B (from versions A and B) are within 35% to 65%. In other words, if score A is 48% and score B is 52%, you can apply the formula. If score A is 8% and score B is 12%, you cannot.

Miguel
If A scores 48% and B scores 52%, that's basically blowing 2 games with maybe in total just 2 very bad moves, as that can give a 4 point swing in total.

First of all odds these 2 bad moves were caused by the specific pattern is tiny. It could be some fluctuation or book learning or whatever effect.

So you really soon will conclude you need THOUSANDS of games for real good statistical significance. I'm going usually for 95%.

Vincent
Going from 50-50 to 52-48 is an increase of ~15 Elo points. Yes, you need thousands of games to make sure it is real with a good level of confidence.

Miguel
Additionally they have to be preferably on the hardware and time control you want to play tournament in.

Jonathan Schaeffer: "You have to test with what you play".
There seems to be a positive correlation of engine strength between short and longer time controls, based on some results published here and what you also can notice in the established rating lists.

So if you're lacking the time and resources to test with what you play, for example a tournament time control of 40/40 you can take a compromise by playing blitz games. There is a big probability that the result in blitz will correspond with its result in longer time controls, though there are some few engines that are the exception.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: Eval Dilemma

Post by Edsel Apostol »

MattieShoes wrote:I'm poking around on a spreadsheet trying to make everything stick in my brain. Assuming I'm interpreting what Dr. Muller said correctly (dangerous assumption, I know)...

For 52% score vs 48% score:
Assuming 0% draws, it would take about 1228 games
Assuming 35% draws, it would take about 811 games

For very raw engines where the difference might be extreme, testing with 95% confidence interval still seems viable without a setup like Dr. Hyatt has. for example, going 25% vs 35% score would be more like 95 games for 95% confidence interval.
Hi Matt, would you mind explaining how did you solve this?
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: Eval Dilemma

Post by Edsel Apostol »

diep wrote:
Edsel Apostol wrote:
diep wrote:
Gian-Carlo Pascutto wrote:
Edsel Apostol wrote: The opponents are Rybka1.2f 64 bit, Naum 3 64 bit, Thinker 5.4ai 64 bit and HIARCS11MP[...] the number of games is only 240 for each version.

I know its too few games, but I would expect that the bugfixed version should at least be stronger.

Note that the version with the bug performed well against Rybka and Hiarcs resulting to higher score.
240 games / 4 opponents = 60 games per program.

With 60 games per program it is completely meaningless to talk about "perform better against this or that".

Your problem is that you do not respect statistics.
When i would've posted something like this a few years ago (before 2004), Frans Morsch would ship me an email or tell during a tournament: "please don't tell them that, right now they make no chance to get a strong engine, let alone become one of my competitors, competing with the current ones is already hard enough".

Vincent
It seems like being wary that the newbies will catch up with the veterans. It's just a fact of life that old bulls are being replaced by young ones. :D
Taking strelka code and carrying on might win from some old chaps, it sure doesn't make the entire new generation better as they 'lift' a bit too much there onto someone elses work.
I agree with you here. Most of the engine nowadays are being influenced by strong open source engines like Fruit/Toga, Glaurung, and Strelka. Even the commercial ones get some benefits from them.

But though a lot of knowledge has been available now compared to before, through Strelka, Fruit, etc., it doesn't mean that those knowledge can be incorporated easily into ones engine. Strelka code has been around for a while but only few engines has surpassed it yet.

Besides the knowledge is available for both the old generation and the new ones so it is not an excuse to say that the new generation benefits from others work. In my opinion why the younger generation tends to surpass the old ones is that the younger generation is willing to learn something new while the old ones tend to stick to their old methods that might already be obsolete.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Eval Dilemma

Post by bob »

Edsel Apostol wrote:
diep wrote:
michiguel wrote:
diep wrote:
michiguel wrote:
diep wrote:
hgm wrote:
MattieShoes wrote:Can you or anybody point me to how the error bars are calculated?
I think the rule-of-thumb Error = 40%/sqrt(numberOfGames) is accurate enough in practice, for scores in the 65%-35% range. (This is for the 1-sigma or 84% confidence level; for 95% confidence, double it.) For very unbalanced scores, you would have to take into account the fact that the 40% goes down; the exact formula for this is

100%*sqrt(score*(1-score) - 0.25*drawFraction)

where the score is given as a fraction. The 40% is based on 35% draws, and a score of 0.5. In the case mentioned (score around 0.25, presumably 15% win and 20% draws, you would get 100%*sqrt(0.25*0.75-0.25*0.2) = 37%. So in 240 games you woud have 2.4% error bar (1 sigma).

When comparing the results from two independent gauntlets, the error bar in the diffrence is the Pythagorean sum of the individua error bars (i.e. sqrt(error1^2 + error2^2) ). For results that had equal numbers of games, this means multiplying the individual error bars by sqrt(2).
To get a score difference of 30% (35% ==> 65%) that's so big, that if you add just 1 pattern to your evaluation with such a huge impact, that obviously we might hope that's not the 'average pattern' that you add.

More likely it is that you see a score difference of 1 point at a 200 games when adding just 1 tiny pattern.

Vincent
He was not talking about increases from 35% to 65%. The formula is valid if both score A and score B (from versions A and B) are within 35% to 65%. In other words, if score A is 48% and score B is 52%, you can apply the formula. If score A is 8% and score B is 12%, you cannot.

Miguel
If A scores 48% and B scores 52%, that's basically blowing 2 games with maybe in total just 2 very bad moves, as that can give a 4 point swing in total.

First of all odds these 2 bad moves were caused by the specific pattern is tiny. It could be some fluctuation or book learning or whatever effect.

So you really soon will conclude you need THOUSANDS of games for real good statistical significance. I'm going usually for 95%.

Vincent
Going from 50-50 to 52-48 is an increase of ~15 Elo points. Yes, you need thousands of games to make sure it is real with a good level of confidence.

Miguel
Additionally they have to be preferably on the hardware and time control you want to play tournament in.

Jonathan Schaeffer: "You have to test with what you play".
There seems to be a positive correlation of engine strength between short and longer time controls, based on some results published here and what you also can notice in the established rating lists.

So if you're lacking the time and resources to test with what you play, for example a tournament time control of 40/40 you can take a compromise by playing blitz games. There is a big probability that the result in blitz will correspond with its result in longer time controls, though there are some few engines that are the exception.
That's not the issue. You are trying to decide whether A' is better than A, and that absolutely does not correlate well at different time controls, for many kinds of changes. Particularly with respect to things that significantly alter the shape of the tree, such as search extensions, reductions, etc. I have found some ideas that work better at fast time controls (small but significant improvement) but then fall flat on their face at longer time controls. Eval changes are less likely to do this but I have seen examples there as well where this also happens.