Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/11 12:38:43 (12 years ago)
Author:
gkronber
Message:

#1418 implemented wrapper for LDA (linear discriminant analysis) implemented in alglib.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClusteringUtil.cs

    r5651 r5658  
    2727namespace HeuristicLab.Algorithms.DataAnalysis {
    2828  public static class KMeansClusteringUtil {
    29     public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) {
    30       List<int> allowedRows = CalculateAllowedRows(dataset, allowedInputVariables, rows).ToList();
    31 
    32       double[,] matrix = new double[allowedRows.Count, allowedInputVariables.Count()];
    33       for (int row = 0; row < allowedRows.Count; row++) {
    34         int col = 0;
    35         foreach (string column in allowedInputVariables) {
    36           matrix[row, col] = dataset[column, row];
    37           col++;
    38         }
    39       }
    40       return matrix;
    41     }
    42 
    43     private static IEnumerable<int> CalculateAllowedRows(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) {
    44       // return only rows that contain no infinity or NaN values
    45       return from row in rows
    46              where (from inputVariable in allowedInputVariables
    47                     let x = dataset[inputVariable, row]
    48                     where double.IsInfinity(x) || double.IsNaN(x)
    49                     select 1)
    50                     .Any() == false
    51              select row;
    52     }
    53 
    5429    public static IEnumerable<int> FindClosestCenters(IEnumerable<double[]> centers, Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) {
    5530      int nRows = rows.Count();
Note: See TracChangeset for help on using the changeset viewer.