Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/13 17:18:05 (12 years ago)
Author:
abeham
Message:

#1913: fixed handling of non-sequential natural numbered class values in LDA initializer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/LdaInitializer.cs

    r9272 r9451  
    4848                                                data.TrainingIndices);
    4949
    50       var uniqueClasses = data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices).Distinct().Count();
     50      // map class values to sequential natural numbers (required by alglib)
     51      var uniqueClasses = data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices)
     52                                        .Distinct()
     53                                        .Select((v, i) => new { v, i })
     54                                        .ToDictionary(x => x.v, x => x.i);
     55
     56      for (int row = 0; row < instances; row++)
     57        ldaDs[row, attributes] = uniqueClasses[ldaDs[row, attributes]];
    5158
    5259      int info;
    5360      double[,] matrix;
    54       alglib.fisherldan(ldaDs, instances, attributes, uniqueClasses, out info, out matrix);
     61      alglib.fisherldan(ldaDs, instances, attributes, uniqueClasses.Count, out info, out matrix);
    5562
    5663      return matrix;
Note: See TracChangeset for help on using the changeset viewer.