Changeset 2043 for trunk/sources
- Timestamp:
- 06/15/09 16:46:25 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs
r2041 r2043 41 41 42 42 43 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end) {43 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 44 44 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 45 45 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs
r2041 r2043 40 40 } 41 41 42 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end) {42 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 43 43 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 44 44 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); -
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 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/HeuristicLab.SupportVectorMachines-3.2.csproj
r1906 r2043 88 88 <Compile Include="SupportVectorEvaluator.cs" /> 89 89 <Compile Include="SVMHelper.cs" /> 90 <Compile Include="VariableEvaluationImpactCalculator.cs" /> 91 <Compile Include="VariableQualityImpactCalculator.cs" /> 90 92 </ItemGroup> 91 93 <ItemGroup> … … 126 128 <Name>HeuristicLab.PluginInfrastructure</Name> 127 129 </ProjectReference> 130 <ProjectReference Include="..\..\HeuristicLab.Random\3.2\HeuristicLab.Random-3.2.csproj"> 131 <Project>{47019A74-F7F7-482E-83AA-D3F4F777E879}</Project> 132 <Name>HeuristicLab.Random-3.2</Name> 133 </ProjectReference> 134 <ProjectReference Include="..\..\HeuristicLab.Selection\3.2\HeuristicLab.Selection-3.2.csproj"> 135 <Project>{F7CF0571-25CB-43D5-8443-0843A1E2861A}</Project> 136 <Name>HeuristicLab.Selection-3.2</Name> 137 </ProjectReference> 128 138 <ProjectReference Include="..\..\HeuristicLab.SequentialEngine\3.2\HeuristicLab.SequentialEngine-3.2.csproj"> 129 139 <Project>{B4BE8E53-BA06-4237-9A01-24255F880201}</Project> -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/HeuristicLabSupportVectorMachinesPlugin.cs
r1857 r2043 37 37 [Dependency(Dependency = "HeuristicLab.Logging-3.2")] 38 38 [Dependency(Dependency = "HeuristicLab.Operators.Programmable-3.2")] 39 [Dependency(Dependency = "HeuristicLab.Random-3.2")] 40 [Dependency(Dependency = "HeuristicLab.Selection-3.2")] 39 41 public class HeuristicLabSupportVectorMachinesPlugin : PluginBase { 40 42 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorEvaluator.cs
r2036 r2043 59 59 for (int i = 0; i < end - start; i++) { 60 60 values[i,0] = SVM.Prediction.Predict(modelData.Model, scaledProblem.X[i]); 61 values[i,1] = dataset. Samples[(start + i) * dataset.Columns + targetVariable];61 values[i,1] = dataset.GetValue(start + i,targetVariable); 62 62 } 63 63 -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs
r1922 r2043 34 34 using HeuristicLab.Operators.Programmable; 35 35 using HeuristicLab.Modeling; 36 using HeuristicLab.Random; 37 using HeuristicLab.Selection; 36 38 37 39 namespace HeuristicLab.SupportVectorMachines { … … 118 120 main.AddSubOperator(CreateGlobalInjector()); 119 121 main.AddSubOperator(new ProblemInjector()); 120 121 SequentialProcessor nuLoop = new SequentialProcessor(); 122 nuLoop.Name = "NuLoop"; 123 SequentialProcessor costLoop = new SequentialProcessor(); 124 costLoop.Name = "CostLoop"; 125 main.AddSubOperator(nuLoop); 126 nuLoop.AddSubOperator(CreateResetOperator("CostIndex")); 127 nuLoop.AddSubOperator(costLoop); 122 main.AddSubOperator(new RandomInjector()); 123 128 124 SubScopesCreater modelScopeCreator = new SubScopesCreater(); 129 125 modelScopeCreator.GetVariableInfo("SubScopes").Local = true; 130 126 modelScopeCreator.AddVariable(new HeuristicLab.Core.Variable("SubScopes", new IntData(1))); 127 main.AddSubOperator(modelScopeCreator); 128 129 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 130 IOperator modelProcessor = CreateModelProcessor(); 131 seqSubScopesProc.AddSubOperator(modelProcessor); 132 main.AddSubOperator(seqSubScopesProc); 133 134 SequentialProcessor nuLoop = new SequentialProcessor(); 135 nuLoop.Name = "NuLoop"; 136 137 IOperator costCounter = CreateCounter("Cost"); 138 IOperator costComparator = CreateComparator("Cost"); 139 nuLoop.AddSubOperator(costCounter); 140 nuLoop.AddSubOperator(costComparator); 141 ConditionalBranch costBranch = new ConditionalBranch(); 142 costBranch.Name = "IfValidCostIndex"; 143 costBranch.GetVariableInfo("Condition").ActualName = "RepeatCostLoop"; 144 145 // build cost loop 146 SequentialProcessor costLoop = new SequentialProcessor(); 147 costLoop.Name = "CostLoop"; 131 148 costLoop.AddSubOperator(modelScopeCreator); 132 149 SequentialSubScopesProcessor subScopesProcessor = new SequentialSubScopesProcessor(); 133 150 costLoop.AddSubOperator(subScopesProcessor); 151 subScopesProcessor.AddSubOperator(new EmptyOperator()); 152 subScopesProcessor.AddSubOperator(modelProcessor); 153 154 Sorter sorter = new Sorter(); 155 sorter.GetVariableInfo("Value").ActualName = "ValidationQuality"; 156 sorter.GetVariableInfo("Descending").Local = true; 157 sorter.AddVariable(new Variable("Descending", new BoolData(false))); 158 costLoop.AddSubOperator(sorter); 159 160 LeftSelector selector = new LeftSelector(); 161 selector.GetVariableInfo("Selected").Local = true; 162 selector.AddVariable(new Variable("Selected", new IntData(1))); 163 costLoop.AddSubOperator(selector); 164 165 RightReducer reducer = new RightReducer(); 166 costLoop.AddSubOperator(reducer); 167 168 costLoop.AddSubOperator(costCounter); 169 costLoop.AddSubOperator(costComparator); 170 171 costBranch.AddSubOperator(costLoop); 172 costLoop.AddSubOperator(costBranch); 173 174 nuLoop.AddSubOperator(costBranch); 175 nuLoop.AddSubOperator(CreateResetOperator("CostIndex")); 176 177 nuLoop.AddSubOperator(CreateCounter("Nu")); 178 nuLoop.AddSubOperator(CreateComparator("Nu")); 179 180 ConditionalBranch nuBranch = new ConditionalBranch(); 181 nuBranch.Name = "NuLoop"; 182 nuBranch.GetVariableInfo("Condition").ActualName = "RepeatNuLoop"; 183 nuBranch.AddSubOperator(nuLoop); 184 nuLoop.AddSubOperator(nuBranch); 185 186 main.AddSubOperator(nuLoop); 187 main.AddSubOperator(CreateModelAnalyser()); 188 return main; 189 } 190 191 private IOperator CreateModelProcessor() { 134 192 SequentialProcessor modelProcessor = new SequentialProcessor(); 135 subScopesProcessor.AddSubOperator(modelProcessor);136 193 modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Nu")); 137 194 modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Cost")); … … 160 217 ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("ValidationQuality")); 161 218 modelProcessor.AddSubOperator(collector); 162 163 BestSolutionStorer solStorer = new BestSolutionStorer(); 164 solStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality"; 165 solStorer.GetVariableInfo("Maximization").Local = true; 166 solStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution"; 167 solStorer.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false))); 168 169 costLoop.AddSubOperator(solStorer); 170 SubScopesRemover remover = new SubScopesRemover(); 171 costLoop.AddSubOperator(remover); 172 costLoop.AddSubOperator(CreateCounter("Cost")); 173 costLoop.AddSubOperator(CreateComparator("Cost")); 174 ConditionalBranch costBranch = new ConditionalBranch(); 175 costBranch.Name = "CostLoop"; 176 costBranch.GetVariableInfo("Condition").ActualName = "RepeatCostLoop"; 177 costBranch.AddSubOperator(costLoop); 178 costLoop.AddSubOperator(costBranch); 179 180 nuLoop.AddSubOperator(CreateCounter("Nu")); 181 nuLoop.AddSubOperator(CreateComparator("Nu")); 182 ConditionalBranch nuBranch = new ConditionalBranch(); 183 nuBranch.Name = "NuLoop"; 184 nuBranch.GetVariableInfo("Condition").ActualName = "RepeatNuLoop"; 185 nuBranch.AddSubOperator(nuLoop); 186 nuLoop.AddSubOperator(nuBranch); 187 return main; 219 return modelProcessor; 188 220 } 189 221 … … 271 303 progOp.RemoveVariableInfo("Result"); 272 304 progOp.AddVariableInfo(new VariableInfo("Value", "Value", typeof(IntData), VariableKind.In | VariableKind.Out)); 273 progOp.Code = "Value.Data = 0;";305 progOp.Code = "Value.Data = -1;"; 274 306 progOp.GetVariableInfo("Value").ActualName = paramName; 275 307 return progOp; … … 279 311 VariableInjector injector = new VariableInjector(); 280 312 injector.AddVariable(new HeuristicLab.Core.Variable("CostIndex", new IntData(0))); 281 injector.AddVariable(new HeuristicLab.Core.Variable("CostList", new DoubleArrayData(new double[] { 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0 , 16.0, 32.0, 64.0, 128.0})));313 injector.AddVariable(new HeuristicLab.Core.Variable("CostList", new DoubleArrayData(new double[] { 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0 }))); 282 314 injector.AddVariable(new HeuristicLab.Core.Variable("MaxCostIndex", new IntData())); 283 315 injector.AddVariable(new HeuristicLab.Core.Variable("NuIndex", new IntData(0))); 284 injector.AddVariable(new HeuristicLab.Core.Variable("NuList", new DoubleArrayData(new double[] { 0.01, 0.05, 0.1, 0.5 , 0.9})));316 injector.AddVariable(new HeuristicLab.Core.Variable("NuList", new DoubleArrayData(new double[] { 0.01, 0.05, 0.1, 0.5 }))); 285 317 injector.AddVariable(new HeuristicLab.Core.Variable("MaxNuIndex", new IntData())); 286 318 injector.AddVariable(new HeuristicLab.Core.Variable("Log", new ItemList())); … … 291 323 return injector; 292 324 } 325 326 private IOperator CreateModelAnalyser() { 327 CombinedOperator modelAnalyser = new CombinedOperator(); 328 modelAnalyser.Name = "Model Analyzer"; 329 SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor(); 330 SequentialProcessor seqProc = new SequentialProcessor(); 331 VariableEvaluationImpactCalculator evalImpactCalc = new VariableEvaluationImpactCalculator(); 332 evalImpactCalc.GetVariableInfo("SVMModel").ActualName = "Model"; 333 VariableQualityImpactCalculator qualImpactCalc = new VariableQualityImpactCalculator(); 334 qualImpactCalc.GetVariableInfo("SVMModel").ActualName = "Model"; 335 336 seqProc.AddSubOperator(evalImpactCalc); 337 seqProc.AddSubOperator(qualImpactCalc); 338 seqSubScopeProc.AddSubOperator(seqProc); 339 modelAnalyser.OperatorGraph.InitialOperator = seqSubScopeProc; 340 modelAnalyser.OperatorGraph.AddOperator(seqSubScopeProc); 341 return modelAnalyser; 342 } 343 293 344 294 345 protected internal virtual Model CreateSVMModel(IScope bestModelScope) { … … 309 360 model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data; 310 361 model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data; 311 362 312 363 model.Data = bestModelScope.GetVariableValue<SVMModel>("BestValidationModel", false); 313 364 HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 314 365 model.Dataset = ds; 315 366 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 367 368 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 369 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 370 foreach (ItemList row in evaluationImpacts) { 371 string variableName = ((StringData)row[0]).Data; 372 double impact = ((DoubleData)row[0]).Data; 373 model.SetVariableEvaluationImpact(variableName, impact); 374 } 375 foreach (ItemList row in qualityImpacts) { 376 string variableName = ((StringData)row[0]).Data; 377 double impact = ((DoubleData)row[0]).Data; 378 model.SetVariableQualityImpact(variableName, impact); 379 } 380 316 381 return model; 317 382 } … … 337 402 338 403 #endregion 339 340 404 } 341 405 } -
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 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/VariableQualityImpactCalculator.cs
r2042 r2043 29 29 using System.Linq; 30 30 31 namespace HeuristicLab. GP.StructureIdentification{31 namespace HeuristicLab.SupportVectorMachines { 32 32 public class VariableQualityImpactCalculator : HeuristicLab.Modeling.VariableQualityImpactCalculator { 33 33 34 34 public VariableQualityImpactCalculator() 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 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 43 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 44 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); 45 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 46 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree); 39 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures, int start, int end) { 40 SVMModel model = GetVariableValue<SVMModel>("SVMModel", scope, true); 41 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, allowedFeatures, targetVariable, start, end); 42 SVM.Problem scaledProblem = SVM.Scaling.Scale(problem, model.RangeTransform); 47 43 48 double[,] result = new double[end - start,2];49 for (int i = start; i < end; i++) {50 result[i - start, 0] = dataset.GetValue(i, targetVariable);51 result[i - start,1] = evaluator.Evaluate(i);44 double[,] values = new double[end - start, 2]; 45 for (int i = 0; i < end - start; i++) { 46 values[i, 0] = SVM.Prediction.Predict(model.Model, scaledProblem.X[i]); 47 values[i, 1] = dataset.GetValue(start + i,targetVariable); 52 48 } 53 49 54 return HeuristicLab.Modeling.SimpleMSEEvaluator.Calculate( result);50 return HeuristicLab.Modeling.SimpleMSEEvaluator.Calculate(values); 55 51 } 56 52 }
Note: See TracChangeset
for help on using the changeset viewer.