private IContent CreateModel(int idx) { idx -= 1; var rfModel = Content.Model as RandomForestModel; if (rfModel == null) { return(null); } var regProblemData = Content.ProblemData as IRegressionProblemData; var classProblemData = Content.ProblemData as IClassificationProblemData; if (idx < 0 || idx >= rfModel.NumberOfTrees) { return(null); } if (regProblemData != null) { var syModel = new SymbolicRegressionModel(regProblemData.TargetVariable, rfModel.ExtractTree(idx), new SymbolicDataAnalysisExpressionTreeLinearInterpreter()); return(syModel.CreateRegressionSolution(regProblemData)); } else if (classProblemData != null) { var syModel = new SymbolicDiscriminantFunctionClassificationModel(classProblemData.TargetVariable, rfModel.ExtractTree(idx), new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), new NormalDistributionCutPointsThresholdCalculator()); syModel.RecalculateModelParameters(classProblemData, classProblemData.TrainingIndices); return(syModel.CreateClassificationSolution(classProblemData)); } else { throw new InvalidProgramException(); } }
private static SymbolicDiscriminantFunctionClassificationModel CreateDiscriminantFunctionModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IClassificationProblemData problemData, IEnumerable <int> rows) { var model = new SymbolicDiscriminantFunctionClassificationModel(problemData.TargetVariable, tree, interpreter, new AccuracyMaximizationThresholdCalculator()); model.RecalculateModelParameters(problemData, rows); return(model); }