【发布时间】:2015-07-19 09:18:21
【问题描述】:
我正在尝试在 Accord.Net 中使用 adaboost(或 boosting)。我尝试了https://github.com/accord-net/framework/wiki/Classification 给出的决策树示例的一个版本,它适用于以下代码:
'' 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)
现在我想添加此代码以在更复杂的示例中使用 adaboost 或 boosting。我通过在上面的代码中添加以下内容来尝试以下操作:
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)
问题似乎出在这条线上:
Learn.Creation = New ModelConstructor(Of DecisionStump)(x=>tree.Compute(x))
如何在 Accord.Net 中使用 adaboost 或 boosting?如何调整我的代码以使其正常工作?我们将不胜感激。
【问题讨论】:
-
你定义了“x”吗?如果未定义,算法可能不喜欢未定义的变量。查看特定的 Ying-Yang 数据集,您可以使用基于模型的聚类(高斯混合模型),并且可能比所示的任何监督方法做得更好。此外,具有径向基函数 (RBF) 内核的 SVM 应该会表现良好。 (我没有查看使用的 SVM 方法)。
标签: vb.net machine-learning adaboost accord.net