如何用accord.net实现多变量多输出线性回归

wuxinwuyin 2019-04-25 09:23:33
求c#中,实现accord.net实现多变量多输出线性回归的方法。
...全文
495 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuxinwuyin 2019-05-05
  • 打赏
  • 举报
回复
包里面有这个函数,我就不需要再编算法。搞工程的会应用就行,不需要造黑盒子。
wuxinwuyin 2019-05-05
  • 打赏
  • 举报
回复
官网看了,没给出具体怎么输出系数。我不知计算机专业。
下面是官网给的例子,试了好几遍还是没有把系数输出出来。求怎么输出系数。
// The multivariate linear regression is a generalization of
// the multiple linear regression. In the multivariate linear
// regression, not only the input variables are multivariate,
// but also are the output dependent variables.

// In the following example, we will perform a regression of
// a 2-dimensional output variable over a 3-dimensional input
// variable.

double[][] inputs =
{
// variables: x1 x2 x3
new double[] { 1, 1, 1 }, // input sample 1
new double[] { 2, 1, 1 }, // input sample 2
new double[] { 3, 1, 1 }, // input sample 3
};

double[][] outputs =
{
// variables: y1 y2
new double[] { 2, 3 }, // corresponding output to sample 1
new double[] { 4, 6 }, // corresponding output to sample 2
new double[] { 6, 9 }, // corresponding output to sample 3
};

// With a quick eye inspection, it is possible to see that
// the first output variable y1 is always the double of the
// first input variable. The second output variable y2 is
// always the triple of the first input variable. The other
// input variables are unused. Nevertheless, we will fit a
// multivariate regression model and confirm the validity
// of our impressions:

// Use Ordinary Least Squares to create the regression
OrdinaryLeastSquares ols = new OrdinaryLeastSquares();

// Now, compute the multivariate linear regression:
MultivariateLinearRegression regression = ols.Learn(inputs, outputs);

// We can obtain predictions using
double[][] predictions = regression.Transform(inputs);

// The prediction error is
double error = new SquareLoss(outputs).Loss(predictions); // 0

// At this point, the regression error will be 0 (the fit was
// perfect). The regression coefficients for the first input
// and first output variables will be 2. The coefficient for
// the first input and second output variables will be 3. All
// others will be 0.
//
// regression.Coefficients should be the matrix given by
//
// double[,] coefficients = {
// { 2, 3 },
// { 0, 0 },
// { 0, 0 },
// };
//

// We can also check the r-squared coefficients of determination:
double[] r2 = regression.CoefficientOfDetermination(inputs, outputs);
jx315425246 2019-05-04
  • 打赏
  • 举报
回复
其实就是一种近似的数学模拟,一元的最好计算,多元的。。。。。,写好处法程式也就出来了
jx315425246 2019-05-04
  • 打赏
  • 举报
回复
老老实写算法吧,先分析散列,再计算,高数要好
  • 打赏
  • 举报
回复
在accord.net官网下载,有docs里有所有说明
wuxinwuyin 2019-05-01
  • 打赏
  • 举报
回复
我说的是从Nuget里加accord的package,它给的说明书里写过。
  • 打赏
  • 举报
回复
accord.net是不需要安装的,拷贝直接用
wuxinwuyin 2019-04-25
  • 打赏
  • 举报
回复
我看到accord.net介绍页写道能实现多变量多输出的线性回归,应该是统计那个包里,原文如下: In the multivariate linear regression, not only the input variables are multivariate,but also are the output dependent variables.
我摸索了半天,目前发现我包没装好。提示不兼容1.0,需要4.0版本,正在尝试中。
  • 打赏
  • 举报
回复
accord.math里有没

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧