public GbmState(IRegressionProblemData problemData, ILossFunction lossFunction, uint randSeed, int maxSize, double r, double m, double nu) {
        // default settings for MaxSize, Nu and R
        this.maxSize = maxSize;
        this.nu = nu;
        this.r = r;
        this.m = m;

        this.randSeed = randSeed;
        random = new MersenneTwister(randSeed);
        this.problemData = problemData;
        this.trainingRows = problemData.TrainingIndices.ToArray();
        this.testRows = problemData.TestIndices.ToArray();
        this.lossFunction = lossFunction;

        int nRows = trainingRows.Length;

        y = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, trainingRows).ToArray();

        treeBuilder = new RegressionTreeBuilder(problemData, random);

        activeIdx = Enumerable.Range(0, nRows).ToArray();

        var zeros = Enumerable.Repeat(0.0, nRows).ToArray();
        double f0 = lossFunction.LineSearch(y, zeros, activeIdx, 0, nRows - 1); // initial constant value (mean for squared errors)
        pred = Enumerable.Repeat(f0, nRows).ToArray();
        predTest = Enumerable.Repeat(f0, testRows.Length).ToArray();
        pseudoRes = new double[nRows];

        models = new List<IRegressionModel>();
        weights = new List<double>();
        // add constant model
        models.Add(new ConstantModel(f0, problemData.TargetVariable));
        weights.Add(1.0);
      }
            public GbmState(IRegressionProblemData problemData, ILossFunction lossFunction, uint randSeed, int maxSize, double r, double m, double nu)
            {
                // default settings for MaxSize, Nu and R
                this.maxSize = maxSize;
                this.nu      = nu;
                this.r       = r;
                this.m       = m;

                this.randSeed     = randSeed;
                random            = new MersenneTwister(randSeed);
                this.problemData  = problemData;
                this.trainingRows = problemData.TrainingIndices.ToArray();
                this.testRows     = problemData.TestIndices.ToArray();
                this.lossFunction = lossFunction;

                int nRows = trainingRows.Length;

                y = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, trainingRows).ToArray();

                treeBuilder = new RegressionTreeBuilder(problemData, random);

                activeIdx = Enumerable.Range(0, nRows).ToArray();

                var    zeros = Enumerable.Repeat(0.0, nRows).ToArray();
                double f0    = lossFunction.LineSearch(y, zeros, activeIdx, 0, nRows - 1); // initial constant value (mean for squared errors)

                pred      = Enumerable.Repeat(f0, nRows).ToArray();
                predTest  = Enumerable.Repeat(f0, testRows.Length).ToArray();
                pseudoRes = new double[nRows];

                models  = new List <IRegressionModel>();
                weights = new List <double>();
                // add constant model
                models.Add(new ConstantModel(f0, problemData.TargetVariable));
                weights.Add(1.0);
            }