Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/21 19:41:33 (3 years ago)
Author:
gkronber
Message:

#3117: update alglib to version 3.17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourClassification.cs

    r17180 r17931  
    4242    private const string NearestNeighbourClassificationModelResultName = "Nearest neighbour classification solution";
    4343    private const string WeightsParameterName = "Weights";
    44     private const string SelfMatchParameterName = "SelfMatch";
    4544
    4645    #region parameter properties
    4746    public IFixedValueParameter<IntValue> KParameter {
    4847      get { return (IFixedValueParameter<IntValue>)Parameters[KParameterName]; }
    49     }
    50     public IFixedValueParameter<BoolValue> SelfMatchParameter {
    51       get { return (IFixedValueParameter<BoolValue>)Parameters[SelfMatchParameterName]; }
    5248    }
    5349    public IValueParameter<DoubleArray> WeightsParameter {
     
    5652    #endregion
    5753    #region properties
    58     public bool SelfMatch {
    59       get { return SelfMatchParameter.Value.Value; }
    60       set { SelfMatchParameter.Value.Value = value; }
    61     }
    6254    public int K {
    6355      get { return KParameter.Value.Value; }
     
    8072    public NearestNeighbourClassification()
    8173      : base() {
    82       Parameters.Add(new FixedValueParameter<BoolValue>(SelfMatchParameterName, "Should we use equal points for classification?", new BoolValue(false)));
    8374      Parameters.Add(new FixedValueParameter<IntValue>(KParameterName, "The number of nearest neighbours to consider for regression.", new IntValue(3)));
    8475      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)"));
     
    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 = CreateNearestNeighbourClassificationSolution(Problem.ProblemData, K, SelfMatch, weights);
     96      var solution = CreateNearestNeighbourClassificationSolution(Problem.ProblemData, K, weights);
    10997      Results.Add(new Result(NearestNeighbourClassificationModelResultName, "The nearest neighbour classification solution.", solution));
    11098    }
    11199
    112     public static IClassificationSolution CreateNearestNeighbourClassificationSolution(IClassificationProblemData problemData, int k, bool selfMatch = false, double[] weights = null) {
     100    public static IClassificationSolution CreateNearestNeighbourClassificationSolution(IClassificationProblemData problemData, int k, double[] weights = null) {
    113101      var problemDataClone = (IClassificationProblemData)problemData.Clone();
    114       return new NearestNeighbourClassificationSolution(Train(problemDataClone, k, selfMatch, weights), problemDataClone);
     102      return new NearestNeighbourClassificationSolution(Train(problemDataClone, k, weights), problemDataClone);
    115103    }
    116104
    117     public static INearestNeighbourModel Train(IClassificationProblemData problemData, int k, bool selfMatch = false, double[] weights = null) {
     105    public static INearestNeighbourModel Train(IClassificationProblemData 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.