Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16086


Ignore:
Timestamp:
08/23/18 09:56:09 (6 years ago)
Author:
bwerth
Message:

#2941 added divion-by-zero check to scaling

File:
1 edited

Legend:

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

    r15786 r16086  
    130130          // automatic determination of weights (all features should have variance = 1)
    131131          this.weights = this.allowedInputVariables
    132             .Select(name => 1.0 / dataset.GetDoubleValues(name, rows).StandardDeviationPop())
     132            .Select(name => {
     133              var pop = dataset.GetDoubleValues(name, rows).StandardDeviationPop();
     134              return  pop.IsAlmost(0) ? 1.0 : 1.0/pop;
     135            })
    133136            .Concat(new double[] { 1.0 }) // no scaling for target variable
    134137            .ToArray();
Note: See TracChangeset for help on using the changeset viewer.