Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/05/16 11:58:52 (8 years ago)
Author:
gkronber
Message:

#2653: added synchronization in NearestNeighbourModel and made some related changes to GradientBoostedTreesModelSurrogate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs

    r14185 r14236  
    5757
    5858    public override IEnumerable<string> VariablesUsedForPrediction {
    59       get { return actualModel.Models.SelectMany(x => x.VariablesUsedForPrediction).Distinct().OrderBy(x => x); }
     59      get
     60      {
     61        lock (actualModel) { if (actualModel == null) actualModel = RecalculateModel(); }
     62        return actualModel.Models.SelectMany(x => x.VariablesUsedForPrediction).Distinct().OrderBy(x => x);
     63      }
    6064    }
    6165
     
    105109    // forward message to actual model (recalculate model first if necessary)
    106110    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    107       if (actualModel == null) actualModel = RecalculateModel();
     111      lock (actualModel) { if (actualModel == null) actualModel = RecalculateModel(); }
    108112      return actualModel.GetEstimatedValues(dataset, rows);
    109113    }
     
    119123    public IEnumerable<IRegressionModel> Models {
    120124      get {
    121         if (actualModel == null) actualModel = RecalculateModel();
     125        lock(actualModel) { if (actualModel == null) actualModel = RecalculateModel();}
    122126        return actualModel.Models;
    123127      }
     
    126130    public IEnumerable<double> Weights {
    127131      get {
    128         if (actualModel == null) actualModel = RecalculateModel();
     132        lock(actualModel) { if (actualModel == null) actualModel = RecalculateModel();}
    129133        return actualModel.Weights;
    130134      }
Note: See TracChangeset for help on using the changeset viewer.