Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

update ml wine sample miss rate to match halfmoon #766

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions samples/machine-learning/wine/Host.cs
Expand Up @@ -33,12 +33,13 @@ static async Task Main(string[] args)

// After training, we can use the validation data to test the accuracy
// of our new classifier.
var testMisses = await ValidateWineModel.Run(
var missRate = await ValidateWineModel.Run(
targetMachine,
optimizedParameters,
optimizedBias
);
System.Console.WriteLine($"Observed {testMisses} misclassifications.");

System.Console.WriteLine($"Observed {100 * missRate:F2}% misclassifications.");
}
}

Expand Down
5 changes: 3 additions & 2 deletions samples/machine-learning/wine/Training.qs
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

namespace Microsoft.Quantum.Samples {
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Random;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
Expand Down Expand Up @@ -68,7 +69,7 @@ namespace Microsoft.Quantum.Samples {
operation ValidateWineModel(
parameters : Double[],
bias : Double
) : Int {
) : Double {
// Get the remaining samples to use as validation data.
let samples = (Datasets.WineData())[143...];
let tolerance = 0.005;
Expand All @@ -80,7 +81,7 @@ namespace Microsoft.Quantum.Samples {
nMeasurements,
DefaultSchedule(samples)
);
return results::NMisclassifications;
return IntAsDouble(results::NMisclassifications) / IntAsDouble(Length(samples));
}

}