public void StandardInterpreterTestEvaluation()
        {
            var interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();

            EvaluateTerminals(interpreter, ds);
            EvaluateOperations(interpreter, ds);
            EvaluateAdf(interpreter, ds);
        }
示例#2
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var interpreter          = new SymbolicDataAnalysisExpressionTreeInterpreter();
            var modelsWithComplexity = new List <(ISymbolicRegressionModel, int)>();

            Stopwatch stopwatch = Stopwatch.StartNew();

            RunFFX(out var basisFunctions, out var lambda, out var coeff, out var trainNMSE, out var testNMSE, out var intercept, out var elnetData);
            stopwatch.Stop();

            var runtime = stopwatch.ElapsedTicks / 10000000.0; // in seconds

            if (Verbose)
            {
                var errorTable = NMSEGraph(coeff, lambda, trainNMSE, testNMSE);
                Results.Add(new Result(errorTable.Name, errorTable.Description, errorTable));
                var coeffTable = CoefficientGraph(coeff, lambda, elnetData.AllowedInputVariables, elnetData.Dataset);
                Results.Add(new Result(coeffTable.Name, coeffTable.Description, coeffTable));
            }

            int complexity(double[] modelCoeffs) => modelCoeffs.Count(val => val != 0) + 1;

            for (int row = 0; row < coeff.GetUpperBound(0); row++)
            {
                var coeffs                     = Utils.GetRow(coeff, row);
                var numBasisFuncs              = complexity(coeffs);
                ISymbolicExpressionTree  tree  = Tree(basisFunctions, coeffs, intercept[row]);
                ISymbolicRegressionModel model = new SymbolicRegressionModel(elnetData.TargetVariable, tree, interpreter);
                modelsWithComplexity.Add((model, numBasisFuncs));
            }

            // calculate the pareto front
            var paretoFront = Utils.NondominatedFilter(modelsWithComplexity.ToArray(), coeff, testNMSE, complexity);

            modelsWithComplexity = modelsWithComplexity.Distinct(new Utils.SymbolicRegressionModelSameComplexity()).ToList();

            var results  = new ItemCollection <IResult>();
            int modelIdx = 1;

            foreach (var model in modelsWithComplexity)
            {
                results.Add(new Result("Model " + (modelIdx < 10 ? "0" + modelIdx : modelIdx.ToString()), model.Item1));
                //results.Add(new ItemCollection<IResult>(3){
                //new Result("Model Complexity", new IntValue(model.Item2)),
                //new Result("Model Accuracy", new RegressionSolution(model.Item1, Problem.ProblemData))
                //});
                modelIdx++;
            }

            Results.Add(new Result("Pareto Front", "The Pareto Front of the Models. ", results));
            if (FilePath != "")
            {
                SaveInFile(paretoFront, runtime, FilePath, ",");
            }
        }
        public void TimeSeriesPrognosisInterpreterTestEvaluation()
        {
            Dataset ds = new Dataset(new string[] { "Y", "A", "B" }, new double[, ] {
                { 1.0, 1.0, 1.0 },
                { 2.0, 2.0, 2.0 },
                { 3.0, 1.0, 2.0 },
                { 4.0, 1.0, 1.0 },
                { 5.0, 2.0, 2.0 },
                { 6.0, 1.0, 2.0 },
                { 7.0, 1.0, 1.0 },
                { 8.0, 2.0, 2.0 },
                { 9.0, 1.0, 2.0 },
                { 10.0, 1.0, 1.0 },
                { 11.0, 2.0, 2.0 },
                { 12.0, 1.0, 2.0 }
            });

            var interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();

            EvaluateTerminals(interpreter, ds);
            EvaluateOperations(interpreter, ds);
            EvaluateAdf(interpreter, ds);
        }
 public void StandardInterpreterTestEvaluation() {
   var interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
   EvaluateTerminals(interpreter, ds);
   EvaluateOperations(interpreter, ds);
   EvaluateAdf(interpreter, ds);
 }
    public void TimeSeriesPrognosisInterpreterTestEvaluation() {
      Dataset ds = new Dataset(new string[] { "Y", "A", "B" }, new double[,] {
        { 1.0, 1.0, 1.0 },
        { 2.0, 2.0, 2.0 },
        { 3.0, 1.0, 2.0 },
        { 4.0, 1.0, 1.0 },
        { 5.0, 2.0, 2.0 },
        { 6.0, 1.0, 2.0 },
        { 7.0, 1.0, 1.0 },
        { 8.0, 2.0, 2.0 },
        { 9.0, 1.0, 2.0 },
        { 10.0, 1.0, 1.0 },
        { 11.0, 2.0, 2.0 },
        { 12.0, 1.0, 2.0 }
      });

      var interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
      EvaluateTerminals(interpreter, ds);
      EvaluateOperations(interpreter, ds);
      EvaluateAdf(interpreter, ds);
    }