DTREG .NET Class Library

The DTREG .NET Class Library makes it easy for production applications to call DTREG as an “engine” to compute the predicted value for data records using a model created by DTREG. You must use the GUI version of DTREG to construct a model before you can use it with the DTREG Class Library to predict values.

Any type of model can be used with the DTREG Class Library to generate predicted values. All of the advanced scoring features such as the use of surrogate splitters to handle missing predictor values are used in the DTREG Class Library.

Because of the standardization of the .NET interface, it is easy to call the DTREG Class Library from programs written in Visual Basic, C#, Visual C++, VBA, Excel, Access, ASP and other languages. Both 32-bit and 64-bit versions of the Class Library are provided.

Click here to view the manual for the DTREG Class Library

Example Visual Basic Program That Calls The DTREG Class Library

 

Imports DTREGclassLibrary

Private Sub btnRun_Click(sender As System.Object, e As System.EventArgs) Handles btnRun.Click
        '
        '  Miscellaneous variable declarations.
        '
        Dim ModelType, status, index As Long
        Dim NumVar, NumCat As Long
        Dim VarClass, VarType As Long
        Dim VarName, CatLabel As String
        Dim ixSepalLength, ixSepalWidth As Long
        Dim ixPetalLength, ixPetalWidth As Long
        Dim ixSpecies As Long
        Dim PredictedCategory As String
        Dim CatProb As Double
        Dim Mvalue As Double
        '
        '  Create an object to access the DTREG class library.
        '
        Dim dtreg As New DTREGclassLibrary.DTREGclass
        '
        '  Open a DTREG project file.
        '
        Dim intStatus As Integer = dtreg.OpenModel("C:\DTREGtestFiles\Iris.dtr")
        If intStatus <> 0 Then
            MessageBox.Show("Project open status = " & intStatus.ToString)
        End If
        '
        '  Get the real value used to represent missing value.
        '
        Mvalue = dtreg.GetMissingValue()
        '
        '  Find out what type of model this is
        '
        ModelType = dtreg.GetModelType()
        '
        '  Find out how many variables are in the model.
        '
        NumVar = dtreg.GetNumberOfVariables()
        '
        '  Check the name and properties of each variable.
        '
        For index = 0 To NumVar - 1
            VarName = dtreg.VariableName(index)
            VarClass = dtreg.VariableClass(index)
            VarType = dtreg.VariableType(index)
        Next
        '
        '  Get the index numbers of the variables variables.
        '
        ixSpecies = dtreg.VariableIndex("Species")
        ixSepalLength = dtreg.VariableIndex("Sepal length")
        ixSepalWidth = dtreg.VariableIndex("Sepal width")
        ixPetalLength = dtreg.VariableIndex("Petal length")
        ixPetalWidth = dtreg.VariableIndex("Petal width")
        '
        '  Set the values of the predictors we want to score.
        '
        status = dtreg.SetContinuousValue(ixSepalLength, 5.1)
        status = dtreg.SetContinuousValue(ixSepalWidth, 3.5)
        status = dtreg.SetContinuousValue(ixPetalLength, 1.4)
        status = dtreg.SetContinuousValue(ixPetalWidth, 0.2)
        '
        '  Compute the predicted target category.
        '
        intStatus = dtreg.ComputeScore()
        '
        '  See if any error occurred during the computation.
        '
        If intStatus <> 0 Then
            MessageBox.Show("Error computing target: " & intStatus.ToString)
            Stop
        End If
        '
        '  Check the predicted category for the target.
        '
        PredictedCategory = dtreg.GetPredictedCategory()
        If PredictedCategory <> "Setosa" Then
            MessageBox.Show("Incorrect predicted category: " & PredictedCategory)
        End If
        '
        '  If we are using a TreeBoost model, check the probabilities
        '  for each of the target variable categories.
        '
        NumCat = dtreg.GetNumberOfCategories(ixSpecies)
        For index = 0 To NumCat - 1
            CatLabel = dtreg.GetCategoryLabel(ixSpecies, index)
            CatProb = dtreg.GetProbabilityScore(index)
        Next
    End Sub
End Class'
'  If we are using a TreeBoost model, check the probabilities
'  for each of the target variable categories.
'
If ModelType = 2 Then
    NumCat = dtreg.NumberOfCategories(ixSpecies)
    For index = 0 To NumCat - 1
        CatLabel = dtreg.CategoryLabel(ixSpecies, index)
        CatProb = dtreg.TargetCategoryProbability(index)
    Next
End If

End Sub