Example usage for weka.filters.unsupervised.attribute RemoveType setInputFormat

List of usage examples for weka.filters.unsupervised.attribute RemoveType setInputFormat

Introduction

In this page you can find the example usage for weka.filters.unsupervised.attribute RemoveType setInputFormat.

Prototype

@Override
public boolean setInputFormat(Instances instanceInfo) throws Exception 

Source Link

Document

Sets the format of the input instances.

Usage

From source file:asap.NLPSystem.java

private Instances getFilteredSet(Instances set) {
    //TODO: filter all unwanted features
    if (set == null) {
        return null;
    }/*from  ww w  .  ja v  a 2s . c om*/

    RemoveType removeTypeFilter = new RemoveType();
    String[] removeTypeFilterOptions = { "-T", "string" };
    Instances filteredSet = null;
    try {
        removeTypeFilter.setInputFormat(set);
        removeTypeFilter.setOptions(removeTypeFilterOptions);
        filteredSet = Filter.useFilter(set, removeTypeFilter);
    } catch (Exception ex) {
        Logger.getLogger(NLPSystem.class.getName()).log(Level.SEVERE, null, ex);
    }
    return filteredSet;
}

From source file:org.opentox.qsar.processors.filters.AttributeCleanup.java

License:Open Source License

private Instances remove(Instances input, ATTRIBUTE_TYPE type) throws QSARException {
    RemoveType remover = new RemoveType();
    try {/*from   w  ww. j a  v a  2 s.c  om*/
        remover.setInputFormat(input);
    } catch (Exception ex) {
        String message = "Invalid input format for attribute-type removing filter";
        throw new QSARException(Cause.XQF11, message, ex);
    }
    String typeRemoved = type.toString();
    Instances output = input;
    String[] options = new String[] { "-T", typeRemoved };
    try {
        remover.setOptions(options);
    } catch (Exception ex) {
        String message = "Invalid filter options for cleanup";
        throw new QSARException(Cause.XQF111, message, ex);
    }
    try {
        output = RemoveType.useFilter(input, remover);
    } catch (Exception ex) {
        String message = "The filter is unable to remove the specified type :" + typeRemoved;
        throw new QSARException(Cause.XQF212, message, ex);
    }
    return output;
}