Changeset 14543
- Timestamp:
- 01/04/17 18:38:52 (8 years ago)
- Location:
- branches/HeuristicLab.DatastreamAnalysis
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Plugin.cs
r14538 r14543 23 23 24 24 namespace HeuristicLab.DatastreamAnalysis.Views { 25 [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.1453 6")]25 [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.14538")] 26 26 [PluginFile("HeuristicLab.DatastreamAnalysis.Views-3.4.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Properties/AssemblyInfo.cs
r14538 r14543 54 54 // [assembly: AssemblyVersion("1.0.*")] 55 55 [assembly: AssemblyVersion("3.4.0.0")] 56 [assembly: AssemblyFileVersion("3.4.14.1453 6")]56 [assembly: AssemblyFileVersion("3.4.14.14538")] -
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Datastream.cs
r14538 r14543 181 181 public Datastream() : base() { 182 182 Parameters.Add(new ValueParameter<RegressionProblemData>(ProblemDataParameterName, "ProblemData for analysis with selected ensembles.", null)); 183 Parameters.Add(new FixedValueParameter<IntRange>(InitialSlidingWindowParameterName, "Initial sliding window boundaries", new IntRange(0, 5)));184 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "Sliding window size", new IntValue( 5)));183 Parameters.Add(new FixedValueParameter<IntRange>(InitialSlidingWindowParameterName, "Initial sliding window boundaries", new IntRange(0, 20))); 184 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "Sliding window size", new IntValue(20))); 185 185 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowStepWidthParameterName, "Sliding window step width", new IntValue(1))); 186 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowMovementIntervalParameterName, "Sliding window movement interval (milliseconds)", new IntValue( 2000)));186 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowMovementIntervalParameterName, "Sliding window movement interval (milliseconds)", new IntValue(500))); 187 187 RegisterParameterEvents(); 188 188 InitializeState(); -
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/DatastreamAnalysisOptimizer.cs
r14538 r14543 144 144 set { ((IntValue)Results["Sliding Window Movements"].Value).Value = value; } 145 145 } 146 private double ResultsBestQuality {147 get { return ((DoubleValue)Results["Best Quality"].Value).Value; }148 set { ((DoubleValue)Results["Best Quality"].Value).Value = value; }149 }150 146 private DataTable ResultsQualities { 151 147 get { return ((DataTable)Results["Qualities"].Value); } 152 148 } 153 149 154 private const string ResultsQualities R2 = "R²";155 private const string ResultsQualitiesP earson = "Pearson";150 private const string ResultsQualitiesMSE = "Mean squared error"; 151 private const string ResultsQualitiesPR2 = "Pearson R²"; 156 152 157 153 private DataTable ResultsTargets { … … 161 157 private const string ResultsTargetsReal = "Real"; 162 158 159 private DataTable ResultsQualitiesBars { 160 get { return ((DataTable) Results["Ensembles"].Value); } 161 } 162 163 163 protected void SetupResults() { 164 164 Results.Clear(); 165 165 166 166 Results.Add(new Result("Sliding Window Movements", new IntValue(0))); 167 Results.Add(new Result("Best Quality", new DoubleValue(0)));168 167 Results.Add(new Result("Qualities", new DataTable("Qualities"))); 169 168 Results.Add(new Result("Targets", new DataTable("Targets"))); 170 169 171 ResultsQualities .Rows.Add(new DataRow(ResultsQualitiesR2));172 ResultsQualities.Rows.Add(new DataRow(ResultsQualitiesPearson)); 170 ResultsQualitiesBars.Rows.Add(new DataRow("Ensembles")); 171 173 172 ResultsTargets.Rows.Add(new DataRow(ResultsTargetsReal)); 174 173 foreach (var ensemble in Ensembles) { 174 // targets table 175 175 ResultsTargets.Rows.Add(new DataRow(ensemble.Name)); 176 177 // qualities (series) 178 //ResultsQualities.Rows.Add(new DataRow(ensemble.Name + " - " + ResultsQualitiesMSE)); 179 ResultsQualities.Rows.Add(new DataRow(ensemble.Name + " - " + ResultsQualitiesPR2)); 180 181 // qualities (bars) 182 //ResultsQualitiesBars.Rows.Add(new DataRow(ensemble.Name + " - " + ResultsQualitiesPR2)); 183 //ResultsQualitiesBars.Rows["Ensembles"].Values. 176 184 } 177 185 } … … 180 188 181 189 #region constructors, cloner,... 182 183 190 public DatastreamAnalysisOptimizer() : base() { 184 191 name = "Datastream Analysis"; … … 248 255 if (prepared) { 249 256 SetupResults(); 250 //prepared = false;257 Datastream.InitializeState(); 251 258 } 252 259 … … 273 280 OnPaused(); 274 281 } 275 //if(!Datastream.SlidingWindowMovementPossible) OnStopped();276 //else OnPaused();277 282 }); 278 279 283 } 280 284 … … 361 365 362 366 protected void Run(CancellationToken cancellationToken) { 363 // init algorithm364 var problemData = Datastream.ProblemData;365 var targetVarName = problemData.TargetVariable;366 var activeVariables = problemData.AllowedInputVariables;367 367 368 368 if (prepared) { 369 // replay datastream until FitnessPartition.End370 //for (int i = 0; i < Datastream.FitnessPartition.End; i++) {371 // var val = problemData.Dataset.GetDoubleValue(targetVarName, i);372 // ResultsTargets.Rows[ResultsTargetsReal].Values.Add(val);373 //}374 //replayedIndex = Datastream.FitnessPartition.End;375 369 replayedIndex = 0; 376 370 prepared = false; 377 371 } 378 372 379 380 Random rnd = new Random();381 382 373 try { 374 375 // play and evaluate initial window 376 PlayDatastream(); 377 if(Datastream.SlidingWindowEvaluationPossible) Evaluate(); 378 replayedIndex = Datastream.FitnessPartition.End; 379 383 380 do { 384 do{381 while(Datastream.SlidingWindowMovementPossible) { 385 382 cancellationToken.ThrowIfCancellationRequested(); 386 383 384 // perform (delayed) window movement 387 385 Thread.Sleep(Datastream.SlidingWindowMovementInterval.Value); 388 386 Datastream.MoveSlidingWindow(); 389 390 if (Datastream.SlidingWindowEvaluationPossible) { 391 foreach (var ensemble in Ensembles) { 392 // TODO do the window evaluation 393 double estimatedVal = problemData.Dataset.GetDoubleValue(targetVarName, replayedIndex) 394 * (1.0 + (((double)rnd.Next(0, 30)) / 100)); 395 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 396 ResultsTargets.Rows[ensemble.Name].Values.Add(estimatedVal); 397 } 398 } 399 } 400 401 // replay datastream until FitnessPartition.End 402 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 403 var val = problemData.Dataset.GetDoubleValue(targetVarName, i); 404 ResultsTargets.Rows[ResultsTargetsReal].Values.Add(val); 405 } 387 ResultsSlidingWindowMovements++; 388 389 // play and evaluate the moved window 390 PlayDatastream(); 391 if (Datastream.SlidingWindowEvaluationPossible) Evaluate(); 406 392 replayedIndex = Datastream.FitnessPartition.End; 407 408 409 // TODO: collect results and display them 410 411 int exp = rnd.Next(100); 412 ResultsQualities.Rows[ResultsQualitiesR2].Values.Add(exp); 413 ResultsQualities.Rows[ResultsQualitiesPearson].Values.Add((double)exp / 10); 414 ResultsSlidingWindowMovements++; 415 ResultsBestQuality = (double)exp / 42; 416 417 } while (Datastream.SlidingWindowMovementPossible); 393 } 418 394 } while (Datastream.UpdateAvailable); 419 395 finished = true; … … 426 402 // reset everything 427 403 //Prepare(true); 404 } 405 } 406 407 private void PlayDatastream() { 408 var problemData = Datastream.ProblemData; 409 var targetVarName = problemData.TargetVariable; 410 411 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 412 var realValue = problemData.Dataset.GetDoubleValue(targetVarName, i); 413 ResultsTargets.Rows[ResultsTargetsReal].Values.Add(realValue); 414 } 415 } 416 417 private void Evaluate() { 418 var problemData = Datastream.ProblemData; 419 var dataset = problemData.Dataset; 420 var targetVarName = problemData.TargetVariable; 421 422 var realRows = Enumerable.Range(Datastream.FitnessPartition.Start, Datastream.FitnessPartition.Size).ToList(); 423 var realValues = dataset.GetDoubleValues(targetVarName, realRows); 424 425 foreach (var ensemble in Ensembles) { 426 427 var rows = Enumerable.Range(Datastream.FitnessPartition.Start, Datastream.FitnessPartition.Size); 428 var estimatedValuesPerModelPerRow = ensemble.Models.Select(x => x.GetEstimatedValues(datastream.ProblemData.Dataset, rows).ToArray()); 429 var estimatedValues = Enumerable.Range(0, Datastream.FitnessPartition.Size).Select(r => estimatedValuesPerModelPerRow.Select(e => e[r]).Average()).ToArray(); // per row 430 var averageEstimatedValuesPerModel = estimatedValuesPerModelPerRow.Select(x => x.Average()); // per model 431 var averageEstimatedValue = averageEstimatedValuesPerModel.Average(); 432 433 // determine quality 434 var mse = Math.Pow(averageEstimatedValue - realValues.Average(), 2); 435 OnlineCalculatorError error; 436 var pR = OnlinePearsonsRCalculator.Calculate(estimatedValues, realValues, out error); 437 var pR2 = error == OnlineCalculatorError.None ? pR * pR : 0.0; 438 439 DataRow qualitiesBarsRow = ResultsQualitiesBars.Rows[ensemble.Name + " - " + ResultsQualitiesPR2]; 440 441 for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) { 442 ResultsTargets.Rows[ensemble.Name].Values.Add(averageEstimatedValue); 443 444 //ResultsQualities.Rows[ensemble.Name + " - " + ResultsQualitiesMSE].Values.Add(mse); 445 ResultsQualities.Rows[ensemble.Name + " - " + ResultsQualitiesPR2].Values.Add(pR2); 446 } 428 447 } 429 448 } -
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Plugin.cs
r14538 r14543 23 23 24 24 namespace HeuristicLab.DatastreamAnalysis { 25 [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.1453 6")]25 [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.14538")] 26 26 [PluginFile("HeuristicLab.DatastreamAnalysis-3.4.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Properties/AssemblyInfo.cs
r14538 r14543 54 54 // [assembly: AssemblyVersion("1.0.*")] 55 55 [assembly: AssemblyVersion("3.4.0.0")] 56 [assembly: AssemblyFileVersion("3.4.14.1453 6")]56 [assembly: AssemblyFileVersion("3.4.14.14538")]
Note: See TracChangeset
for help on using the changeset viewer.