Java Examples for weka.filters.SimpleBatchFilter

The following java examples will help you to understand the usage of weka.filters.SimpleBatchFilter. These source code samples are taken from different open source projects.

Example 1
Project: TimeSeriesClassification-master  File: View source code
public static Instances basicTransformExample(Instances train) {
    /*Class to demonstrate the usage of the FullShapeletTransform. Returns the 
  * transformed set of instances  
    st = new ShapeletTransform();
    /*The number of shapelets defaults to 100. we recommend setting it to a large
value, since there will be many duplicates and there is little overhead in 
* keeping a lot (although the shapelet early abandon becomes less efficient).
    //Let m=train.numAttributes()-1 (series length)
    //Let n=   train.numInstances() (number of series)      
    int nosShapelets = (train.numAttributes() - 1) * train.numInstances() / 5;
    if (nosShapelets < FullShapeletTransform.DEFAULT_NUMSHAPELETS)
        nosShapelets = FullShapeletTransform.DEFAULT_NUMSHAPELETS;
    /* Two other key parameters are minShapeletLength and maxShapeletLength. For 
 * each value between these two, a full search is performed, which is 
 * order (m^2n^2), so clearly there is a time/accuracy trade off. Defaults 
 * to min of 3 max of 30.
    int minLength = 5;
    int maxLength = (train.numAttributes() - 1) / 10;
    if (maxLength < FullShapeletTransform.DEFAULT_MINSHAPELETLENGTH)
        maxLength = FullShapeletTransform.DEFAULT_MINSHAPELETLENGTH;
    st.setShapeletMinAndMax(minLength, maxLength);
    /*Next you need to set the quality measure. This defaults to IG, but         
 * we recommend using the F stat. It is faster and (debatably) more accurate.
    // You can set the filter to output details of the shapelets or not  
    // Alternatively, you can turn the logging off
    //        st.turnOffLog();        
    /* Thats the basic options. Now you need to perform the transform.
 * FullShapeletTransform extends the weka SimpleBatchFilter, but we have made 
 * the method process public to make usage easier.
    Instances shapeletT = null;
    try {
        shapeletT = st.process(train);
    } catch (Exception ex) {
        System.out.println("Error performing the shapelet transform" + ex);
    return shapeletT;