Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/16 13:33:17 (8 years ago)
Author:
mkommend
Message:

#2604:

  • Base classes for data analysis, classification, and regression models
  • Added target variable to classification and regression models
  • Switched parameter order in data analysis solutions (model, problemdata)
Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassification.cs

    r13238 r13941  
    220220
    221221      var problemDataClone = (IClassificationProblemData)problemData.Clone();
    222       return new NeuralNetworkClassificationSolution(problemDataClone, new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()));
     222      return new NeuralNetworkClassificationSolution(new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()), problemDataClone);
    223223    }
    224224    #endregion
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassificationSolution.cs

    r12012 r13941  
    4343      : base(original, cloner) {
    4444    }
    45     public NeuralNetworkClassificationSolution(IClassificationProblemData problemData, INeuralNetworkModel nnModel)
     45    public NeuralNetworkClassificationSolution(INeuralNetworkModel nnModel, IClassificationProblemData problemData)
    4646      : base(nnModel, problemData) {
    4747    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs

    r13238 r13941  
    204204      relClassError = alglib.mlperelclserror(mlpEnsemble, inputMatrix, nRows);
    205205      var problemDataClone = (IClassificationProblemData)problemData.Clone();
    206       return new NeuralNetworkEnsembleClassificationSolution(problemDataClone, new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()));
     206      return new NeuralNetworkEnsembleClassificationSolution(new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()), problemDataClone);
    207207    }
    208208    #endregion
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassificationSolution.cs

    r12012 r13941  
    4343      : base(original, cloner) {
    4444    }
    45     public NeuralNetworkEnsembleClassificationSolution(IClassificationProblemData problemData, INeuralNetworkEnsembleModel nnModel)
     45    public NeuralNetworkEnsembleClassificationSolution(INeuralNetworkEnsembleModel nnModel, IClassificationProblemData problemData)
    4646      : base(nnModel, problemData) {
    4747    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs

    r13921 r13941  
    3434  [StorableClass]
    3535  [Item("NeuralNetworkEnsembleModel", "Represents a neural network ensemble for regression and classification.")]
    36   public sealed class NeuralNetworkEnsembleModel : NamedItem, INeuralNetworkEnsembleModel {
     36  public sealed class NeuralNetworkEnsembleModel : ClassificationModel, INeuralNetworkEnsembleModel {
    3737
    3838    private alglib.mlpensemble mlpEnsemble;
     
    4848    }
    4949
    50     public string TargetVariable {
    51       get { return targetVariable; }
    52     }
    53 
    54     public IEnumerable<string> VariablesUsedForPrediction {
     50    public override IEnumerable<string> VariablesUsedForPrediction {
    5551      get { return allowedInputVariables; }
    5652    }
     
    8076    }
    8177    public NeuralNetworkEnsembleModel(alglib.mlpensemble mlpEnsemble, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null)
    82       : base() {
     78      : base(targetVariable) {
    8379      this.name = ItemName;
    8480      this.description = ItemDescription;
     
    111107    }
    112108
    113     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     109    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    114110      double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows);
    115111
     
    137133    }
    138134
    139     public INeuralNetworkEnsembleRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    140       return new NeuralNetworkEnsembleRegressionSolution(new RegressionEnsembleProblemData(problemData), this);
    141     }
    142     IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {
    143       return CreateRegressionSolution(problemData);
    144     }
    145     public INeuralNetworkEnsembleClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    146       return new NeuralNetworkEnsembleClassificationSolution(new ClassificationEnsembleProblemData(problemData), this);
    147     }
    148     IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
    149       return CreateClassificationSolution(problemData);
     135    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
     136      return new NeuralNetworkEnsembleRegressionSolution(this, new RegressionEnsembleProblemData(problemData));
     137    }
     138    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     139      return new NeuralNetworkEnsembleClassificationSolution(this, new ClassificationEnsembleProblemData(problemData));
    150140    }
    151141
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs

    r13238 r13941  
    190190      avgRelError = alglib.mlpeavgrelerror(mlpEnsemble, inputMatrix, nRows);
    191191
    192       return new NeuralNetworkEnsembleRegressionSolution((IRegressionProblemData)problemData.Clone(), new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables));
     192      return new NeuralNetworkEnsembleRegressionSolution(new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables), (IRegressionProblemData)problemData.Clone());
    193193    }
    194194    #endregion
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegressionSolution.cs

    r12012 r13941  
    4343      : base(original, cloner) {
    4444    }
    45     public NeuralNetworkEnsembleRegressionSolution(IRegressionProblemData problemData, INeuralNetworkEnsembleModel nnModel)
     45    public NeuralNetworkEnsembleRegressionSolution(INeuralNetworkEnsembleModel nnModel, IRegressionProblemData problemData)
    4646      : base(nnModel, problemData) {
    4747      RecalculateResults();
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs

    r13921 r13941  
    3434  [StorableClass]
    3535  [Item("NeuralNetworkModel", "Represents a neural network for regression and classification.")]
    36   public sealed class NeuralNetworkModel : NamedItem, INeuralNetworkModel {
     36  public sealed class NeuralNetworkModel : ClassificationModel, INeuralNetworkModel {
    3737
    3838    private alglib.multilayerperceptron multiLayerPerceptron;
     
    4848    }
    4949
    50     public IEnumerable<string> VariablesUsedForPrediction {
     50    public override IEnumerable<string> VariablesUsedForPrediction {
    5151      get { return allowedInputVariables; }
    5252    }
    5353
    54     public string TargetVariable {
    55       get { return targetVariable; }
    56     }
    57 
    58     [Storable]
    59     private string targetVariable;
    6054    [Storable]
    6155    private string[] allowedInputVariables;
     
    8276      multiLayerPerceptron.innerobj.x = (double[])original.multiLayerPerceptron.innerobj.x.Clone();
    8377      multiLayerPerceptron.innerobj.y = (double[])original.multiLayerPerceptron.innerobj.y.Clone();
    84       targetVariable = original.targetVariable;
    8578      allowedInputVariables = (string[])original.allowedInputVariables.Clone();
    8679      if (original.classValues != null)
     
    8881    }
    8982    public NeuralNetworkModel(alglib.multilayerperceptron multiLayerPerceptron, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null)
    90       : base() {
     83      : base(targetVariable) {
    9184      this.name = ItemName;
    9285      this.description = ItemDescription;
    9386      this.multiLayerPerceptron = multiLayerPerceptron;
    94       this.targetVariable = targetVariable;
    9587      this.allowedInputVariables = allowedInputVariables.ToArray();
    9688      if (classValues != null)
     
    119111    }
    120112
    121     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     113    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    122114      double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows);
    123115
     
    145137    }
    146138
    147     public INeuralNetworkRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    148       return new NeuralNetworkRegressionSolution(new RegressionProblemData(problemData), this);
    149     }
    150     IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {
    151       return CreateRegressionSolution(problemData);
    152     }
    153     public INeuralNetworkClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    154       return new NeuralNetworkClassificationSolution(new ClassificationProblemData(problemData), this);
    155     }
    156     IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
    157       return CreateClassificationSolution(problemData);
     139    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
     140      return new NeuralNetworkRegressionSolution(this, new RegressionProblemData(problemData));
     141    }
     142    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     143      return new NeuralNetworkClassificationSolution(this, new ClassificationProblemData(problemData));
    158144    }
    159145
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs

    r13238 r13941  
    207207      avgRelError = alglib.mlpavgrelerror(multiLayerPerceptron, inputMatrix, nRows);
    208208
    209       return new NeuralNetworkRegressionSolution((IRegressionProblemData)problemData.Clone(), new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables));
     209      return new NeuralNetworkRegressionSolution(new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables), (IRegressionProblemData)problemData.Clone());
    210210    }
    211211    #endregion
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegressionSolution.cs

    r12012 r13941  
    4343      : base(original, cloner) {
    4444    }
    45     public NeuralNetworkRegressionSolution(IRegressionProblemData problemData, INeuralNetworkModel nnModel)
     45    public NeuralNetworkRegressionSolution(INeuralNetworkModel nnModel, IRegressionProblemData problemData)
    4646      : base(nnModel, problemData) {
    4747    }
Note: See TracChangeset for help on using the changeset viewer.