Changeset 117 for trunk


Ignore:
Timestamp:
06/02/16 17:01:08 (9 years ago)
Author:
sherbold
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/dataselection/MahalanobisOutlierRemoval.java

    r86 r117  
    1919import org.apache.commons.math3.linear.LUDecomposition; 
    2020import org.apache.commons.math3.linear.RealMatrix; 
     21import org.apache.commons.math3.linear.SingularMatrixException; 
    2122import org.apache.commons.math3.stat.correlation.Covariance; 
    2223 
     24import de.lmu.ifi.dbs.elki.logging.Logging.Level; 
    2325import de.ugoe.cs.cpdp.util.WekaUtils; 
     26import de.ugoe.cs.util.console.Console; 
    2427import weka.core.Instances; 
    2528 
     
    9295            values.setRow(i, WekaUtils.instanceValues(data.get(i))); 
    9396        } 
    94         RealMatrix inverseCovariance = 
     97        RealMatrix inverseCovariance; 
     98        try { 
     99            inverseCovariance = 
    95100            new LUDecomposition(new Covariance(values).getCovarianceMatrix()).getSolver() 
    96101                .getInverse(); 
    97  
     102        } catch(SingularMatrixException e) { 
     103            Console.traceln(Level.WARNING, "could not perform Mahalanobis outlier removal due to singular covariance matrix"); 
     104            return; 
     105        } 
    98106        // create mean vector 
    99107        double[] meanValues = new double[data.numAttributes() - 1]; 
Note: See TracChangeset for help on using the changeset viewer.