Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6604


Ignore:
Timestamp:
07/27/11 16:30:49 (13 years ago)
Author:
mkommend
Message:

#1600: Added possibility to create classification solutions from classification models.

Location:
trunk/sources
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitModel.cs

    r6576 r6604  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.IO;
    2524using System.Linq;
    26 using System.Text;
    2725using HeuristicLab.Common;
    2826using HeuristicLab.Core;
    2927using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3028using HeuristicLab.Problems.DataAnalysis;
    31 using SVM;
    3229
    3330namespace HeuristicLab.Algorithms.DataAnalysis {
     
    111108    }
    112109
     110    public MultinomialLogitClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     111      return new MultinomialLogitClassificationSolution(problemData, this);
     112    }
     113    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     114      return CreateClassificationSolution(problemData);
     115    }
     116
    113117    #region events
    114118    public event EventHandler Changed;
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs

    r6603 r6604  
    183183      return CreateRegressionSolution(problemData);
    184184    }
     185    public INearestNeighbourClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     186      return new NearestNeighbourClassificationSolution(problemData, this);
     187    }
     188    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     189      return CreateClassificationSolution(problemData);
     190    }
    185191
    186192    #region events
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs

    r6603 r6604  
    150150      return CreateRegressionSolution(problemData);
    151151    }
     152    public INeuralNetworkEnsembleClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     153      return new NeuralNetworkEnsembleClassificationSolution(problemData, this);
     154    }
     155    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     156      return CreateClassificationSolution(problemData);
     157    }
    152158
    153159    #region events
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs

    r6603 r6604  
    143143      return CreateRegressionSolution(problemData);
    144144    }
     145    public INeuralNetworkClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     146      return new NeuralNetworkClassificationSolution(problemData, this);
     147    }
     148    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     149      return CreateClassificationSolution(problemData);
     150    }
    145151
    146152    #region events
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs

    r6603 r6604  
    137137      return CreateRegressionSolution(problemData);
    138138    }
     139    public IRandomForestClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     140      return new RandomForestClassificationSolution(problemData, this);
     141    }
     142    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     143      return CreateClassificationSolution(problemData);
     144    }
    139145
    140146    #region events
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs

    r6603 r6604  
    154154      }
    155155    }
     156
     157    public SupportVectorClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     158      return new SupportVectorClassificationSolution(this, problemData);
     159    }
     160    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     161      return CreateClassificationSolution(problemData);
     162    }
    156163    #endregion
    157164    // cache for predictions, which is cloned but not persisted, must be cleared when the model is changed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationModel.cs

    r5809 r6604  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2725using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    29 using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    32 using System;
    3327
    3428namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    5549      return Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows);
    5650    }
     51
     52    public ISymbolicClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     53      return new SymbolicClassificationSolution(this, problemData);
     54    }
     55    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     56      return CreateClassificationSolution(problemData);
     57    }
     58
     59
    5760  }
    5861}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs

    r6234 r6604  
    104104    }
    105105
     106    public SymbolicDiscriminantFunctionClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     107      return new SymbolicDiscriminantFunctionClassificationSolution(this, problemData);
     108    }
     109    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     110      return CreateClassificationSolution(problemData);
     111    }
     112    IDiscriminantFunctionClassificationSolution IDiscriminantFunctionClassificationModel.CreateDiscriminantFunctionClassificationSolution(IClassificationProblemData problemData) {
     113      return CreateClassificationSolution(problemData);
     114    }
     115
    106116    #region events
    107117    public event EventHandler ThresholdsChanged;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs

    r6520 r6604  
    8989    }
    9090
     91    IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     92      return new ClassificationEnsembleSolution(models, problemData);
     93    }
    9194    #endregion
    9295  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs

    r5809 r6604  
    3333  [StorableClass]
    3434  [Item("DiscriminantFunctionClassificationModel", "Represents a classification model that uses a discriminant function and classification thresholds.")]
    35   public class DiscriminantFunctionClassificationModel : NamedItem, IDiscriminantFunctionClassificationModel {
     35  public abstract class DiscriminantFunctionClassificationModel : NamedItem, IDiscriminantFunctionClassificationModel {
    3636    [Storable]
    3737    private IRegressionModel model;
     
    7070    }
    7171
    72     public override IDeepCloneable Clone(Cloner cloner) {
    73       return new DiscriminantFunctionClassificationModel(this, cloner);
    74     }
    75 
    7672    public void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues) {
    7773      var classValuesArr = classValues.ToArray();
     
    106102    }
    107103    #endregion
     104
     105    public abstract IDiscriminantFunctionClassificationSolution CreateDiscriminantFunctionClassificationSolution(IClassificationProblemData problemData);
     106    public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    108107  }
    109108}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r6589 r6604  
    3939      : base(original, cloner) {
    4040    }
    41     protected DiscriminantFunctionClassificationSolution(IRegressionModel model, IClassificationProblemData problemData)
    42       : this(new DiscriminantFunctionClassificationModel(model), problemData) {
    43     }
    4441    protected DiscriminantFunctionClassificationSolution(IDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData)
    4542      : base(model, problemData) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r6589 r6604  
    7878      : base(original, cloner) {
    7979      RegisterEventHandler();
    80     }
    81     protected DiscriminantFunctionClassificationSolutionBase(IRegressionModel model, IClassificationProblemData problemData)
    82       : this(new DiscriminantFunctionClassificationModel(model), problemData) {
    8380    }
    8481    protected DiscriminantFunctionClassificationSolutionBase(IDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData)
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs

    r5809 r6604  
    2424  public interface IClassificationModel : IDataAnalysisModel {
    2525    IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows);
     26    IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    2627  }
    2728}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationModel.cs

    r5809 r6604  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    23 using System;
    2424namespace HeuristicLab.Problems.DataAnalysis {
    2525  public interface IDiscriminantFunctionClassificationModel : IClassificationModel {
     
    2727    IEnumerable<double> ClassValues { get; }
    2828    // class values and thresholds can only be assigned simultaniously
    29     void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues); 
     29    void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues);
    3030    IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows);
    3131
    3232    event EventHandler ThresholdsChanged;
     33
     34    IDiscriminantFunctionClassificationSolution CreateDiscriminantFunctionClassificationSolution(IClassificationProblemData problemData);
    3335  }
    3436}
Note: See TracChangeset for help on using the changeset viewer.