Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.DataAnalysis

  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineCrossValidationEvaluator.cs

    r4543 r4722  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.Data;
     
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032using SVM;
    31 using System.Collections.Generic;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis.SupportVectorMachine {
     
    126127    #endregion
    127128
     129    [StorableConstructor]
     130    protected SupportVectorMachineCrossValidationEvaluator(bool deserializing) : base(deserializing) { }
     131
     132    protected SupportVectorMachineCrossValidationEvaluator(SupportVectorMachineCrossValidationEvaluator original,
     133      Cloner cloner)
     134      : base(original, cloner) { }
    128135    public SupportVectorMachineCrossValidationEvaluator()
    129136      : base() {
     
    143150    }
    144151
     152    public override IDeepCloneable Clone(Cloner cloner) {
     153      return new SupportVectorMachineCrossValidationEvaluator(this, cloner);
     154    }
     155
    145156    public override IOperation Apply() {
    146157      double reductionRatio = 1.0; // TODO: make parameter
    147158      if (ActualSamplesParameter.ActualValue != null)
    148159        reductionRatio = ActualSamplesParameter.ActualValue.Value;
    149       IEnumerable<int> rows = 
     160      IEnumerable<int> rows =
    150161        Enumerable.Range(SamplesStart.Value, SamplesEnd.Value - SamplesStart.Value)
    151162        .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i);
     
    153164      // create a new DataAnalysisProblemData instance
    154165      DataAnalysisProblemData reducedProblemData = (DataAnalysisProblemData)DataAnalysisProblemData.Clone();
    155       reducedProblemData.Dataset = 
     166      reducedProblemData.Dataset =
    156167        CreateReducedDataset(RandomParameter.ActualValue, reducedProblemData.Dataset, rows, reductionRatio);
    157168      reducedProblemData.TrainingSamplesStart.Value = 0;
     
    170181
    171182    private Dataset CreateReducedDataset(IRandom random, Dataset dataset, IEnumerable<int> rowIndices, double reductionRatio) {
    172      
     183
    173184      // must not make a fink:
    174185      // => select n rows randomly from start..end
     
    191202      // take the first n indexes (selected n rowIndexes from start..end)
    192203      // now order by index
    193       int[] orderedRandomIndexes = 
     204      int[] orderedRandomIndexes =
    194205        rowIndexArr.Take(n)
    195206        .OrderBy(x => x)
Note: See TracChangeset for help on using the changeset viewer.