Changeset 42


Ignore:
Timestamp:
11/13/15 18:09:46 (9 years ago)
Author:
sherbold
Message:
  • added CLA/CLAMI data processors (ASE 2015)
  • modified normal WEKA training to have a fallback in case to few instances of a certain class (defect-prone, non-defect-prone) are available: it now uses ZeroR in that case, i.e., a trivial classifier that always predicts the class that appears more often.
Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp
Files:
2 added
2 edited

Legend:

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

    r41 r42  
    5656        classifierParams = Arrays.copyOfRange(params, 2, params.length); 
    5757 
    58         classifier = setupClassifier(); 
     58        //classifier = setupClassifier(); 
    5959    } 
    6060 
     
    6464    } 
    6565 
    66     public Classifier setupClassifier() { 
     66    protected Classifier setupClassifier() { 
    6767        Classifier cl = null; 
    6868        try { 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining.java

    r41 r42  
    2121 
    2222import de.ugoe.cs.util.console.Console; 
     23import weka.classifiers.rules.ZeroR; 
    2324import weka.core.Instances; 
    2425 
     
    4647    @Override 
    4748    public void apply(Instances traindata) { 
     49        classifier = setupClassifier(); 
    4850        PrintStream errStr = System.err; 
    4951        System.setErr(new PrintStream(new NullOutputStream())); 
     
    5557        } 
    5658        catch (Exception e) { 
    57             throw new RuntimeException(e); 
     59            if (e.getMessage().contains("Not enough training instances with class labels")) { 
     60                Console.traceln(Level.SEVERE, 
     61                                "failure due to lack of instances: " + e.getMessage()); 
     62                Console.traceln(Level.SEVERE, "training ZeroR classifier instead"); 
     63                classifier = new ZeroR(); 
     64                try { 
     65                    classifier.buildClassifier(traindata); 
     66                } 
     67                catch (Exception e2) { 
     68                    throw new RuntimeException(e2); 
     69                } 
     70            } 
     71            else { 
     72                throw new RuntimeException(e); 
     73            } 
    5874        } 
    5975        finally { 
Note: See TracChangeset for help on using the changeset viewer.