コード例 #1
0
    private static RandomForestRegressionSolution GridSearchWithCrossvalidation(IRegressionProblemData problemData, out RFParameter bestParameters, int seed = 3141519)
    {
        double rmsError, outOfBagRmsError, avgRelError, outOfBagAvgRelError;

        bestParameters = RandomForestUtil.GridSearch(problemData, numberOfFolds, shuffleFolds, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
        var model = RandomForestModel.CreateRegressionModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed, out rmsError, out outOfBagRmsError, out avgRelError, out outOfBagAvgRelError);

        return((RandomForestRegressionSolution)model.CreateRegressionSolution(problemData));
    }
    private static RandomForestClassificationSolution GridSearch(IClassificationProblemData problemData, out RFParameter bestParameters, int seed = 3141519)
    {
        double rmsError, outOfBagRmsError, relClassificationError, outOfBagRelClassificationError;

        bestParameters = RandomForestUtil.GridSearch(problemData, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
        var model = RandomForestModel.CreateClassificationModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed,
                                                                out rmsError, out outOfBagRmsError, out relClassificationError, out outOfBagRelClassificationError);

        return((RandomForestClassificationSolution)model.CreateClassificationSolution(problemData));
    }