Skip to main content
Kofax

Scripting - How can the Classification Confidence score be obtained and set

Article # 3035744 - Page views: 395

Issue

How can the Classification Confidence score be obtained and set in Kofax Transformation Modules (KTM)?

 

Solution

The script example below shows how it is possible to get the classification confidence, the classID and the class name from a classified Document. In addition, it shows how a classification confidence can be changed.

Note-Icon.png

Note that the functions BestClassId() and BestClassId() are arrays which include all the classification alternatives listed by confidence.

In this example, the confidence from the final classification class is changed to 86%:

' Project classification script
Option Explicit
Private Sub Document_AfterClassifyXDoc(ByVal pXDoc As CASCADELib.CscXDocument)
   Dim iAllClassID() As Long
   Dim iAllConf() As Single
   Dim sFinalClassName As String
   Dim oMyRes As CscResult
   Dim iNumberOfResults As Integer
   Set oMyRes = pXDoc.ClassificationResult
   'Get the number of result alternatives
   iNumberOfResults = oMyRes.NumberOfConfidences
   ReDim iAllClassID(iNumberOfResults)
   ReDim iAllConf(iNumberOfResults)
   ' Set the classification confidence of a classified document to in this case 86%
   ' It is also possible to change the ResultType
   ' (e.g., FinalResult, CscResultTypeUnknown - not classified, etc.)
   pXDoc.ClassificationResult.SetResultItem(oMyRes.BestClassId(0),0.86,CscResultTypeFinalResult)
   ' Get the classification confidence (iAllConf(0)),
   ' the class ID from the best class (iAllClassID(0))
   ' and the class name (sFinalClassName)
   iAllClassID(0) = oMyRes.BestClassId(0)
   iAllConf(0) = oMyRes.BestConfidence(0)
   sFinalClassName = Project.ClassByID(iAllClassID(0)).Name
End Sub

 

Level of Complexity 

Moderate

 

Applies to  

Product Version Build Environment Hardware
Kofax Transformation Modules All      

 

References

Add any references to other internal or external articles

 

 

Article # 3035744
  • Was this article helpful?