vb.net2019-Accord.Net机器学习库安装与SVM简单分类
生活随笔
收集整理的這篇文章主要介紹了
vb.net2019-Accord.Net机器学习库安装与SVM简单分类
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
新建一個窗口項目。
先從C#程序開始,建立一個c#控制臺程序,注意引入System.Windows.Forms
using System; using Accord.Controls; using Accord.MachineLearning.VectorMachines.Learning; using Accord.Math.Optimization.Losses; using Accord.Statistics; using Accord.Statistics.Kernels;namespace GettingStarted {class Program{[MTAThread]static void Main(string[] args){double[][] inputs ={/* 1.*/ new double[] { 0, 0 },/* 2.*/ new double[] { 1, 0 }, /* 3.*/ new double[] { 0, 1 }, /* 4.*/ new double[] { 1, 1 },};int[] outputs ={ /* 1. 0 xor 0 = 0: */ 0,/* 2. 1 xor 0 = 1: */ 1,/* 3. 0 xor 1 = 1: */ 1,/* 4. 1 xor 1 = 0: */ 0,};// Create the learning algorithm with the chosen kernelvar smo = new SequentialMinimalOptimization<Gaussian>(){Complexity = 100 // Create a hard-margin SVM };// Use the algorithm to learn the svmvar svm = smo.Learn(inputs, outputs);// Compute the machine's answers for the given inputsbool[] prediction = svm.Decide(inputs);// Compute the classification error between the expected // values and the values actually predicted by the machine:double error = new AccuracyLoss(outputs).Loss(prediction);Console.WriteLine("Error: " + error);// Show results on screen ScatterplotBox.Show("Training data", inputs, outputs);ScatterplotBox.Show("SVM results", inputs, prediction.ToZeroOne());Console.ReadKey();}} }
下面是vb.net版本的
下面的示例演示了泛型類的主干定義。
Public Class classHolder(Of t)Public Sub processNewItem(ByVal newItem As t)Dim tempItem As t' Insert code that processes an item of data type t.End Sub End Class在上面的主干中, t 是一個 類型形參,即你在聲明此類時提供的數據類型的占位符。 在代碼中的其他地方,可以通過為 classHolder 提供不同的數據類型來聲明不同版本的 t 下面的示例演示了兩個此類聲明。
Public integerClass As New classHolder(Of Integer) Friend stringClass As New classHolder(Of String)上面的語句聲明了 構造類,在這些類中,特定的類型替換了類型形參。 此類替換會在構造類中的代碼內進行傳播。 下面的示例顯示了 processNewItem 過程在 integerClass中的外觀。
Public Sub processNewItem(ByVal newItem As Integer)Dim tempItem As Integer' Inserted code now processes an Integer item. End Sub總結
以上是生活随笔為你收集整理的vb.net2019-Accord.Net机器学习库安装与SVM简单分类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vb.net2019-播放声音(wav、
- 下一篇: 循环删除List集合的错误