Changeset 2043 for trunk/sources/HeuristicLab.Modeling
- Timestamp:
- 06/15/09 16:46:25 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Modeling/3.2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling/3.2/VariableEvaluationImpactCalculator.cs
r2041 r2043 53 53 } 54 54 55 protected override double[] CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end) {56 return GetOutputs(scope, dataset, targetVariable, start, end);55 protected override double[] CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 56 return GetOutputs(scope, dataset, targetVariable, allowedFeatures, start, end); 57 57 } 58 58 … … 66 66 } 67 67 68 protected abstract double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end);68 protected abstract double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end); 69 69 } 70 70 } -
trunk/sources/HeuristicLab.Modeling/3.2/VariableImpactCalculatorBase.cs
r2041 r2043 31 31 namespace HeuristicLab.Modeling { 32 32 public abstract class VariableImpactCalculatorBase<T> : OperatorBase { 33 private bool abortRequested = false; 34 33 35 public override string Description { 34 36 get { return @"Calculates the impact of all allowed input variables on the model."; } … … 36 38 37 39 public abstract string OutputVariableName { get; } 40 41 public override void Abort() { 42 abortRequested = true; 43 } 38 44 39 45 public VariableImpactCalculatorBase() … … 55 61 int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; 56 62 57 T referenceValue = CalculateValue(scope, dataset, targetVariable, start, end);63 T referenceValue = CalculateValue(scope, dataset, targetVariable, allowedFeatures, start, end); 58 64 double[] impacts = new double[allowedFeatures.Count]; 59 65 60 for (int i = 0; i < allowedFeatures.Count ; i++) {66 for (int i = 0; i < allowedFeatures.Count && !abortRequested; i++) { 61 67 int currentVariable = allowedFeatures[i].Data; 62 var oldValues = ReplaceVariableValues(dirtyDataset, currentVariable 63 T newValue = CalculateValue(scope, dirtyDataset, targetVariable, start, end);68 var oldValues = ReplaceVariableValues(dirtyDataset, currentVariable, CalculateNewValues(dirtyDataset, currentVariable, start, end), start, end); 69 T newValue = CalculateValue(scope, dirtyDataset, targetVariable, allowedFeatures, start, end); 64 70 impacts[i] = CalculateImpact(referenceValue, newValue); 65 71 ReplaceVariableValues(dirtyDataset, currentVariable, oldValues, start, end); 66 72 } 67 73 68 impacts = PostProcessImpacts(impacts); 74 if (!abortRequested) { 75 impacts = PostProcessImpacts(impacts); 69 76 70 ItemList variableImpacts = new ItemList(); 71 for (int i = 0; i < allowedFeatures.Count; i++) { 72 int currentVariable = allowedFeatures[i].Data; 73 ItemList row = new ItemList(); 74 row.Add(new StringData(dataset.GetVariableName(currentVariable))); 75 row.Add(new DoubleData(impacts[i])); 76 variableImpacts.Add(row); 77 ItemList variableImpacts = new ItemList(); 78 for (int i = 0; i < allowedFeatures.Count; i++) { 79 int currentVariable = allowedFeatures[i].Data; 80 ItemList row = new ItemList(); 81 row.Add(new StringData(dataset.GetVariableName(currentVariable))); 82 row.Add(new DoubleData(impacts[i])); 83 variableImpacts.Add(row); 84 } 85 86 scope.AddVariable(new Variable(scope.TranslateName(OutputVariableName), variableImpacts)); 87 return null; 88 } else { 89 return new AtomicOperation(this, scope); 77 90 } 78 79 scope.AddVariable(new Variable(scope.TranslateName(OutputVariableName), variableImpacts));80 return null;81 91 } 82 92 83 protected abstract T CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end);93 protected abstract T CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end); 84 94 85 95 protected abstract double CalculateImpact(T referenceValue, T newValue); … … 96 106 int index = start; 97 107 ds.FireChangeEvents = false; 98 foreach (double v in newValues) {108 foreach (double v in newValues) { 99 109 ds.SetValue(index++, variableIndex, v); 100 110 } -
trunk/sources/HeuristicLab.Modeling/3.2/VariableQualityImpactCalculator.cs
r2041 r2043 43 43 } 44 44 45 protected override double CalculateValue(IScope scope, Dataset dataset, int targetVariable, int start, int end) {46 return CalculateQuality(scope, dataset, targetVariable, start, end);45 protected override double CalculateValue(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 46 return CalculateQuality(scope, dataset, targetVariable, allowedFeatures, start, end); 47 47 } 48 48 49 protected abstract double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end);49 protected abstract double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end); 50 50 } 51 51 }
Note: See TracChangeset
for help on using the changeset viewer.