Ejemplo n.º 1
0
        double CrossValidate(int folds)
        {
            var(observations, targets) = DataSetUtilities.LoadDecisionTreeDataSet();

            var sut         = new CrossValidation <double>(new RandomIndexSampler <double>(42), folds);
            var predictions = sut.CrossValidate(new RegressionDecisionTreeLearner(), observations, targets);
            var metric      = new MeanSquaredErrorRegressionMetric();

            return(metric.Error(targets, predictions));
        }
        double CrossValidate(int folds)
        {
            var targetName   = "T";
            var parser       = new CsvParser(() => new StringReader(Resources.DecisionTreeData));
            var observations = parser.EnumerateRows(v => !v.Contains(targetName)).ToF64Matrix();
            var targets      = parser.EnumerateRows(targetName).ToF64Vector();

            var sut         = new CrossValidation <double>(new RandomIndexSampler <double>(42), folds);
            var predictions = sut.CrossValidate(new RegressionDecisionTreeLearner(), observations, targets);
            var metric      = new MeanSquaredErrorRegressionMetric();

            return(metric.Error(targets, predictions));
        }