Где поставить `namespace` и` using` для машинного обучения Accord - PullRequest
1 голос
/ 08 июня 2019

Я пытаюсь запустить следующий код:

// 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
...