Add confidence threshold
This commit is contained in:
parent
1ba2e2674e
commit
fc96c36dc0
|
|
@ -210,19 +210,23 @@ public class IntentClassifier
|
|||
return processedText;
|
||||
}
|
||||
|
||||
public string Predict(NDArray vector)
|
||||
public string Predict(NDArray vector, float confidenceScore = 0.9f)
|
||||
{
|
||||
if (!_isModelReady)
|
||||
{
|
||||
InitClassifer();
|
||||
}
|
||||
|
||||
var prob = _model.predict(vector);
|
||||
var prob = _model.predict(vector).numpy();
|
||||
|
||||
if (prob[0] < confidenceScore)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var probLabel = tf.arg_max(prob, -1).numpy();
|
||||
// var prediction = _settings.LabelMappingDict.First(x => x.Value == probLabel[0]).Key;
|
||||
|
||||
var prediction = GetLabels()[probLabel[0]];
|
||||
// var prediction = GetLabels().Where((x, i) => i == probLabel[0]).First();
|
||||
|
||||
return prediction;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue