- Timestamp:
- 03/27/18 17:34:41 (7 years ago)
- Location:
- branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Datastream.cs
r14710 r15867 39 39 40 40 protected const string ProblemDataParameterName = "ProblemData"; 41 protected const string DataSourceAddressParameterName = "DataSourceAdress"; 41 42 protected const string InitialSlidingWindowParameterName = "InitialSlidingWindowParameter"; 42 43 protected const string SlidingWindowSizeParameterName = "SlidingWindowSize"; … … 45 46 protected const string FitnessPartitionParameterName = "FitnessPartition"; 46 47 protected const string SlidingWindowSonarRatioParameterName = "SlidingWindowSonarRatio"; 48 protected const string SlidingWindowEvaluationSchemeParameterName = "SlidingWindowEvaluationScheme"; 47 49 48 50 #region parameter properites 49 51 50 public IValueParameter<RegressionProblemData> ProblemDataParameter { 51 get { return (IValueParameter<RegressionProblemData>) Parameters[ProblemDataParameterName]; } 52 } 53 54 public IValueParameter<IntRange> InitialSlidingWindowParameter { 55 get { return (IValueParameter<IntRange>) Parameters[InitialSlidingWindowParameterName]; } 56 } 57 58 public IValueParameter<IntValue> SlidingWindowSizeParameter { 59 get { return (IValueParameter<IntValue>) Parameters[SlidingWindowSizeParameterName]; } 60 } 61 62 public IValueParameter<IntValue> SlidingWindowStepWidthParameter { 63 get { return (IValueParameter<IntValue>) Parameters[SlidingWindowStepWidthParameterName]; } 64 } 65 66 public IValueParameter<IntValue> SlidingWindowMovementDelayParameter { 67 get { return (IValueParameter<IntValue>) Parameters[SlidingWindowMovementDelayParameterName]; } 68 } 69 70 public IValueParameter<DoubleValue> SlidingWindowSonarRatioParameter { 71 get { return (IValueParameter<DoubleValue>) Parameters[SlidingWindowSonarRatioParameterName]; } 52 public enum EvaluationScheme { none, equal, linear, quadratic, cubic, exponential } 53 54 public IValueParameter<RegressionProblemData> ProblemDataParameter 55 { 56 get { return (IValueParameter<RegressionProblemData>)Parameters[ProblemDataParameterName]; } 57 } 58 59 public IValueParameter<StringValue> DataSourceAddressParameter 60 { 61 get { return (IValueParameter<StringValue>)Parameters[DataSourceAddressParameterName]; } 62 } 63 64 public IValueParameter<IntRange> InitialSlidingWindowParameter 65 { 66 get { return (IValueParameter<IntRange>)Parameters[InitialSlidingWindowParameterName]; } 67 } 68 69 public IValueParameter<IntValue> SlidingWindowSizeParameter 70 { 71 get { return (IValueParameter<IntValue>)Parameters[SlidingWindowSizeParameterName]; } 72 } 73 74 public IValueParameter<IntValue> SlidingWindowStepWidthParameter 75 { 76 get { return (IValueParameter<IntValue>)Parameters[SlidingWindowStepWidthParameterName]; } 77 } 78 79 public IValueParameter<IntValue> SlidingWindowMovementDelayParameter 80 { 81 get { return (IValueParameter<IntValue>)Parameters[SlidingWindowMovementDelayParameterName]; } 82 } 83 84 public IValueParameter<DoubleValue> SlidingWindowSonarRatioParameter 85 { 86 get { return (IValueParameter<DoubleValue>)Parameters[SlidingWindowSonarRatioParameterName]; } 87 } 88 89 public IValueParameter<EnumValue<EvaluationScheme>> SlidingWindowEvaluationSchemeParameter 90 { 91 get 92 { 93 return (IValueParameter<EnumValue<EvaluationScheme>>)Parameters[SlidingWindowEvaluationSchemeParameterName]; 94 } 72 95 } 73 96 … … 80 103 #region properties 81 104 82 public RegressionProblemData ProblemData { 105 public RegressionProblemData ProblemData 106 { 83 107 get { return ProblemDataParameter.Value; } 84 set { 85 if(value == null) throw new ArgumentNullException("ProblemData", "The provided value for problemData is null."); 108 set 109 { 110 if (value == null) throw new ArgumentNullException("ProblemData", "The provided value for problemData is null."); 86 111 ProblemDataParameter.Value = value; 87 112 //OnProblemDataChanged(); 88 113 } 89 114 } 90 91 92 public IntRange InitialSlidingWindow { 115 116 public StringValue DataSourceAddress 117 { 118 get { return DataSourceAddressParameter.Value; } 119 set { DataSourceAddressParameter.Value = value; } 120 } 121 122 public IntRange InitialSlidingWindow 123 { 93 124 get { return InitialSlidingWindowParameter.Value; } 94 125 set { InitialSlidingWindowParameter.Value = value; } 95 126 } 96 127 97 public IntValue SlidingWindowSize { 128 public IntValue SlidingWindowSize 129 { 98 130 get { return SlidingWindowSizeParameter.Value; } 99 131 set { SlidingWindowSizeParameter.Value = value; } 100 132 } 101 133 102 public IntValue SlidingWindowStepWidth { 134 public IntValue SlidingWindowStepWidth 135 { 103 136 get { return SlidingWindowStepWidthParameter.Value; } 104 137 set { SlidingWindowStepWidthParameter.Value = value; } 105 138 } 106 139 107 public IntValue SlidingWindowMovementDelay { 140 public IntValue SlidingWindowMovementDelay 141 { 108 142 get { return SlidingWindowMovementDelayParameter.Value; } 109 143 set { SlidingWindowMovementDelayParameter.Value = value; } 110 144 } 111 145 112 public DoubleValue SlidingWindowSonarRatio { 146 public DoubleValue SlidingWindowSonarRatio 147 { 113 148 get { return SlidingWindowSonarRatioParameter.Value; } 114 149 set { SlidingWindowSonarRatioParameter.Value = value; } 115 150 } 116 151 152 public EnumValue<EvaluationScheme> SlidingWindowEvaluationScheme 153 { 154 get { return SlidingWindowEvaluationSchemeParameter.Value; } 155 set { SlidingWindowEvaluationSchemeParameter.Value = value; } 156 } 157 158 117 159 #endregion 118 160 … … 121 163 public IntRange FitnessPartition { get; set; } 122 164 123 public bool UpdateAvailable { 124 get { return false; } 125 } 126 127 public bool SlidingWindowMovementPossible { 128 get { 165 public bool UpdateAvailable 166 { 167 get { return !String.IsNullOrWhiteSpace(DataSourceAddress.Value); } 168 } 169 170 public bool SlidingWindowMovementPossible 171 { 172 get 173 { 129 174 return ProblemData != null && ProblemData.Dataset != null && 130 175 ( … … 135 180 } 136 181 137 public bool SlidingWindowEvaluationPossible { 138 get { 182 public bool SlidingWindowEvaluationPossible 183 { 184 get 185 { 139 186 //return ProblemData != null && ProblemData.Dataset != null && ProblemData.Dataset.Rows > 0 && FitnessPartition.Size > 0; 140 187 return FitnessPartition.Size > 0; … … 149 196 FitnessPartition.Start += SlidingWindowStepWidth.Value; 150 197 FitnessPartition.End += SlidingWindowStepWidth.Value; 151 } else { 198 } else { 152 199 FitnessPartition.End += SlidingWindowStepWidth.Value; 153 200 FitnessPartition.Start += FitnessPartition.End - SlidingWindowSize.Value; 154 } 201 } 155 202 156 203 //if (FitnessPartition.Size > SlidingWindowSize.Value) { … … 191 238 public Datastream() : base() { 192 239 Parameters.Add(new ValueParameter<RegressionProblemData>(ProblemDataParameterName, "ProblemData for analysis with selected ensembles.", null)); 240 Parameters.Add(new FixedValueParameter<StringValue>(DataSourceAddressParameterName, "Source address of data stream", new StringValue(""))); 193 241 Parameters.Add(new FixedValueParameter<IntRange>(InitialSlidingWindowParameterName, "Initial sliding window boundaries", new IntRange(0, 100))); 194 242 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "Sliding window size", new IntValue(100))); … … 196 244 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowMovementDelayParameterName, "Sliding window movement delay interval (milliseconds)", new IntValue(0))); 197 245 Parameters.Add(new FixedValueParameter<DoubleValue>(SlidingWindowSonarRatioParameterName, "Sliding window sonar ratio", new DoubleValue(0.25))); 246 Parameters.Add(new FixedValueParameter<EnumValue<EvaluationScheme>>(SlidingWindowEvaluationSchemeParameterName, "Sliding window evaluation scheme", new EnumValue<EvaluationScheme>(EvaluationScheme.none))); 198 247 RegisterParameterEvents(); 199 248 InitializeState(); … … 201 250 #endregion 202 251 203 public void InitializeState() {252 public void InitializeState() { 204 253 if (ProblemData == null || ProblemData.Dataset == null || ProblemData.Dataset.Rows == 0) { 205 254 FitnessPartition = new IntRange(0, 0); … … 216 265 FitnessPartition = new IntRange(0, 0); 217 266 } else { 218 if (FitnessPartition == null) FitnessPartition = (IntRange)InitialSlidingWindow.Clone();267 if (FitnessPartition == null) FitnessPartition = (IntRange)InitialSlidingWindow.Clone(); 219 268 if (FitnessPartition.End > ProblemData.Dataset.Rows) { 220 269 FitnessPartition.End = ProblemData.Dataset.Rows; … … 258 307 // TODO 259 308 public IEnumerable<IParameterizedItem> ExecutionContextItems { get; } 260 309 261 310 } 262 311 } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/DatastreamAnalysisOptimizer.cs
r14710 r15867 74 74 } 75 75 76 private double lastStateValue;76 //private double lastStateValue; 77 77 private double pR2Sum; 78 78 private int detectionCount; … … 108 108 109 109 [Storable] 110 private IItemList< RatedEnsembleModel> ensembles;111 112 public IItemList< RatedEnsembleModel> Ensembles {110 private IItemList<ProxyEnsembleModel> ensembles; 111 112 public IItemList<ProxyEnsembleModel> Ensembles { 113 113 get { return ensembles; } 114 114 set { 115 115 if (value == null || value == ensembles) 116 116 return; 117 if (!(value is I RatedEnsembleModel)) throw new ArgumentException("Invaid ensemble model type");117 if (!(value is IProxyEnsembleModel)) throw new ArgumentException("Invaid ensemble model type"); 118 118 DeregisterEnsembleEvents(); 119 119 ensembles = value; … … 214 214 protected void SetupResults() { 215 215 evaluationCount = 0; 216 lastStateValue = 0.0;216 //lastStateValue = 0.0; 217 217 pR2Sum = 0.0; 218 218 exclusivitySum = 0.0; … … 267 267 log = new Log(); 268 268 results = new ResultCollection(); 269 ensembles = new ItemList< RatedEnsembleModel>();269 ensembles = new ItemList<ProxyEnsembleModel>(); 270 270 datastream = new Datastream(); 271 271 runsCounter = 0; … … 287 287 log = cloner.Clone(original.log); 288 288 results = cloner.Clone(original.results); 289 ensembles = (ItemList< RatedEnsembleModel>) original.Ensembles.Clone(cloner);289 ensembles = (ItemList<ProxyEnsembleModel>) original.Ensembles.Clone(cloner); 290 290 datastream = (Datastream) original.Datastream.Clone(cloner); 291 291 runsCounter = original.runsCounter; … … 322 322 } 323 323 324 public override void Start() { 324 public override void Start(CancellationToken cancellationToken) { 325 base.Start(cancellationToken); 325 326 if (ensembles == null || datastream == null) return; 326 base.Start(); 327 cancellationTokenSource = new CancellationTokenSource();327 328 cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); 328 329 stopPending = false; 329 330 … … 450 451 // play and evaluate initial window 451 452 PlayDatastream(); 452 lastStateValue = Datastream.ProblemData.Dataset.GetDoubleValue("h", replayedIndex);453 //lastStateValue = Datastream.ProblemData.Dataset.GetDoubleValue("h", replayedIndex); 453 454 if (Datastream.SlidingWindowEvaluationPossible) Evaluate(); 454 455 replayedIndex = Datastream.FitnessPartition.End; … … 490 491 } 491 492 } 492 493 494 private void Smoothen(double[] estimatedValuesPerRow) { 495 if (Datastream.SlidingWindowEvaluationScheme.Value == Datastream.EvaluationScheme.equal) { 496 var avg = estimatedValuesPerRow.Average(); 497 for (int i = 0; i < estimatedValuesPerRow.Length; i++) { 498 estimatedValuesPerRow[i] = avg; 499 } 500 } 501 } 502 493 503 private void Evaluate() { 494 504 evaluationCount++; … … 512 522 var curDetectionCount = 0; 513 523 var changeDetectionCount = 0; 514 double curStateValue = 0.0; 524 //double curStateValue = 0.0; 525 515 526 foreach (var ensemble in Ensembles) { 516 527 517 528 var sonarEstimatedValuesPerModelPerRow = ensemble.Model.Models.Select(x => x.GetEstimatedValues(datastream.ProblemData.Dataset, sonarRows).ToArray()); 518 529 var sonarEstimatedValuesPerRow = Enumerable.Range(0, sonarSize).Select(r => sonarEstimatedValuesPerModelPerRow.Select(m => m[r]).Average()).ToArray(); 519 530 520 531 var estimatedValuesPerModelPerRow = ensemble.Model.Models.Select(x => x.GetEstimatedValues(datastream.ProblemData.Dataset, rows).ToArray()); 521 532 var estimatedValuesPerRow = Enumerable.Range(0, Datastream.FitnessPartition.Size).Select(r => estimatedValuesPerModelPerRow.Select(e => e[r]).Average()).ToArray(); // per row … … 550 561 int replayCount = estimatedValuesPerRow.Length - replayAmount; 551 562 563 Smoothen(estimatedValuesPerRow); 564 552 565 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 553 566 //ResultsTargets.Rows[ensemble.Name].Values.Add(averageEstimatedValue); … … 594 607 } 595 608 596 double replCount = 0.0; 597 double accCount = 0.0; 598 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 599 replCount++; 600 curStateValue = problemData.Dataset.GetDoubleValue("h", i); 601 if (curStateValue <= 0.5 && winningEnsembleIdx == 0 && winningEnsemblePR2 > ensembles[winningEnsembleIdx].QualityThreshold.Start) { 602 accCount++; 603 } else if (curStateValue > 0.5 && winningEnsembleIdx == 1 && winningEnsemblePR2 > ensembles[winningEnsembleIdx].QualityThreshold.Start) { 604 accCount++; 605 } 606 } 607 accuracySum += accCount / replCount; 608 ResultsDetectionAccuracy = accuracySum / evaluationCount; 609 //double replCount = 0.0; 610 //double accCount = 0.0; 611 //for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 612 // replCount++; 613 // //curStateValue = problemData.Dataset.GetDoubleValue("h", i); 614 // if (curStateValue <= 0.5 && winningEnsembleIdx == 0 && winningEnsemblePR2 > ensembles[winningEnsembleIdx].QualityThreshold.Start) { 615 // accCount++; 616 // } else if (curStateValue > 0.5 && winningEnsembleIdx == 1 && winningEnsemblePR2 > ensembles[winningEnsembleIdx].QualityThreshold.Start) { 617 // accCount++; 618 // } 619 //} 620 //accuracySum += accCount / replCount; 621 //ResultsDetectionAccuracy = accuracySum / evaluationCount; 622 623 624 609 625 610 626 //if (accCount / replCount > 1.0) { … … 621 637 //} 622 638 623 lastStateValue = curStateValue;639 //lastStateValue = curStateValue; 624 640 625 641 // detection of state change … … 650 666 private bool accDiscount = false; 651 667 652 private double CalulateEnsembleConfidenceCM1( RatedEnsembleModel ensemble, IEnumerable<double[]> estimatedValuesPerModelPerRow, IEnumerable<double> realValues) {668 private double CalulateEnsembleConfidenceCM1(ProxyEnsembleModel ensemble, IEnumerable<double[]> estimatedValuesPerModelPerRow, IEnumerable<double> realValues) { 653 669 int noModels = estimatedValuesPerModelPerRow.Count(); 654 670 int votes = 0; … … 717 733 718 734 protected virtual void RegisterEnsembleEvents() { 719 ensembles.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);720 ensembles.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);721 ensembles.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);722 ensembles.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);723 ensembles.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_Reset);735 ensembles.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 736 ensembles.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 737 ensembles.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 738 ensembles.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 739 ensembles.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_Reset); 724 740 } 725 741 726 742 protected virtual void DeregisterEnsembleEvents() { 727 ensembles.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);728 ensembles.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);729 ensembles.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);730 ensembles.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_ItemsChanged);731 ensembles.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem< RatedEnsembleModel>>(Ensembles_Reset);743 ensembles.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 744 ensembles.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 745 ensembles.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 746 ensembles.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_ItemsChanged); 747 ensembles.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<ProxyEnsembleModel>>(Ensembles_Reset); 732 748 } 733 749 #endregion -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/HeuristicLab.DatastreamAnalysis.csproj
r14710 r15867 18 18 <DebugType>full</DebugType> 19 19 <Optimize>false</Optimize> 20 <OutputPath>..\..\..\..\trunk\ sources\bin\</OutputPath>20 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 21 21 <DefineConstants>DEBUG;TRACE</DefineConstants> 22 22 <ErrorReport>prompt</ErrorReport> … … 110 110 <Compile Include="IAnalysisBase.cs" /> 111 111 <Compile Include="IDatastream.cs" /> 112 <Compile Include="I RatedEnsembleModel.cs" />112 <Compile Include="IProxyEnsembleModel.cs" /> 113 113 <Compile Include="Plugin.cs" /> 114 114 <Compile Include="Properties\AssemblyInfo.cs" /> 115 <Compile Include=" RatedEnsembleModel.cs" />115 <Compile Include="ProxyEnsembleModel.cs" /> 116 116 </ItemGroup> 117 117 <ItemGroup> -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/HeuristicLab.DatastreamAnalysis.csproj.user
r14536 r15867 3 3 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> 4 4 <StartAction>Program</StartAction> 5 <StartProgram>C:\dev\workspaces\hl-core\trunk\ sources\bin\HeuristicLab 3.3.exe</StartProgram>6 <StartArguments>/ hidestarter /start:Optimizer</StartArguments>5 <StartProgram>C:\dev\workspaces\hl-core\trunk\bin\HeuristicLab 3.3.exe</StartProgram> 6 <StartArguments>/start:Optimizer /hideStarter</StartArguments> 7 7 </PropertyGroup> 8 8 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Plugin.cs
r15025 r15867 23 23 24 24 namespace HeuristicLab.DatastreamAnalysis { 25 [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.1 4710")]25 [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.15025")] 26 26 [PluginFile("HeuristicLab.DatastreamAnalysis-3.4.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Properties/AssemblyInfo.cs
r15025 r15867 54 54 // [assembly: AssemblyVersion("1.0.*")] 55 55 [assembly: AssemblyVersion("3.4.0.0")] 56 [assembly: AssemblyFileVersion("3.4.14.1 4710")]56 [assembly: AssemblyFileVersion("3.4.14.15025")]
Note: See TracChangeset
for help on using the changeset viewer.