Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (14 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelCreator.cs

    r4068 r5275  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
     25using HeuristicLab.Common;
    2326using HeuristicLab.Core;
    2427using HeuristicLab.Data;
     
    3437  [StorableClass]
    3538  [Item("SupportVectorMachineModelCreator", "Represents an operator that creates a support vector machine model.")]
    36   public class SupportVectorMachineModelCreator : SingleSuccessorOperator {
     39  public sealed class SupportVectorMachineModelCreator : SingleSuccessorOperator {
    3740    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
    3841    private const string SvmTypeParameterName = "SvmType";
     
    108111    #endregion
    109112
     113    [StorableConstructor]
     114    private SupportVectorMachineModelCreator(bool deserializing) : base(deserializing) { }
     115    private SupportVectorMachineModelCreator(SupportVectorMachineModelCreator original, Cloner cloner) : base(original, cloner) { }
     116    public override IDeepCloneable Clone(Cloner cloner) {
     117      return new SupportVectorMachineModelCreator(this, cloner);
     118    }
    110119    public SupportVectorMachineModelCreator()
    111120      : base() {
     
    125134
    126135    public override IOperation Apply() {
     136      int start = SamplesStart.Value;
     137      int end = SamplesEnd.Value;
     138      IEnumerable<int> rows =
     139        Enumerable.Range(start, end - start)
     140        .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i);
     141
    127142      SupportVectorMachineModel model = TrainModel(DataAnalysisProblemData,
    128                              SamplesStart.Value, SamplesEnd.Value,
     143                             rows,
    129144                             SvmType.Value, KernelType.Value,
    130145                             Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value);
     
    138153      string svmType, string kernelType,
    139154      double cost, double nu, double gamma, double epsilon) {
    140       return TrainModel(problemData, problemData.TrainingSamplesStart.Value, problemData.TrainingSamplesEnd.Value, svmType, kernelType, cost, nu, gamma, epsilon);
     155      return TrainModel(problemData, problemData.TrainingIndizes, svmType, kernelType, cost, nu, gamma, epsilon);
    141156    }
    142157
    143158    public static SupportVectorMachineModel TrainModel(
    144159      DataAnalysisProblemData problemData,
    145       int start, int end,
     160      IEnumerable<int> trainingIndizes,
    146161      string svmType, string kernelType,
    147162      double cost, double nu, double gamma, double epsilon) {
     
    160175
    161176
    162       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     177      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, trainingIndizes);
    163178      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
    164179      SVM.Problem scaledProblem = Scaling.Scale(rangeTransform, problem);
Note: See TracChangeset for help on using the changeset viewer.