Changeset 12373


Ignore:
Timestamp:
05/02/15 14:34:26 (4 years ago)
Author:
gkronber
Message:

#2261: added hidden alg.-parameter to disable solution-creation (this is useful for cross-validation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GBT/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesAlgorithm.cs

    r12332 r12373  
    6262    private const string LossFunctionParameterName = "LossFunction";
    6363    private const string UpdateIntervalParameterName = "UpdateInterval";
     64    private const string CreateSolutionParameterName = "CreateSolution";
    6465    #endregion
    6566
     
    9192    public IFixedValueParameter<IntValue> UpdateIntervalParameter {
    9293      get { return (IFixedValueParameter<IntValue>)Parameters[UpdateIntervalParameterName]; }
     94    }
     95    public IFixedValueParameter<BoolValue> CreateSolutionParameter {
     96      get { return (IFixedValueParameter<BoolValue>)Parameters[CreateSolutionParameterName]; }
    9397    }
    9498    #endregion
     
    122126      get { return MParameter.Value.Value; }
    123127      set { MParameter.Value.Value = value; }
     128    }
     129    public bool CreateSolution {
     130      get { return CreateSolutionParameter.Value.Value; }
     131      set { CreateSolutionParameter.Value.Value = value; }
    124132    }
    125133    #endregion
     
    156164      Parameters.Add(new FixedValueParameter<DoubleValue>(MParameterName, "Ratio of variables selected randomly in each step (0 < M <= 1)", new DoubleValue(0.5)));
    157165      Parameters.Add(new FixedValueParameter<DoubleValue>(NuParameterName, "Learning rate nu (step size for the gradient update, should be small 0 < nu < 0.1)", new DoubleValue(0.002)));
    158       Parameters.Add(new FixedValueParameter<IntValue>("UpdateInterval", "", new IntValue(100)));
    159       Parameters["UpdateInterval"].Hidden = true;
     166      Parameters.Add(new FixedValueParameter<IntValue>(UpdateIntervalParameterName, "", new IntValue(100)));
     167      Parameters[UpdateIntervalParameterName].Hidden = true;
     168      Parameters.Add(new FixedValueParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true)));
     169      Parameters[CreateSolutionParameterName].Hidden = true;
    160170
    161171      var lossFunctionNames = ApplicationManager.Manager.GetInstances<ILossFunction>().Select(l => new StringValue(l.ToString()).AsReadOnly());
     
    179189      Results.Add(new Result("Qualities", table));
    180190      var curLoss = new DoubleValue();
    181       Results.Add(new Result("Current loss", curLoss));
     191      Results.Add(new Result("Loss (train)", curLoss));
    182192
    183193      // init
     
    225235
    226236      Results.Add(new Result("Variable relevance", impacts));
     237      Results.Add(new Result("Loss (test)", new DoubleValue(state.GetTestLoss())));
    227238
    228239      // produce solution
    229       Results.Add(new Result("Solution", new RegressionSolution(state.GetModel(), (IRegressionProblemData)problemData.Clone())));
     240      if (CreateSolution)
     241        Results.Add(new Result("Solution", new RegressionSolution(state.GetModel(), (IRegressionProblemData)problemData.Clone())));
    230242    }
    231243  }
Note: See TracChangeset for help on using the changeset viewer.