mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-14 20:48:27 +00:00
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using AIStudio.Assistants.ModelComparison;
|
|
|
|
namespace AIStudio.Tests.Assistants.ModelComparison;
|
|
|
|
/// <summary>
|
|
/// Checks the share of wins and its Wilson score interval, against values computed by hand.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public sealed class ModelComparisonWinShareTests
|
|
{
|
|
private const double TOLERANCE = 0.001;
|
|
|
|
[Test]
|
|
public void WithoutDecidedRunsNothingIsClear()
|
|
{
|
|
var winShare = ModelComparisonWinShare.Of(0, 0);
|
|
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
Assert.That(winShare.Share, Is.Null);
|
|
Assert.That(winShare.LowerBound, Is.Null);
|
|
Assert.That(winShare.UpperBound, Is.Null);
|
|
Assert.That(winShare.Significance, Is.EqualTo(ModelComparisonSignificance.NOT_YET_CLEAR));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void EightOfTenIsNotYetClear()
|
|
{
|
|
var winShare = ModelComparisonWinShare.Of(8, 2);
|
|
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
Assert.That(winShare.Share, Is.EqualTo(0.8).Within(TOLERANCE));
|
|
Assert.That(winShare.LowerBound, Is.EqualTo(0.4902).Within(TOLERANCE));
|
|
Assert.That(winShare.UpperBound, Is.EqualTo(0.9433).Within(TOLERANCE));
|
|
Assert.That(winShare.Significance, Is.EqualTo(ModelComparisonSignificance.NOT_YET_CLEAR), "The interval still reaches below one half.");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void EighteenOfTwentyIsClearlyBetter()
|
|
{
|
|
var winShare = ModelComparisonWinShare.Of(18, 2);
|
|
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
Assert.That(winShare.LowerBound, Is.EqualTo(0.6990).Within(TOLERANCE));
|
|
Assert.That(winShare.Significance, Is.EqualTo(ModelComparisonSignificance.CLEARLY_BETTER));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void NoneOfTenIsClearlyWorse()
|
|
{
|
|
var winShare = ModelComparisonWinShare.Of(0, 10);
|
|
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
Assert.That(winShare.LowerBound, Is.EqualTo(0).Within(TOLERANCE));
|
|
Assert.That(winShare.UpperBound, Is.EqualTo(0.2775).Within(TOLERANCE));
|
|
Assert.That(winShare.Significance, Is.EqualTo(ModelComparisonSignificance.CLEARLY_WORSE));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void ANegativeCountIsRefused()
|
|
{
|
|
Assert.That(() => ModelComparisonWinShare.Of(-1, 3), Throws.TypeOf<ArgumentOutOfRangeException>());
|
|
}
|
|
} |