- Timestamp:
- 09/03/09 15:00:23 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/PredictorBuilder.cs
r2319 r2328 28 28 using HeuristicLab.GP.Interfaces; 29 29 using HeuristicLab.Modeling; 30 using HeuristicLab.DataAnalysis; 30 31 31 32 namespace HeuristicLab.GP.StructureIdentification { … … 35 36 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree", typeof(IGeneticProgrammingModel), VariableKind.In)); 36 37 AddVariableInfo(new VariableInfo("TreeEvaluator", "The tree evaluator used to evaluate the model", typeof(ITreeEvaluator), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("PunishmentFactor", "The punishment factor limits the estimated values to a certain range", typeof(DoubleData), VariableKind.In)); 39 AddVariableInfo(new VariableInfo("Dataset", "The dataset", typeof(Dataset), VariableKind.In)); 40 AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In)); 41 AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In)); 42 AddVariableInfo(new VariableInfo("TargetVariable", "Index of the target variable", typeof(IntData), VariableKind.In)); 37 43 AddVariableInfo(new VariableInfo("Predictor", "The predictor combines the function tree and the evaluator and can be used to generate estimated values", typeof(IPredictor), VariableKind.New)); 38 44 } … … 44 50 public override IOperation Apply(IScope scope) { 45 51 IGeneticProgrammingModel model = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true); 46 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 47 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Predictor"), new Predictor(evaluator, model))); 52 ITreeEvaluator evaluator = (ITreeEvaluator)GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true).Clone(); 53 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 54 Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true); 55 int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; 56 int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; 57 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data; 58 double mean = dataset.GetMean(targetVariable, start, end); 59 double range = dataset.GetRange(targetVariable, start, end); 60 double minEstimatedValue = mean - punishmentFactor * range; 61 double maxEstimatedValue = mean + punishmentFactor * range; 62 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Predictor"), new Predictor(evaluator, model, minEstimatedValue, maxEstimatedValue))); 48 63 return null; 49 64 }
Note: See TracChangeset
for help on using the changeset viewer.