我根据此页面http://accord-framework.net/docs/html/T_Accord_Statistics_Models_Regression_Linear_SimpleLinearRegression.htm使用Accord.NET计算线性回归的斜率和截距
我想设置一个固定的截距值,以便Accord仅能预测斜率。我可以在Accord.NET中做那件事吗?
Dim inp(10), opt(10) As Double
inp = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
opt = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
Dim ols As New OrdinaryLeastSquares
Dim reg As New SimpleLinearRegression
reg.Intercept = 4 'no effect, how can we set the intercept value?
reg = ols.Learn(inp, opt)
Dim hsl As String
hsl = "y=" + reg.Slope.ToString + "X+" + reg.Intercept.ToString
答案 0 :(得分:0)
设置ols.UseIntercept = False
,将所需的截距值添加到每个opt
值,然后运行ols.Learn()
。将为您想要的截距计算出结果Slope
。