Changeset 2043 for trunk/sources/HeuristicLab.SupportVectorMachines/3.2/VariableEvaluationImpactCalculator.cs
- Timestamp:
- 06/15/09 16:46:25 (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/VariableEvaluationImpactCalculator.cs
r2042 r2043 29 29 using System.Linq; 30 30 31 namespace HeuristicLab. GP.StructureIdentification{31 namespace HeuristicLab.SupportVectorMachines { 32 32 public class VariableEvaluationImpactCalculator : HeuristicLab.Modeling.VariableEvaluationImpactCalculator { 33 33 34 34 public VariableEvaluationImpactCalculator() 35 35 : base() { 36 AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In)); 37 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IFunctionTree), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In)); 39 AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In)); 36 AddVariableInfo(new VariableInfo("SVMModel", "The model that should be evaluated", typeof(SVMModel), VariableKind.In)); 40 37 } 41 38 42 39 43 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 44 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 45 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); 46 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 47 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree); 40 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 41 SVMModel model = GetVariableValue<SVMModel>("SVMModel", scope, true); 42 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, allowedFeatures, targetVariable, start, end); 43 SVM.Problem scaledProblem = SVM.Scaling.Scale(problem, model.RangeTransform); 48 44 49 double[] result= new double[end - start];50 for (int i = start; i < end; i++) {51 result[i - start] = evaluator.Evaluate(i);45 double[] values = new double[end - start]; 46 for (int i = 0; i < end - start; i++) { 47 values[i] = SVM.Prediction.Predict(model.Model, scaledProblem.X[i]); 52 48 } 53 54 return result; 49 return values; 55 50 } 56 51 }
Note: See TracChangeset
for help on using the changeset viewer.