Skip to main content
Kofax

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

13627

QAID # 13627 Published 

Question / Problem:

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

Answer / 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 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

Applies to:

Product Version Category
AXPRO 4.5 Classification
AXPRO 4.5 Configuration
AXPRO 4.5 Document Review
AXPRO 4.5 Server
  • Was this article helpful?