【问题标题】:Linear Regression with a known fixed intercept in Accord.NETAccord.NET 中具有已知固定截距的线性回归
【发布时间】:2019-07-13 00:59:13
【问题描述】:

我使用 Accord.NET 计算基于此页面http://accord-framework.net/docs/html/T_Accord_Statistics_Models_Regression_Linear_SimpleLinearRegression.htm的线性回归的斜率和截距

我想设置一个固定的截距值,以便 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

【问题讨论】:

    标签: vb.net linear-regression accord.net


    【解决方案1】:

    设置ols.UseIntercept = False,将所需的截距值添加到每个opt 值,然后运行ols.Learn()。生成的Slope 将根据您想要的截距进行计算。

    【讨论】:

    • 谢谢@RobertBaron,这对我的情况有用。以前,我不知道如何添加所需的截距值。非常感谢您的解决方案。
    • @taufiq yuliawan - 欢迎您!很高兴我能帮上忙!
    猜你喜欢
    • 2011-11-12
    • 2019-05-27
    • 2018-06-11
    • 2022-01-09
    • 2018-01-02
    • 2020-12-03
    • 2016-08-31
    • 2015-10-28
    • 1970-01-01
    相关资源
    最近更新 更多