Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/20/21 18:13:55 (3 years ago)
Author:
dpiringe
Message:

#3026

  • merged trunk into branch
Location:
branches/3026_IntegrationIntoSymSpace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis/3.4

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourRegression.cs

    r17180 r18027  
    4141    private const string NearestNeighbourRegressionModelResultName = "Nearest neighbour regression solution";
    4242    private const string WeightsParameterName = "Weights";
    43     private const string SelfMatchParameterName = "SelfMatch";
    4443
    4544    #region parameter properties
    4645    public IFixedValueParameter<IntValue> KParameter {
    4746      get { return (IFixedValueParameter<IntValue>)Parameters[KParameterName]; }
    48     }
    49     public IFixedValueParameter<BoolValue> SelfMatchParameter {
    50       get { return (IFixedValueParameter<BoolValue>)Parameters[SelfMatchParameterName]; }
    5147    }
    5248    public IValueParameter<DoubleArray> WeightsParameter {
     
    6157        else KParameter.Value.Value = value;
    6258      }
    63     }
    64     public bool SelfMatch {
    65       get { return SelfMatchParameter.Value.Value; }
    66       set { SelfMatchParameter.Value.Value = value; }
    6759    }
    6860    public DoubleArray Weights {
     
    8173      Parameters.Add(new FixedValueParameter<IntValue>(KParameterName, "The number of nearest neighbours to consider for regression.", new IntValue(3)));
    8274      Parameters.Add(new OptionalValueParameter<DoubleArray>(WeightsParameterName, "Optional: use weights to specify individual scaling values for all features. If not set the weights are calculated automatically (each feature is scaled to unit variance)"));
    83       Parameters.Add(new FixedValueParameter<BoolValue>(SelfMatchParameterName, "Should we use equal points for classification?", new BoolValue(false)));
    8475      Problem = new RegressionProblem();
    8576    }
     
    9182      if (!Parameters.ContainsKey(WeightsParameterName)) {
    9283        Parameters.Add(new OptionalValueParameter<DoubleArray>(WeightsParameterName, "Optional: use weights to specify individual scaling values for all features. If not set the weights are calculated automatically (each feature is scaled to unit variance)"));
    93       }
    94       if (!Parameters.ContainsKey(SelfMatchParameterName)) {
    95         Parameters.Add(new FixedValueParameter<BoolValue>(SelfMatchParameterName, "Should we use equal points for classification?", new BoolValue(false)));
    9684      }
    9785      #endregion
     
    10694      double[] weights = null;
    10795      if (Weights != null) weights = Weights.CloneAsArray();
    108       var solution = CreateNearestNeighbourRegressionSolution(Problem.ProblemData, K, SelfMatch, weights);
     96      var solution = CreateNearestNeighbourRegressionSolution(Problem.ProblemData, K, weights);
    10997      Results.Add(new Result(NearestNeighbourRegressionModelResultName, "The nearest neighbour regression solution.", solution));
    11098    }
    11199
    112     public static IRegressionSolution CreateNearestNeighbourRegressionSolution(IRegressionProblemData problemData, int k, bool selfMatch = false, double[] weights = null) {
     100    public static IRegressionSolution CreateNearestNeighbourRegressionSolution(IRegressionProblemData problemData, int k, double[] weights = null) {
    113101      var clonedProblemData = (IRegressionProblemData)problemData.Clone();
    114       return new NearestNeighbourRegressionSolution(Train(problemData, k, selfMatch, weights), clonedProblemData);
     102      return new NearestNeighbourRegressionSolution(Train(problemData, k, weights), clonedProblemData);
    115103    }
    116104
    117     public static INearestNeighbourModel Train(IRegressionProblemData problemData, int k, bool selfMatch = false, double[] weights = null) {
     105    public static INearestNeighbourModel Train(IRegressionProblemData problemData, int k, double[] weights = null) {
    118106      return new NearestNeighbourModel(problemData.Dataset,
    119107        problemData.TrainingIndices,
    120108        k,
    121         selfMatch,
    122109        problemData.TargetVariable,
    123110        problemData.AllowedInputVariables,
Note: See TracChangeset for help on using the changeset viewer.