Ignore:
Timestamp:
11/18/15 16:42:40 (9 years ago)
Author:
atrautsch
Message:

metric matching configurable

Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp/training
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/training/ISetWiseTestdataAwareTrainingStrategy.java

    r44 r45  
    99 
    1010    String getName(); 
     11     
     12    void setMethod(String method); 
     13    void setThreshold(String threshold); 
    1114} 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/training/MetricMatchingTraining.java

    r44 r45  
    2323 
    2424import org.apache.commons.collections4.list.SetUniqueList; 
    25 import org.apache.commons.math3.stat.inference.ChiSquareTest;   
    26 import org.apache.commons.math3.stat.correlation.SpearmansCorrelation;  // spearman ist drin 
    27 import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; // kolmogorov nicht in der 3.1  
     25import org.apache.commons.math3.stat.inference.ChiSquareTest; 
     26import org.apache.commons.math3.stat.correlation.SpearmansCorrelation; 
     27import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; 
    2828 
    2929import de.ugoe.cs.util.console.Console; 
     
    4242    private final Classifier classifier = new MetricMatchingClassifier(); 
    4343     
     44    private String method; 
     45    private float threshold; 
    4446     
    4547    /** 
     
    5254    } 
    5355     
    54     /* 
     56     
    5557    @Override 
    5658    public String getName() { 
    57         return "MetricMatching_" + this.classifier.getName(); 
    58     }*/ 
     59        return "MetricMatching_" + classifierName; 
     60    } 
     61 
     62 
     63    @Override 
     64    public void setMethod(String method) { 
     65        this.method = method; 
     66    } 
     67 
     68 
     69    @Override 
     70    public void setThreshold(String threshold) { 
     71        this.threshold = Float.parseFloat(threshold); 
     72    } 
    5973 
    6074        /** 
    61          * We need the testdata instances to do a metric matching so in this special case we get this data 
     75         * We need the testdata instances to do a metric matching, so in this special case we get this data 
    6276         * before evaluation 
    6377         */ 
     
    7690                        //tmp.kolmogorovSmirnovTest(0.05); 
    7791                         
    78                         tmp.spearmansRankCorrelation(0.5); 
    79                          
    80                         //Console.traceln(Level.INFO, "Tested traindata set " + num + " for matching attributes, found " + tmp.getRank() + " matches"); 
     92                        if( this.method.equals("spearman") ) { 
     93                            tmp.spearmansRankCorrelation(this.threshold); 
     94                        } 
     95                        else if( this.method.equals("kolmogorov") ) { 
     96                            tmp.kolmogorovSmirnovTest(this.threshold); 
     97                        } 
     98                        else { 
     99                            throw new RuntimeException("unknown method"); 
     100                        } 
    81101 
    82102                        // we only select the training data from our set with the most matching attributes 
     
    129149                        this.classifier.buildClassifier(traindata); 
    130150                } 
    131                  
     151 
    132152                public void setMetricMatching(MetricMatch mm) { 
    133153                        this.mm = mm; 
     
    400420                } 
    401421         } 
    402  
    403  
    404422} 
Note: See TracChangeset for help on using the changeset viewer.