Changeset 5624 for branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear
- Timestamp:
- 03/07/11 18:11:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
r5617 r5624 32 32 using System.Collections.Generic; 33 33 using HeuristicLab.Problems.DataAnalysis.Symbolic; 34 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 34 35 35 36 namespace HeuristicLab.Algorithms.DataAnalysis { … … 61 62 protected override void Run() { 62 63 double rmsError, cvRmsError; 63 IRegressionProblemData problemData = Problem.ProblemData; 64 int samplesStart = problemData.TrainingPartitionStart.Value; 65 int samplesEnd = problemData.TrainingPartitionEnd.Value; 66 IEnumerable<string> selectedInputVariables = problemData.InputVariables.CheckedItems.Select(x => x.Value); 67 var solution = CreateLinearRegressionSolution(problemData.Dataset, problemData.TargetVariable, selectedInputVariables, samplesStart, samplesEnd, out rmsError, out cvRmsError); 64 var solution = CreateLinearRegressionSolution(Problem.ProblemData, out rmsError, out cvRmsError); 68 65 Results.Add(new Result(LinearRegressionModelResultName, "The linear regression model.", solution)); 69 66 Results.Add(new Result("Root mean square error", "The root of the mean of squared errors of the linear regression model on the training set.", new DoubleValue(rmsError))); … … 71 68 } 72 69 73 public static ISymbolicExpressionTree CreateLinearRegressionSolution(Dataset dataset, string targetVariable, IEnumerable<string> allowedInputVariables, int start, int end, out double rmsError, out double cvRmsError) { 74 double[,] inputMatrix = LinearRegressionUtil.PrepareInputMatrix(dataset, targetVariable, allowedInputVariables, start, end); 70 public static ISymbolicRegressionSolution CreateLinearRegressionSolution(IRegressionProblemData problemData, out double rmsError, out double cvRmsError) { 71 Dataset dataset = problemData.Dataset; 72 string targetVariable = problemData.TargetVariable; 73 IEnumerable<string> allowedInputVariables = problemData.InputVariables.CheckedItems.Select(x => x.Value); 74 int samplesStart = problemData.TrainingPartitionStart.Value; 75 int samplesEnd = problemData.TrainingPartitionEnd.Value; 76 77 IEnumerable<string> selectedInputVariables = problemData.InputVariables.CheckedItems.Select(x => x.Value); 78 79 double[,] inputMatrix = LinearRegressionUtil.PrepareInputMatrix(dataset, targetVariable, allowedInputVariables, samplesStart, samplesEnd); 75 80 76 81 alglib.linearmodel lm = new alglib.linearmodel(); … … 107 112 addition.AddSubTree(cNode); 108 113 109 return tree; 114 SymbolicRegressionSolution solution = new SymbolicRegressionSolution(new SymbolicRegressionModel(tree, new SymbolicDataAnalysisExpressionTreeInterpreter()), problemData); 115 return solution; 110 116 } 111 117 #endregion
Note: See TracChangeset
for help on using the changeset viewer.