Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/16 14:37:15 (8 years ago)
Author:
mkommend
Message:

#2604: Merged r13826,r13921, r13922, r13941, r13992, r13993, r14000 intos table.

Location:
stable
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis

  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassification.cs

    r13297 r14027  
    143143
    144144      if (CreateSolution) {
    145         var solution = new RandomForestClassificationSolution((IClassificationProblemData)Problem.ProblemData.Clone(), model);
     145        var solution = new RandomForestClassificationSolution(model, (IClassificationProblemData)Problem.ProblemData.Clone());
    146146        Results.Add(new Result(RandomForestClassificationModelResultName, "The random forest classification solution.", solution));
    147147      }
    148148    }
    149    
     149
    150150    // keep for compatibility with old API
    151151    public static RandomForestClassificationSolution CreateRandomForestClassificationSolution(IClassificationProblemData problemData, int nTrees, double r, double m, int seed,
    152152      out double rmsError, out double relClassificationError, out double outOfBagRmsError, out double outOfBagRelClassificationError) {
    153153      var model = CreateRandomForestClassificationModel(problemData, nTrees, r, m, seed, out rmsError, out relClassificationError, out outOfBagRmsError, out outOfBagRelClassificationError);
    154       return new RandomForestClassificationSolution((IClassificationProblemData)problemData.Clone(), model);
     154      return new RandomForestClassificationSolution(model, (IClassificationProblemData)problemData.Clone());
    155155    }
    156156
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassificationSolution.cs

    r12009 r14027  
    4343      : base(original, cloner) {
    4444    }
    45     public RandomForestClassificationSolution(IClassificationProblemData problemData, IRandomForestModel randomForestModel)
     45    public RandomForestClassificationSolution(IRandomForestModel randomForestModel, IClassificationProblemData problemData)
    4646      : base(randomForestModel, problemData) {
    4747    }
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs

    r12702 r14027  
    3434  [StorableClass]
    3535  [Item("RandomForestModel", "Represents a random forest for regression and classification.")]
    36   public sealed class RandomForestModel : NamedItem, IRandomForestModel {
     36  public sealed class RandomForestModel : ClassificationModel, IRandomForestModel {
    3737    // not persisted
    3838    private alglib.decisionforest randomForest;
     
    4444      }
    4545    }
     46
     47    public override IEnumerable<string> VariablesUsedForPrediction {
     48      get { return originalTrainingData.AllowedInputVariables; }
     49    }
     50
    4651
    4752    // instead of storing the data of the model itself
     
    9196
    9297    // random forest models can only be created through the static factory methods CreateRegressionModel and CreateClassificationModel
    93     private RandomForestModel(alglib.decisionforest randomForest,
     98    private RandomForestModel(string targetVariable, alglib.decisionforest randomForest,
    9499      int seed, IDataAnalysisProblemData originalTrainingData,
    95100      int nTrees, double r, double m, double[] classValues = null)
    96       : base() {
     101      : base(targetVariable) {
    97102      this.name = ItemName;
    98103      this.description = ItemDescription;
     
    147152    }
    148153
    149     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     154    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    150155      double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows);
    151156      AssertInputMatrix(inputData);
     
    174179    }
    175180
    176     public IRandomForestRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    177       return new RandomForestRegressionSolution(new RegressionProblemData(problemData), this);
    178     }
    179     IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {
    180       return CreateRegressionSolution(problemData);
    181     }
    182     public IRandomForestClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    183       return new RandomForestClassificationSolution(new ClassificationProblemData(problemData), this);
    184     }
    185     IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
    186       return CreateClassificationSolution(problemData);
     181
     182    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
     183      return new RandomForestRegressionSolution(this, new RegressionProblemData(problemData));
     184    }
     185    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     186      return new RandomForestClassificationSolution(this, new ClassificationProblemData(problemData));
    187187    }
    188188
     
    205205      outOfBagRmsError = rep.oobrmserror;
    206206
    207       return new RandomForestModel(dForest, seed, problemData, nTrees, r, m);
     207      return new RandomForestModel(problemData.TargetVariable, dForest, seed, problemData, nTrees, r, m);
    208208    }
    209209
     
    242242      outOfBagRelClassificationError = rep.oobrelclserror;
    243243
    244       return new RandomForestModel(dForest, seed, problemData, nTrees, r, m, classValues);
     244      return new RandomForestModel(problemData.TargetVariable, dForest, seed, problemData, nTrees, r, m, classValues);
    245245    }
    246246
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs

    r13297 r14027  
    143143
    144144      if (CreateSolution) {
    145         var solution = new RandomForestRegressionSolution((IRegressionProblemData)Problem.ProblemData.Clone(), model);
     145        var solution = new RandomForestRegressionSolution(model, (IRegressionProblemData)Problem.ProblemData.Clone());
    146146        Results.Add(new Result(RandomForestRegressionModelResultName, "The random forest regression solution.", solution));
    147147      }
     
    153153      var model = CreateRandomForestRegressionModel(problemData, nTrees, r, m, seed,
    154154        out rmsError, out avgRelError, out outOfBagRmsError, out outOfBagAvgRelError);
    155       return new RandomForestRegressionSolution((IRegressionProblemData)problemData.Clone(), model);
     155      return new RandomForestRegressionSolution(model, (IRegressionProblemData)problemData.Clone());
    156156    }
    157157
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegressionSolution.cs

    r12009 r14027  
    4343      : base(original, cloner) {
    4444    }
    45     public RandomForestRegressionSolution(IRegressionProblemData problemData, IRandomForestModel randomForestModel)
     45    public RandomForestRegressionSolution(IRandomForestModel randomForestModel, IRegressionProblemData problemData)
    4646      : base(randomForestModel, problemData) {
    4747    }
Note: See TracChangeset for help on using the changeset viewer.