求c#中,实现accord.net实现多变量多输出线性回归的方法。
解决方案 »
- DataGridView根据条件查询并让选中行高亮显示
- C#中,按钮在点击后的显示?
- XML INI文件大小和节点数是否有限制
- 请教一个如何快速更新表内所有记录的问题
- 能否在自己的Web应用程序中嵌入.net的网页设计器或其他网页设计器
- vs2008的visible,hide,minimisized快把我弄疯了,好心人帮个忙吧
- panel 控件于其中子控件的 Enable问题<windows form>?
- 为何数据添加不到ACCESS数据库?
- 遇到一个textbox赋值的问题
- \r\n和\n有什么区别?
- sqlite表已经建好,但是在插入的时候提示表内不存在某些列名
- 窗体之间的传值(先这么表达,不接受反驳)
我摸索了半天,目前发现我包没装好。提示不兼容1.0,需要4.0版本,正在尝试中。
下面是官网给的例子,试了好几遍还是没有把系数输出出来。求怎么输出系数。
// 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);