- Timestamp:
- 09/15/09 14:01:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs
r2351 r2356 125 125 CombinedOperator algo = new CombinedOperator(); 126 126 SequentialProcessor seq = new SequentialProcessor(); 127 algo.Name = "SupportVectorRegression";128 seq.Name = "SupportVectorRegression";127 algo.Name = Name; 128 seq.Name = Name; 129 129 130 130 IOperator initialization = CreateInitialization(); 131 131 IOperator main = CreateMainLoop(); 132 IOperator postProc = Create ModelAnalyser();132 IOperator postProc = CreatePostProcessingOperator(); 133 133 134 134 seq.AddSubOperator(initialization); … … 145 145 SequentialProcessor seq = new SequentialProcessor(); 146 146 seq.Name = "Initialization"; 147 seq.AddSubOperator(new RandomInjector()); 147 148 seq.AddSubOperator(CreateGlobalInjector()); 148 ProblemInjector probInjector = new ProblemInjector(); 149 probInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true; 150 probInjector.AddVariable(new Variable("MaxNumberOfTrainingSamples", new IntData(1000))); 151 seq.AddSubOperator(probInjector); 152 seq.AddSubOperator(new RandomInjector()); 153 154 DatasetShuffler shuffler = new DatasetShuffler(); 155 shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart"; 156 shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd"; 157 seq.AddSubOperator(shuffler); 149 seq.AddSubOperator(CreateProblemInjector()); 158 150 return seq; 151 } 152 153 protected virtual IOperator CreateProblemInjector() { 154 return DefaultRegressionOperators.CreateProblemInjector(); 159 155 } 160 156 … … 402 398 } 403 399 404 protected virtual IOperator Create ModelAnalyser() {400 protected virtual IOperator CreatePostProcessingOperator() { 405 401 CombinedOperator modelAnalyser = new CombinedOperator(); 406 402 modelAnalyser.Name = "Model Analyzer"; … … 410 406 PredictorBuilder predictorBuilder = new PredictorBuilder(); 411 407 predictorBuilder.GetVariableInfo("SVMModel").ActualName = "Model"; 412 VariableEvaluationImpactCalculator evalImpactCalc = new VariableEvaluationImpactCalculator();413 evalImpactCalc.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";414 evalImpactCalc.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";415 VariableQualityImpactCalculator qualImpactCalc = new VariableQualityImpactCalculator();416 qualImpactCalc.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";417 qualImpactCalc.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";418 408 419 409 seqProc.AddSubOperator(CreateEvaluator("Test")); 410 seqProc.AddSubOperator(CreateEvaluator("Training")); 420 411 seqProc.AddSubOperator(predictorBuilder); 421 seqProc.AddSubOperator( evalImpactCalc);422 seqProc.AddSubOperator(qualImpactCalc); 412 seqProc.AddSubOperator(CreateModelAnalyzerOperator()); 413 423 414 seqSubScopeProc.AddSubOperator(seqProc); 424 415 modelAnalyser.OperatorGraph.InitialOperator = seqSubScopeProc; … … 427 418 } 428 419 420 protected virtual IOperator CreateModelAnalyzerOperator() { 421 return DefaultRegressionOperators.CreatePostProcessingOperator(); 422 } 423 429 424 430 425 protected virtual IAnalyzerModel CreateSVMModel(IScope bestModelScope) { 431 426 AnalyzerModel model = new AnalyzerModel(); 432 model.SetResult("TrainingMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data);433 model.SetResult("ValidationMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data);434 model.SetResult("TestMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("TestQuality", false).Data);435 model.SetResult("TrainingCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingR2", false).Data);436 model.SetResult("ValidationCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data);437 model.SetResult("TestCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data);438 model.SetResult("TrainingMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPE", false).Data);439 model.SetResult("ValidationMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data);440 model.SetResult("TestMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data);441 model.SetResult("TrainingMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPRE", false).Data);442 model.SetResult("ValidationMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data);443 model.SetResult("TestMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data);444 model.SetResult("TrainingVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingVAF", false).Data);445 model.SetResult("ValidationVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data);446 model.SetResult("TestVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data);447 448 427 model.SetMetaData("Cost", bestModelScope.GetVariableValue<DoubleData>("Cost", false).Data); 449 428 model.SetMetaData("Nu", bestModelScope.GetVariableValue<DoubleData>("Nu", false).Data); 450 451 HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 452 model.Dataset = ds; 453 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 454 model.TrainingSamplesStart = bestModelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data; 455 model.TrainingSamplesEnd = bestModelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data; 456 model.ValidationSamplesStart = bestModelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data; 457 model.ValidationSamplesEnd = bestModelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data; 458 model.TestSamplesStart = bestModelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data; 459 model.TestSamplesEnd = bestModelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data; 460 model.Predictor = bestModelScope.GetVariableValue<IPredictor>("Predictor", true); 461 462 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 463 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 464 foreach (ItemList row in evaluationImpacts) { 465 string variableName = ((StringData)row[0]).Data; 466 double impact = ((DoubleData)row[1]).Data; 467 model.SetVariableEvaluationImpact(variableName, impact); 468 model.AddInputVariable(variableName); 469 } 470 foreach (ItemList row in qualityImpacts) { 471 string variableName = ((StringData)row[0]).Data; 472 double impact = ((DoubleData)row[1]).Data; 473 model.SetVariableQualityImpact(variableName, impact); 474 model.AddInputVariable(variableName); 475 } 429 DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model); 476 430 477 431 return model; … … 479 433 480 434 protected IOperator GetVariableInjector() { 481 return GetMainOperator().SubOperators[0].SubOperators[ 0];435 return GetMainOperator().SubOperators[0].SubOperators[1]; 482 436 } 483 437
Note: See TracChangeset
for help on using the changeset viewer.