Changeset 2038 for trunk/sources/HeuristicLab.Modeling
- Timestamp:
- 06/10/09 10:46:56 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Modeling/3.2
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
r2034 r2038 83 83 <ItemGroup> 84 84 <Compile Include="ClassificationProblemInjector.cs" /> 85 <Compile Include="VariableImpactCalculator.cs" />86 85 <Compile Include="Model.cs" /> 87 86 <Compile Include="IModel.cs" /> … … 106 105 <Compile Include="TimeSeriesProblemInjector.cs" /> 107 106 <Compile Include="SimpleVarianceAccountedForEvaluator.cs" /> 107 <Compile Include="VariableQualityImpactCalculator.cs" /> 108 108 </ItemGroup> 109 109 <ItemGroup> -
trunk/sources/HeuristicLab.Modeling/3.2/VariableQualityImpactCalculator.cs
r2037 r2038 30 30 31 31 namespace HeuristicLab.Modeling { 32 public class Variable ImpactCalculator : OperatorBase {32 public class VariableQualityImpactCalculator : OperatorBase { 33 33 public override string Description { 34 34 get { return @"Calculates the impact of all allowed input variables on the quality of the model using evaluator supplied as suboperator."; } 35 35 } 36 36 37 public Variable ImpactCalculator()37 public VariableQualityImpactCalculator() 38 38 : base() { 39 39 AddVariableInfo(new VariableInfo("Dataset", "Dataset", typeof(Dataset), VariableKind.In)); … … 42 42 AddVariableInfo(new VariableInfo("TrainingSamplesStart", "TrainingSamplesStart", typeof(IntData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "TrainingSamplesEnd", typeof(IntData), VariableKind.In)); 44 AddVariableInfo(new VariableInfo("Variable Impacts", "Variable impacts", typeof(ItemList), VariableKind.New));44 AddVariableInfo(new VariableInfo("VariableQualityImpacts", "Effect on quality of model (percentage of original quality) if variable is replaced by its mean.", typeof(ItemList), VariableKind.New)); 45 45 } 46 46 … … 53 53 int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; 54 54 55 if (SubOperators.Count < 1) throw new InvalidOperationException("Variable ImpactCalculator needs a suboperator to evaluate the model");55 if (SubOperators.Count < 1) throw new InvalidOperationException("VariableQualityImpactCalculator needs a suboperator to evaluate the model"); 56 56 IOperator evaluationOperator = this.SubOperators[0]; 57 58 ItemList variableImpacts = new ItemList(); 57 ItemList variableQualityImpacts = new ItemList(); 59 58 60 59 // calculateReferenceQuality … … 65 64 var oldValues = ReplaceVariableValues(dirtyDataset, currentVariable , CalculateNewValues(dirtyDataset, currentVariable, start, end), start, end); 66 65 double newQuality = CalculateQuality(scope, dirtyDataset, evaluationOperator); 67 double ratio = referenceQuality / newQuality; 68 double impact = ratio < 1.0 ? 1.0 - ratio : 1.0 - 1.0 / ratio; 66 double ratio = newQuality / referenceQuality; 69 67 ItemList row = new ItemList(); 70 68 row.Add(new StringData(dataset.GetVariableName(currentVariable))); 71 row.Add(new DoubleData( impact));72 variable Impacts.Add(row);69 row.Add(new DoubleData(ratio)); 70 variableQualityImpacts.Add(row); 73 71 ReplaceVariableValues(dirtyDataset, currentVariable, oldValues, start, end); 74 72 } 75 scope.AddVariable(new Variable(scope.TranslateName("Variable Impacts"), variableImpacts));73 scope.AddVariable(new Variable(scope.TranslateName("VariableQualityImpacts"), variableQualityImpacts)); 76 74 return null; 77 75 } … … 93 91 94 92 int index = start; 93 ds.FireChangeEvents = false; 95 94 foreach(double v in newValues) { 96 95 ds.SetValue(index++, variableIndex, v); 97 96 } 97 ds.FireChangeEvents = true; 98 ds.FireChanged(); 98 99 return oldValues; 99 100 }
Note: See TracChangeset
for help on using the changeset viewer.