我正在嘗試學習框架(雅閣),但文檔通常帶有碎片代碼。
我想要類似this。Accord.Net中的多項式支持向量迴歸
我試過不同的事情,似乎沒有任何工作。有沒有人有一個工作的非直線支持向量迴歸示例?
我也試過the official example這似乎並不奏效。
我正在嘗試學習框架(雅閣),但文檔通常帶有碎片代碼。
我想要類似this。Accord.Net中的多項式支持向量迴歸
我試過不同的事情,似乎沒有任何工作。有沒有人有一個工作的非直線支持向量迴歸示例?
我也試過the official example這似乎並不奏效。
在項目採用新的統一學習API後,該文檔仍在整合,該API現在對於所有機器學習模型都很常見。其中大部分是昨天剛剛更新的,但有幾部分可能仍需要注意。
回答你的原始問題,你可以在下面找到一個多項式SV迴歸的例子。假設我們有2維輸入向量,並且我們想要學習從這些向量到單個標量值的映射。
// Declare a very simple regression problem
// with only 2 input variables (x and y):
double[][] inputs =
{
new[] { 3.0, 1.0 },
new[] { 7.0, 1.0 },
new[] { 3.0, 1.0 },
new[] { 3.0, 2.0 },
new[] { 6.0, 1.0 },
};
double[] outputs =
{
65.3,
94.9,
65.3,
66.4,
87.5,
};
例如起見,我們將本機的複雜性參數設置爲一個很高的值,強制學習算法來尋找硬利潤率的解決方案,否則將不能一概而論很好。當現實世界的問題的訓練,離開性質UseKernelEstimation和UseComplexityHeuristic設置爲true或執行網格搜索找到自己的最佳參數:
// Create a LibSVM-based support vector regression algorithm
var teacher = new FanChenLinSupportVectorRegression<Polynomial>()
{
Tolerance = 1e-5,
// UseKernelEstimation = true,
// UseComplexityHeuristic = true
Complexity = 10000,
Kernel = new Polynomial(degree: 1) // you can change the degree
};
現在,我們已經創建了學習算法後,我們可以用它來從數據訓練SVM模型:
// Use the algorithm to learn the machine
var svm = teacher.Learn(inputs, outputs);
終於可以拿到機器的回答爲一組輸入,我們可以檢查機器的預測值有多好相較於預期的地面實況:
// Get machine's predictions for inputs
double[] prediction = svm.Score(inputs);
// Compute the error in the prediction (should be 0.0)
double error = new SquareLoss(outputs).Loss(prediction);
完美的答案和很好的記錄和解釋。我真誠地不能夠感謝你!保持良好的工作! –
注意:示例和文檔已經最終更新。 – Cesar