Я пытаюсь запустить следующий код:
// modified from: https://github.com/accord-net/framework/wiki/Regression
using System;
namespace Accord.Statistics {
using Accord.Statistics.Models.Regression.Linear;
class Program {
// Declare some sample test data.
double[] inputs = { 80, 60, 10, 20, 30 };
double[] outputs = { 20, 40, 30, 50, 60 };
// Use Ordinary Least Squares to learn the regression
OrdinaryLeastSquares ols = new OrdinaryLeastSquares();
SimpleLinearRegression regression = ols.Learn(inputs, outputs);
// Compute the output for a given input:
double y = regression.Transform(85); // The answer will be 28.088
// We can also extract the slope and the intercept term
// for the line. Those will be -0.26 and 50.5, respectively.
double s = regression.Slope; // -0.264706
double c = regression.Intercept; // 50.588235
static void Main(string[] args) {
Console.WriteLine("Linear regression test; slope: {0:D} intercept:{1:D}; Predicted:{3:D}.", s, c, y);
}
}
}
Однако выдает следующую ошибку:
$ mcs linreg.cs -pkg:Accord.Statistics.Models.Regression.Linear
Package Accord.Statistics.Models.Regression.Linear was not found in the pkg-config search path.
Perhaps you should add the directory containing `Accord.Statistics.Models.Regression.Linear.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Accord.Statistics.Models.Regression.Linear' found
error CS8027: Error running pkg-config. Check the above output.
Я работаю над Debian Stable Linux с установленным монокомплектом.
Как можно исправить эту ошибку? Спасибо за вашу помощь.
Изменить: при изменении кода, как это предлагается в комментариях:
using System;
using Accord.Statistics.Models.Regression.Linear;
class Program {
// Declare some sample test data.
double[] inputs = { 80, 60, 10, 20, 30 };
double[] outputs = { 20, 40, 30, 50, 60 };
// Use Ordinary Least Squares to learn the regression
OrdinaryLeastSquares ols = new OrdinaryLeastSquares();
SimpleLinearRegression regression = ols.Learn(inputs, outputs);
// Compute the output for a given input:
double y = regression.Transform(85); // The answer will be 28.088
// We can also extract the slope and the intercept term
// for the line. Those will be -0.26 and 50.5, respectively.
double s = regression.Slope; // -0.264706
double c = regression.Intercept; // 50.588235
static void Main(string[] args) {
Console.WriteLine("Linear regression test; slope: {0:D} intercept:{1:D}; Predicted:{3:D}.", s, c, y);
}
}
Я получаю следующую ошибку:
$ mono-csc linreg.cs
linreg.cs(5,7): error CS0246: The type or namespace name `Accord' could not be found. Are you missing an assembly reference?
linreg.cs(12,3): error CS0246: The type or namespace name `OrdinaryLeastSquares' could not be found. Are you missing an assembly reference?
linreg.cs(13,3): error CS0246: The type or namespace name `SimpleLinearRegression' could not be found. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
using Accord.Statistics.Models.Regression.Linear;
нижеusing System;
, а не внутри пространства имен. - person pravy mravec   schedule 08.06.2019using
всегда идут вверху файла, вне любых объявленийnamespace
или чего-то еще. Это не имеет ничего общего с Accord, Debian или Mono, это просто язык C#. - person David   schedule 08.06.2019using
выше, как было предложено, ведет кerror CS0246: The type or namespace name
Accord' не удалось найти. Вам не хватает ссылки на сборку? `Пожалуйста, смотрите редактирование в моем вопросе выше. - person rnso   schedule 08.06.2019.cs
, а не весь проект, поэтому в настоящее время нет ссылок на внешние сборки. Я не знаю, имеет лиmono-csc
тот же формат для аргументов командной строки, но взгляните на компиляцию командной строки, выполняемую здесь: stackoverflow.com/questions/10722832/ Обратите внимание, как.dll
файлов указываются во время компиляции. Вам также нужно будет включить свой. - person David   schedule 08.06.2019mcs gtkexample2.cs -pkg:gtk-sharp-2.0
сработало. Но здесь$ mono-csc linreg.cs -pkg:Accord.Statistics.Models.Regression.Linear
не работает. Ошибка:No package 'Accord.Statistics.Models.Regression.Linear' found
- person rnso   schedule 08.06.2019