diff --git a/samples/machine-learning/wine/Host.cs b/samples/machine-learning/wine/Host.cs index d52d71feb8e1..fdb9f707e5ce 100644 --- a/samples/machine-learning/wine/Host.cs +++ b/samples/machine-learning/wine/Host.cs @@ -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."); } } diff --git a/samples/machine-learning/wine/Training.qs b/samples/machine-learning/wine/Training.qs index 6836711d6bc8..9378a5ed370a 100644 --- a/samples/machine-learning/wine/Training.qs +++ b/samples/machine-learning/wine/Training.qs @@ -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; @@ -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; @@ -80,7 +81,7 @@ namespace Microsoft.Quantum.Samples { nMeasurements, DefaultSchedule(samples) ); - return results::NMisclassifications; + return IntAsDouble(results::NMisclassifications) / IntAsDouble(Length(samples)); } }