Changeset 2789 for trunk/sources
- Timestamp:
- 02/12/10 15:39:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
r2542 r2789 37 37 38 38 public LinearRegressionOperator() { 39 AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In)); 39 40 AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In)); 40 AddVariableInfo(new VariableInfo(" Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));41 AddVariableInfo(new VariableInfo("InputVariables", "List of allowed input variable names", typeof(ItemList), VariableKind.In)); 41 42 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); 42 43 AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); … … 56 57 IntData minTimeOffsetData = GetVariableValue<IntData>("MinTimeOffset", scope, true, false); 57 58 int minTimeOffset = minTimeOffsetData == null ? 0 : minTimeOffsetData.Data; 58 59 IFunctionTree tree = CreateModel(dataset, targetVariable, dataset.VariableNames, start, end, minTimeOffset, maxTimeOffset); 59 ItemList inputVariables = GetVariableValue<ItemList>("InputVariables", scope, true, false); 60 61 IFunctionTree tree; 62 if (inputVariables != null) { 63 tree = CreateModel(dataset, targetVariable, inputVariables.Cast<StringData>().Select(x => x.Data), start, end, minTimeOffset, maxTimeOffset); 64 } else { 65 tree = CreateModel(dataset, targetVariable, dataset.VariableNames, start, end, minTimeOffset, maxTimeOffset); 66 } 60 67 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree))); 61 68 return null; … … 106 113 int n = targetVector.Length; 107 114 int p = inputMatrix.GetLength(1); 115 // no features allowed -> return constant offset 116 if (p == 0) return new double[] { Statistics.Mean(targetVector) }; 108 117 double[,] dataset = new double[n, p]; 109 118 for (int row = 0; row < n; row++) {
Note: See TracChangeset
for help on using the changeset viewer.