vb.net – 在Accord.Net上使用AdaBoost(Boosting)

vb.net – 在Accord.Net上使用AdaBoost(Boosting),第1张

概述我试图在Accord.Net中使用adaboost(或者增强).我尝试了 https://github.com/accord-net/framework/wiki/Classification为决策树给出的示例版本,它适用于以下代码: '' Creates a matrix from the entire source data tableDim data As DataTable = CTyp 我试图在Accord.Net中使用adaboost(或者增强).我尝试了 https://github.com/accord-net/framework/wiki/Classification为决策树给出的示例版本,它适用于以下代码:

'' Creates a matrix from the entire source data tableDim data As Datatable = CType(DataVIEw.DataSource,Datatable)'' Create a new codification codebook to '' convert strings into integer symbolsDim 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 variablesDim attributes() As DecisionVariable = {New DecisionVariable("Outlook",3),New DecisionVariable("Temperature",_    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 classestree = New DecisionTree(attributes,classCount)'' Create a new instance of the ID3 algorithmDim 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或更复杂的示例.我通过在上面的代码中添加以下内容来尝试以下 *** 作:

Dim Booster As New Boost(Of DecisionStump)()Dim Learn As New AdaBoost(Of DecisionStump)(Booster)Dim weights(inputs.Length - 1) As DoubleFor i As Integer = 0 To weights.Length - 1    weights(i) = 1.0 / weights.LengthNextLearn.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或boost?如何调整我的代码才能使其正常工作?所有帮助将不胜感激.

解决方法 这是一个迟到的响应,但对于那些可能在将来发现它有用的人,从版本3.8.0开始,可以使用Accord.NET Framework学习Boosted决策树,如下所示:

// This example shows how to use AdaBoost to train more complex// models than a simple DecisionStump. For example,we will use// it to train a boosted Decision Trees.// Let's use some synthetic data for that: The Yin-Yang dataset is // a simple 2D binary non-linear decision problem where the points // belong to each of the classes interwine in a Yin-Yang shape:var dataset = new YinYang();double[][] inputs = dataset.Instances;int[] outputs = Classes.ToZeroOne(dataset.ClassLabels);// Create an AdaBoost for Logistic Regression as:var teacher = new AdaBoost<DecisionTree>(){    // Here we can specify how each regression should be learned:    Learner = (param) => new C45Learning()    {        // i.e.        // MaxHeight =         // MaxVariables =     },// Train until:    MaxIterations = 50,Tolerance = 1e-5,};// Now,we can use the Learn method to learn a boosted classifIErBoost<DecisionTree> classifIEr = teacher.Learn(inputs,outputs);// And we can test its performance using (error should be 0.11):double error = ConfusionMatrix.Estimate(classifIEr,inputs,outputs).Error;// And compute a decision for a single data point using:bool y = classifIEr.DecIDe(inputs[0]); // result should false
总结

以上是内存溢出为你收集整理的vb.net – 在Accord.Net上使用AdaBoost(Boosting)全部内容,希望文章能够帮你解决vb.net – 在Accord.Net上使用AdaBoost(Boosting)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1209732.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存