You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This example requires installation of additional nuget package <a href="https://www.nuget.org/packages/Microsoft.ML.LightGbm/">Microsoft.ML.LightGbm</a>.
12
-
publicstaticvoidExample()
13
-
{
14
-
// Create a general context for ML.NET operations. It can be used for exception tracking and logging,
15
-
// as a catalog of available operations and as the source of randomness.
varnativeLabels=labelBuffer.DenseValues().ToArray();// nativeLabels[nativePrediction.PredictedLabelIndex - 1] is the original label indexed by nativePrediction.PredictedLabelIndex.
67
-
68
-
69
-
// Show prediction result for the 3rd example.
70
-
varnativePrediction=nativePredictions[2];
71
-
// Console output:
72
-
// Our predicted label to this example is "AA" with probability 0.9257.
73
-
Console.WriteLine($"Our predicted label to this example is {nativeLabels[(int)nativePrediction.PredictedLabelIndex-1]} "+
74
-
$"with probability {nativePrediction.Scores[(int)nativePrediction.PredictedLabelIndex-1]:F4}.");
75
-
76
-
// Scores and nativeLabels are two parallel attributes; that is, Scores[i] is the probability of being nativeLabels[i].
77
-
// Console output:
78
-
// The probability of being class "AA" is 0.9257.
79
-
// The probability of being class "BB" is 0.0739.
80
-
// The probability of being class "CC" is 0.0002.
81
-
// The probability of being class "DD" is 0.0001.
82
-
for(inti=0;i<nativeLabels.Length;++i)
83
-
Console.WriteLine($"The probability of being class {nativeLabels[i]} is {nativePrediction.Scores[i]:F4}.");
// This example requires installation of additional nuget package <a href="https://www.nuget.org/packages/Microsoft.ML.LightGbm/">Microsoft.ML.LightGbm</a>.
13
-
publicstaticvoidExample()
14
-
{
15
-
// Create a general context for ML.NET operations. It can be used for exception tracking and logging,
16
-
// as a catalog of available operations and as the source of randomness.
varnativeLabels=labelBuffer.DenseValues().ToArray();// nativeLabels[nativePrediction.PredictedLabelIndex - 1] is the original label indexed by nativePrediction.PredictedLabelIndex.
77
-
78
-
79
-
// Show prediction result for the 3rd example.
80
-
varnativePrediction=nativePredictions[2];
81
-
// Console output:
82
-
// Our predicted label to this example is AA with probability 0.8986.
83
-
Console.WriteLine($"Our predicted label to this example is {nativeLabels[(int)nativePrediction.PredictedLabelIndex-1]} "+
84
-
$"with probability {nativePrediction.Scores[(int)nativePrediction.PredictedLabelIndex-1]:F4}.");
85
-
86
-
// Scores and nativeLabels are two parallel attributes; that is, Scores[i] is the probability of being nativeLabels[i].
87
-
// Console output:
88
-
// The probability of being class AA is 0.8986.
89
-
// The probability of being class BB is 0.0961.
90
-
// The probability of being class CC is 0.0050.
91
-
// The probability of being class DD is 0.0003.
92
-
for(inti=0;i<nativeLabels.Length;++i)
93
-
Console.WriteLine($"The probability of being class {nativeLabels[i]} is {nativePrediction.Scores[i]:F4}.");
Copy file name to clipboardExpand all lines: docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/MulticlassClassification.ttinclude
0 commit comments