Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14864 for trunk


Ignore:
Timestamp:
04/13/17 15:16:43 (7 years ago)
Author:
bburlacu
Message:

#2760: Implement shuffling of crossvalidation samples.

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/CrossValidationView.Designer.cs

    r14185 r14864  
    4646    /// </summary>
    4747    private void InitializeComponent() {
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CrossValidationView));
    4849      this.startButton = new System.Windows.Forms.Button();
    4950      this.pauseButton = new System.Windows.Forms.Button();
     
    7980      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    8081      this.splitContainer = new System.Windows.Forms.SplitContainer();
     82      this.shuffleSamplesCheckBox = new System.Windows.Forms.CheckBox();
    8183      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    8284      ((System.ComponentModel.ISupportInitialize)(this.foldsNumericUpDown)).BeginInit();
     
    109111      //
    110112      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    111       this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
     113      this.startButton.Image = ((System.Drawing.Image)(resources.GetObject("startButton.Image")));
    112114      this.startButton.Location = new System.Drawing.Point(0, 514);
    113115      this.startButton.Name = "startButton";
     
    120122      //
    121123      this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    122       this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause;
     124      this.pauseButton.Image = ((System.Drawing.Image)(resources.GetObject("pauseButton.Image")));
    123125      this.pauseButton.Location = new System.Drawing.Point(30, 514);
    124126      this.pauseButton.Name = "pauseButton";
     
    131133      //
    132134      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    133       this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop;
     135      this.stopButton.Image = ((System.Drawing.Image)(resources.GetObject("stopButton.Image")));
    134136      this.stopButton.Location = new System.Drawing.Point(60, 514);
    135137      this.stopButton.Name = "stopButton";
     
    142144      //
    143145      this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    144       this.resetButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Restart;
     146      this.resetButton.Image = ((System.Drawing.Image)(resources.GetObject("resetButton.Image")));
    145147      this.resetButton.Location = new System.Drawing.Point(90, 514);
    146148      this.resetButton.Name = "resetButton";
     
    171173      // foldsNumericUpDown
    172174      //
    173       this.foldsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    174                   | System.Windows.Forms.AnchorStyles.Right)));
     175      this.foldsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     176            | System.Windows.Forms.AnchorStyles.Right)));
    175177      this.foldsNumericUpDown.Location = new System.Drawing.Point(55, 26);
    176178      this.foldsNumericUpDown.Maximum = new decimal(new int[] {
     
    185187            0});
    186188      this.foldsNumericUpDown.Name = "foldsNumericUpDown";
    187       this.foldsNumericUpDown.Size = new System.Drawing.Size(248, 20);
     189      this.foldsNumericUpDown.Size = new System.Drawing.Size(154, 20);
    188190      this.foldsNumericUpDown.TabIndex = 3;
    189191      this.foldsNumericUpDown.ThousandsSeparator = true;
     
    207209      // workersNumericUpDown
    208210      //
    209       this.workersNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    210                   | System.Windows.Forms.AnchorStyles.Right)));
     211      this.workersNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     212            | System.Windows.Forms.AnchorStyles.Right)));
    211213      this.workersNumericUpDown.Location = new System.Drawing.Point(55, 0);
    212214      this.workersNumericUpDown.Maximum = new decimal(new int[] {
     
    261263      // samplesEndStringConvertibleValueView
    262264      //
    263       this.samplesEndStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    264                   | System.Windows.Forms.AnchorStyles.Right)));
     265      this.samplesEndStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     266            | System.Windows.Forms.AnchorStyles.Right)));
    265267      this.samplesEndStringConvertibleValueView.Caption = "StringConvertibleValue View";
    266268      this.samplesEndStringConvertibleValueView.Content = null;
     
    274276      // samplesStartStringConvertibleValueView
    275277      //
    276       this.samplesStartStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    277                   | System.Windows.Forms.AnchorStyles.Right)));
     278      this.samplesStartStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     279            | System.Windows.Forms.AnchorStyles.Right)));
    278280      this.samplesStartStringConvertibleValueView.Caption = "StringConvertibleValue View";
    279281      this.samplesStartStringConvertibleValueView.Content = null;
     
    288290      //
    289291      this.tabControl.AllowDrop = true;
    290       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    291                   | System.Windows.Forms.AnchorStyles.Left)
    292                   | System.Windows.Forms.AnchorStyles.Right)));
     292      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     293            | System.Windows.Forms.AnchorStyles.Left)
     294            | System.Windows.Forms.AnchorStyles.Right)));
    293295      this.tabControl.Controls.Add(this.algorithmTabPage);
    294296      this.tabControl.Controls.Add(this.resultsTabPage);
    295297      this.tabControl.Controls.Add(this.runsTabPage);
    296       this.tabControl.Location = new System.Drawing.Point(0, 87);
     298      this.tabControl.Location = new System.Drawing.Point(0, 115);
    297299      this.tabControl.Name = "tabControl";
    298300      this.tabControl.SelectedIndex = 0;
    299       this.tabControl.Size = new System.Drawing.Size(616, 421);
     301      this.tabControl.Size = new System.Drawing.Size(616, 393);
    300302      this.tabControl.TabIndex = 4;
    301303      //
     
    310312      this.algorithmTabPage.Name = "algorithmTabPage";
    311313      this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);
    312       this.algorithmTabPage.Size = new System.Drawing.Size(608, 395);
     314      this.algorithmTabPage.Size = new System.Drawing.Size(608, 367);
    313315      this.algorithmTabPage.TabIndex = 0;
    314316      this.algorithmTabPage.Text = "Algorithm";
     
    320322      // algorithmNamedItemView
    321323      //
    322       this.algorithmNamedItemView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    323                   | System.Windows.Forms.AnchorStyles.Right)));
     324      this.algorithmNamedItemView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     325            | System.Windows.Forms.AnchorStyles.Right)));
    324326      this.algorithmNamedItemView.Caption = "NamedItem View";
    325327      this.algorithmNamedItemView.Content = null;
     
    333335      //
    334336      this.algorithmTabControl.AllowDrop = true;
    335       this.algorithmTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    336                   | System.Windows.Forms.AnchorStyles.Left)
    337                   | System.Windows.Forms.AnchorStyles.Right)));
     337      this.algorithmTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     338            | System.Windows.Forms.AnchorStyles.Left)
     339            | System.Windows.Forms.AnchorStyles.Right)));
    338340      this.algorithmTabControl.Controls.Add(this.algorithmProblemTabPage);
    339341      this.algorithmTabControl.Controls.Add(this.algorithmParametersTabPage);
     
    341343      this.algorithmTabControl.Name = "algorithmTabControl";
    342344      this.algorithmTabControl.SelectedIndex = 0;
    343       this.algorithmTabControl.Size = new System.Drawing.Size(594, 324);
     345      this.algorithmTabControl.Size = new System.Drawing.Size(594, 296);
    344346      this.algorithmTabControl.TabIndex = 3;
    345347      //
     
    353355      this.algorithmProblemTabPage.Name = "algorithmProblemTabPage";
    354356      this.algorithmProblemTabPage.Padding = new System.Windows.Forms.Padding(3);
    355       this.algorithmProblemTabPage.Size = new System.Drawing.Size(586, 298);
     357      this.algorithmProblemTabPage.Size = new System.Drawing.Size(586, 270);
    356358      this.algorithmProblemTabPage.TabIndex = 0;
    357359      this.algorithmProblemTabPage.Text = "Problem";
     
    363365      // openProblemButton
    364366      //
    365       this.openProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     367      this.openProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("openProblemButton.Image")));
    366368      this.openProblemButton.Location = new System.Drawing.Point(36, 6);
    367369      this.openProblemButton.Name = "openProblemButton";
     
    374376      // algorithmProblemViewHost
    375377      //
    376       this.algorithmProblemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    377                   | System.Windows.Forms.AnchorStyles.Left)
    378                   | System.Windows.Forms.AnchorStyles.Right)));
     378      this.algorithmProblemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     379            | System.Windows.Forms.AnchorStyles.Left)
     380            | System.Windows.Forms.AnchorStyles.Right)));
    379381      this.algorithmProblemViewHost.Caption = "View";
    380382      this.algorithmProblemViewHost.Content = null;
     
    383385      this.algorithmProblemViewHost.Name = "algorithmProblemViewHost";
    384386      this.algorithmProblemViewHost.ReadOnly = false;
    385       this.algorithmProblemViewHost.Size = new System.Drawing.Size(574, 256);
     387      this.algorithmProblemViewHost.Size = new System.Drawing.Size(574, 228);
    386388      this.algorithmProblemViewHost.TabIndex = 2;
    387389      this.algorithmProblemViewHost.ViewsLabelVisible = true;
     
    390392      // newProblemButton
    391393      //
    392       this.newProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     394      this.newProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("newProblemButton.Image")));
    393395      this.newProblemButton.Location = new System.Drawing.Point(6, 6);
    394396      this.newProblemButton.Name = "newProblemButton";
     
    405407      this.algorithmParametersTabPage.Name = "algorithmParametersTabPage";
    406408      this.algorithmParametersTabPage.Padding = new System.Windows.Forms.Padding(3);
    407       this.algorithmParametersTabPage.Size = new System.Drawing.Size(586, 298);
     409      this.algorithmParametersTabPage.Size = new System.Drawing.Size(586, 270);
    408410      this.algorithmParametersTabPage.TabIndex = 1;
    409411      this.algorithmParametersTabPage.Text = "Parameters";
     
    412414      // algorithmParameterCollectionView
    413415      //
     416      this.algorithmParameterCollectionView.AllowEditingOfHiddenParameters = true;
    414417      this.algorithmParameterCollectionView.Caption = "ParameterCollection View";
    415418      this.algorithmParameterCollectionView.Content = null;
     
    418421      this.algorithmParameterCollectionView.Name = "algorithmParameterCollectionView";
    419422      this.algorithmParameterCollectionView.ReadOnly = false;
    420       this.algorithmParameterCollectionView.Size = new System.Drawing.Size(580, 292);
     423      this.algorithmParameterCollectionView.ShowDetails = true;
     424      this.algorithmParameterCollectionView.Size = new System.Drawing.Size(580, 264);
    421425      this.algorithmParameterCollectionView.TabIndex = 0;
    422426      //
    423427      // openAlgorithmButton
    424428      //
    425       this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     429      this.openAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("openAlgorithmButton.Image")));
    426430      this.openAlgorithmButton.Location = new System.Drawing.Point(38, 6);
    427431      this.openAlgorithmButton.Name = "openAlgorithmButton";
     
    434438      // newAlgorithmButton
    435439      //
    436       this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     440      this.newAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("newAlgorithmButton.Image")));
    437441      this.newAlgorithmButton.Location = new System.Drawing.Point(8, 6);
    438442      this.newAlgorithmButton.Name = "newAlgorithmButton";
     
    449453      this.resultsTabPage.Name = "resultsTabPage";
    450454      this.resultsTabPage.Padding = new System.Windows.Forms.Padding(3);
    451       this.resultsTabPage.Size = new System.Drawing.Size(608, 395);
     455      this.resultsTabPage.Size = new System.Drawing.Size(608, 367);
    452456      this.resultsTabPage.TabIndex = 1;
    453457      this.resultsTabPage.Text = "Results";
     
    462466      this.resultCollectionView.Name = "resultCollectionView";
    463467      this.resultCollectionView.ReadOnly = true;
    464       this.resultCollectionView.Size = new System.Drawing.Size(602, 389);
     468      this.resultCollectionView.ShowDetails = true;
     469      this.resultCollectionView.Size = new System.Drawing.Size(602, 361);
    465470      this.resultCollectionView.TabIndex = 0;
    466471      //
     
    472477      this.runsTabPage.Name = "runsTabPage";
    473478      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
    474       this.runsTabPage.Size = new System.Drawing.Size(608, 395);
     479      this.runsTabPage.Size = new System.Drawing.Size(608, 367);
    475480      this.runsTabPage.TabIndex = 2;
    476481      this.runsTabPage.Text = "Runs";
     
    501506      this.runCollectionView.Name = "runCollectionView";
    502507      this.runCollectionView.ReadOnly = false;
    503       this.runCollectionView.Size = new System.Drawing.Size(602, 389);
     508      this.runCollectionView.Size = new System.Drawing.Size(602, 361);
    504509      this.runCollectionView.TabIndex = 0;
    505510      //
     
    513518      // splitContainer
    514519      //
    515       this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    516                   | System.Windows.Forms.AnchorStyles.Right)));
     520      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     521            | System.Windows.Forms.AnchorStyles.Right)));
    517522      this.splitContainer.Location = new System.Drawing.Point(0, 26);
    518523      this.splitContainer.Name = "splitContainer";
     
    520525      // splitContainer.Panel1
    521526      //
     527      this.splitContainer.Panel1.Controls.Add(this.shuffleSamplesCheckBox);
    522528      this.splitContainer.Panel1.Controls.Add(this.samplesEndStringConvertibleValueView);
    523529      this.splitContainer.Panel1.Controls.Add(this.samplesStartStringConvertibleValueView);
     
    531537      this.splitContainer.Panel2.Controls.Add(this.workersLabel);
    532538      this.splitContainer.Panel2.Controls.Add(this.workersNumericUpDown);
    533       this.splitContainer.Size = new System.Drawing.Size(616, 55);
     539      this.splitContainer.Size = new System.Drawing.Size(616, 73);
    534540      this.splitContainer.SplitterDistance = 306;
    535541      this.splitContainer.TabIndex = 3;
    536542      //
     543      // shuffleSamplesCheckBox
     544      //
     545      this.shuffleSamplesCheckBox.AutoSize = true;
     546      this.shuffleSamplesCheckBox.Location = new System.Drawing.Point(6, 52);
     547      this.shuffleSamplesCheckBox.Name = "shuffleSamplesCheckBox";
     548      this.shuffleSamplesCheckBox.Size = new System.Drawing.Size(102, 17);
     549      this.shuffleSamplesCheckBox.TabIndex = 5;
     550      this.shuffleSamplesCheckBox.Text = "Shuffle Samples";
     551      this.shuffleSamplesCheckBox.UseVisualStyleBackColor = true;
     552      this.shuffleSamplesCheckBox.CheckedChanged += new System.EventHandler(this.shuffleSamplesCheckBox_CheckedChanged);
     553      //
    537554      // CrossValidationView
    538555      //
    539       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    540556      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    541557      this.Controls.Add(this.tabControl);
     
    617633    private System.Windows.Forms.SplitContainer splitContainer;
    618634    private Optimization.Views.ResultCollectionView resultCollectionView;
     635    private System.Windows.Forms.CheckBox shuffleSamplesCheckBox;
    619636  }
    620637}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/CrossValidationView.cs

    r14185 r14864  
    197197
    198198    #region GUI events
     199    private void shuffleSamplesCheckBox_CheckedChanged(object sender, EventArgs e) {
     200      Content.ShuffleSamples.Value = shuffleSamplesCheckBox.Checked;
     201    }
    199202    private void foldsNumericUpDown_Validated(object sender, EventArgs e) {
    200203      if (foldsNumericUpDown.Text == string.Empty)
     
    238241        try {
    239242          Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    240         }
    241         catch (Exception ex) {
     243        } catch (Exception ex) {
    242244          ErrorHandling.ShowErrorDialog(this, ex);
    243245        }
     
    250252        algorithmTabControl.Enabled = false;
    251253
    252         ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
     254        ContentManager.LoadAsync(openFileDialog.FileName, delegate (IStorableContent content, Exception error) {
    253255          try {
    254256            if (error != null) throw error;
     
    258260            else
    259261              Content.Algorithm = algorithm;
    260           }
    261           catch (Exception ex) {
     262          } catch (Exception ex) {
    262263            ErrorHandling.ShowErrorDialog(this, ex);
    263           }
    264           finally {
    265             Invoke(new Action(delegate() {
     264          } finally {
     265            Invoke(new Action(delegate () {
    266266              algorithmTabControl.Enabled = true;
    267267            }));
     
    289289        algorithmProblemViewHost.Enabled = false;
    290290
    291         ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
     291        ContentManager.LoadAsync(openFileDialog.FileName, delegate (IStorableContent content, Exception error) {
    292292          try {
    293293            if (error != null) throw error;
     
    298298            else
    299299              Content.Problem = problem;
    300           }
    301           catch (Exception ex) {
     300          } catch (Exception ex) {
    302301            Invoke(new Action(() => ErrorHandling.ShowErrorDialog(this, ex)));
    303           }
    304           finally {
    305             Invoke(new Action(delegate() {
     302          } finally {
     303            Invoke(new Action(delegate () {
    306304              algorithmProblemViewHost.Enabled = true;
    307305              newProblemButton.Enabled = openProblemButton.Enabled = true;
     
    357355    }
    358356    #endregion
    359 
    360357  }
    361358}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r14781 r14864  
    3333using HeuristicLab.Problems.DataAnalysis;
    3434using HeuristicLab.Problems.DataAnalysis.Symbolic;
     35using HeuristicLab.Random;
    3536
    3637namespace HeuristicLab.Algorithms.DataAnalysis {
     
    5657      samplesStart = new IntValue(0);
    5758      samplesEnd = new IntValue(0);
     59      shuffleSamples = new BoolValue(false);
    5860      storeAlgorithmInEachRun = false;
    5961
     
    8991      samplesStart = cloner.Clone(original.samplesStart);
    9092      samplesEnd = cloner.Clone(original.samplesEnd);
     93      shuffleSamples = cloner.Clone(original.shuffleSamples);
    9194      RegisterEvents();
    9295      if (Algorithm != null) RegisterAlgorithmEvents();
     
    170173      get { return results; }
    171174    }
    172 
     175    [Storable]
     176    private BoolValue shuffleSamples;
     177    public BoolValue ShuffleSamples {
     178      get { return shuffleSamples; }
     179    }
    173180    [Storable]
    174181    private IntValue folds;
     
    274281        if (clonedAlgorithms.Count == 0) {
    275282          int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / Folds.Value;
    276 
     283          IDataset shuffledDataset = null;
    277284          for (int i = 0; i < Folds.Value; i++) {
    278             IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone();
     285            var cloner = new Cloner();
     286            if (ShuffleSamples.Value) {
     287              var dataAnalysisProblem = (IDataAnalysisProblem)algorithm.Problem;
     288              var dataset = (Dataset)dataAnalysisProblem.ProblemData.Dataset;
     289              shuffledDataset = shuffledDataset ?? dataset.Shuffle(new FastRandom());
     290              cloner.RegisterClonedObject(dataset, shuffledDataset);
     291            }
     292            IAlgorithm clonedAlgorithm = cloner.Clone(Algorithm);
    279293            clonedAlgorithm.Name = algorithm.Name + " Fold " + i;
    280294            IDataAnalysisProblem problem = clonedAlgorithm.Problem as IDataAnalysisProblem;
     
    590604    private void Algorithm_ExecutionStateChanged(object sender, EventArgs e) {
    591605      switch (Algorithm.ExecutionState) {
    592         case ExecutionState.Prepared: OnPrepared();
     606        case ExecutionState.Prepared:
     607          OnPrepared();
    593608          break;
    594609        case ExecutionState.Started: throw new InvalidOperationException("Algorithm template can not be started.");
    595610        case ExecutionState.Paused: throw new InvalidOperationException("Algorithm template can not be paused.");
    596         case ExecutionState.Stopped: OnStopped();
     611        case ExecutionState.Stopped:
     612          OnStopped();
    597613          break;
    598614      }
     
    724740      AggregateResultValues(collectedResults);
    725741      results.AddRange(collectedResults.Select(x => new Result(x.Key, x.Value)).Cast<IResult>().ToArray());
     742      clonedAlgorithms.Clear();
    726743      runsCounter++;
    727744      runs.Add(new Run(string.Format("{0} Run {1}", Name, runsCounter), this));
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r14857 r14864  
    126126      return new ModifiableDataset(variableNames, values);
    127127    }
     128    /// <summary>
     129    /// Shuffle a dataset's rows
     130    /// </summary>
     131    /// <param name="random">Random number generator used for shuffling.</param>
     132    /// <returns>A shuffled copy of the current dataset.</returns>
     133    public Dataset Shuffle(IRandom random) {
     134      var values = variableNames.Select(x => variableValues[x]).ToList();
     135      return new Dataset(variableNames, values.ShuffleLists(random));
     136    }
    128137
    129138    protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { }
Note: See TracChangeset for help on using the changeset viewer.