Skip to main content

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

Article # 3035744 - Page views: 395


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



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 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.)
   ' 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 



Applies to  

Product Version Build Environment Hardware
Kofax Transformation Modules All      



Add any references to other internal or external articles



Article # 3035744
  • Was this article helpful?