Example usage for weka.filters.unsupervised.attribute StringToNominal setAttributeRange

List of usage examples for weka.filters.unsupervised.attribute StringToNominal setAttributeRange

Introduction

In this page you can find the example usage for weka.filters.unsupervised.attribute StringToNominal setAttributeRange.

Prototype

public void setAttributeRange(String rangeList) 

Source Link

Document

Sets range of indices of the attributes used.

Usage

From source file:clases.Preproceso.java

public static Instances filterStringToNominal(Instances data, String i) {
    try {//from  w ww  .java2  s. c  o  m
        StringToNominal sn = new StringToNominal();
        sn.setAttributeRange(i);
        sn.setInputFormat(data);
        return Filter.useFilter(data, sn);
    } catch (Exception ex) {
        Logger.getLogger(Preproceso.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}

From source file:ffnn.FFNN.java

public static Instances preprocess(Instances i) {
    try {//from   w  w  w  .  jav  a 2  s  .  c  o  m
        Reorder rfilter = new Reorder();
        int classIdx = i.classIndex() + 1;
        String order;
        if (classIdx != 1) {
            order = "1";
            for (int j = 2; j <= i.numAttributes(); j++) {
                if (j != classIdx) {
                    order = order + "," + j;
                }
            }
        } else {
            order = "2";
            for (int j = 3; j <= i.numAttributes(); j++) {
                order = order + "," + j;
            }
        }
        order = order + "," + classIdx;
        rfilter.setAttributeIndices(order);
        rfilter.setInputFormat(i);
        i = Filter.useFilter(i, rfilter);

        StringToNominal stnfilter = new StringToNominal();
        stnfilter.setAttributeRange("first-last");
        stnfilter.setInputFormat(i);
        i = Filter.useFilter(i, stnfilter);

        NominalToBinary ntbfilter = new NominalToBinary();
        ntbfilter.setInputFormat(i);
        i = Filter.useFilter(i, ntbfilter);

        Normalize nfilter = new Normalize();
        nfilter.setInputFormat(i);
        i = Filter.useFilter(i, nfilter);
    } catch (Exception e) {
        System.out.println(e.toString());
    }
    return i;
}