I am trying to use adaboost (or boosting) in Accord.Net. I tried a version of the example given by https://github.com/accord-net/framework/wiki/Classification for decision trees and it works well with the following code:
'' Creates a matrix from the entire source data table
Dim data As DataTable = CType(DataView.DataSource, DataTable)
'' Create a new codification codebook to
'' convert strings into integer symbols
Dim codebook As New Codification(data)
'' Translate our training data into integer symbols using our codebook:
Dim symbols As DataTable = codebook.Apply(data)
Dim inputs As Double()() = symbols.ToArray(Of Double)("Outlook", "Temperature", "Humidity", "Wind")
Dim outputs As Integer() = symbols.ToArray(Of Integer)("PlayTennis")
'' Gather information about decision variables
Dim attributes() As DecisionVariable = {New DecisionVariable("Outlook", 3), New DecisionVariable("Temperature", 3), _
New DecisionVariable("Humidity", 2), New DecisionVariable("Wind", 2)}
Dim classCount As Integer = 2 '' 2 possible output values for playing tennis: yes or no
''Create the decision tree using the attributes and classes
tree = New DecisionTree(attributes, classCount)
'' Create a new instance of the ID3 algorithm
Dim Learning As New C45Learning(tree)
'' Learn the training instances!
Learning.Run(inputs, outputs)
Dim aa As Integer() = codebook.Translate("D1", "Rain", "Mild", "High", "Weak")
Dim ans As Integer = tree.Compute(aa)
Dim answer As String = codebook.Translate("PlayTennis", ans)
Now I want to addapt this code to use adaboost or boosting on more complicated examples. I tried the following by adding the following to the code above:
Dim Booster As New Boost(Of DecisionStump)()
Dim Learn As New AdaBoost(Of DecisionStump)(Booster)
Dim weights(inputs.Length - 1) As Double
For i As Integer = 0 To weights.Length - 1
weights(i) = 1.0 / weights.Length
Next
Learn.Creation = New ModelConstructor(Of DecisionStump)(x=>tree.Compute(x))
Dim Err As Double = Learn.Run(inputs, outputs, weights)
The problem seem to be the line:
Learn.Creation = New ModelConstructor(Of DecisionStump)(x=>tree.Compute(x))
How can I use adaboost or boosting in Accord.Net? How can I adjust my code to make it work? All help will be appreciated.