Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 将AdaBoost(Boosting)与Accord.Net一起使用_Vb.net_Machine Learning_Adaboost_Accord.net - Fatal编程技术网

Vb.net 将AdaBoost(Boosting)与Accord.Net一起使用

Vb.net 将AdaBoost(Boosting)与Accord.Net一起使用,vb.net,machine-learning,adaboost,accord.net,Vb.net,Machine Learning,Adaboost,Accord.net,我正在尝试在Accord.Net中使用adaboost(或boosting)。我尝试了for decision trees给出的示例的一个版本,它与以下代码配合得很好: '' Creates a matrix from the entire source data table Dim data As DataTable = CType(DataView.DataSource, DataTable) '' Create a new codification codebook to '' con

我正在尝试在Accord.Net中使用adaboost(或boosting)。我尝试了for decision trees给出的示例的一个版本,它与以下代码配合得很好:

'' 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?如何调整代码使其正常工作?感谢所有帮助。

这是一个迟来的响应,但对于那些可能在将来发现它有用的人来说,自3.8.0版以来,可以使用Accord.NET框架学习增强的决策树,如下所示:

//此示例演示如何使用AdaBoost来训练更复杂的
//模型比简单的决策更简单。例如,我们将使用
//它需要训练一个决策树。
//让我们使用一些合成数据:阴阳数据集是
//一个简单的二维二元非线性决策问题
//属于阴阳形状的每一类:
var数据集=新阴阳();
double[][]输入=dataset.Instances;
int[]outputs=Classes.tozerone(dataset.ClassLabels);
//为逻辑回归创建AdaBoost,如下所示:
var teacher=newadaboost()
{
//在这里,我们可以指定如何学习每个回归:
学习者=(参数)=>新C45Learning()
{
//即。
//最大高度=
//MaxVariables=
},
//培训至:
最大迭代次数=50,
公差=1e-5,
};
//现在,我们可以使用学习方法来学习增强分类器
Boost分类器=教师学习(输入、输出);
//我们可以使用(误差应为0.11)测试其性能:
双误差=混淆矩阵。估计(分类器、输入、输出)。误差;
//并使用以下公式计算单个数据点的决策:
bool y=classifier.decise(输入[0]);//结果应该是假的
是否定义了“x”?如果未定义,则算法可能不喜欢未定义的变量。查看特定的盈阳数据集,您可以使用基于模型的聚类(高斯混合模型),并且可能比所示的任何监督方法都要好。此外,带有径向基函数(RBF)核的支持向量机也应该做得很好。(我没有查看所使用的SVM方法)。