Example usage for weka.core.converters CSVLoader setNominalAttributes

List of usage examples for weka.core.converters CSVLoader setNominalAttributes

Introduction

In this page you can find the example usage for weka.core.converters CSVLoader setNominalAttributes.

Prototype

public void setNominalAttributes(String value) 

Source Link

Document

Sets the attribute range to be forced to type nominal.

Usage

From source file:classif.ExperimentsLauncher.java

License:Open Source License

public static Instances[] readTrainAndTest(String name) {
    File trainFile = new File(datasetsDir + name + "/" + name + "_TRAIN");
    if (!new File(trainFile.getAbsolutePath() + ".csv").exists()) {
        UCR2CSV.run(trainFile, new File(trainFile.getAbsolutePath() + ".csv"));
    }/*from  w  w w  .j  av a 2  s. com*/
    trainFile = new File(trainFile.getAbsolutePath() + ".csv");
    File testFile = new File(datasetsDir + name + "/" + name + "_TEST");
    if (!new File(testFile.getAbsolutePath() + ".csv").exists()) {
        UCR2CSV.run(testFile, new File(testFile.getAbsolutePath() + ".csv"));
    }
    testFile = new File(testFile.getAbsolutePath() + ".csv");

    CSVLoader loader = new CSVLoader();
    Instances trainDataset = null;
    Instances testDataset = null;

    try {
        loader.setFile(trainFile);
        loader.setNominalAttributes("first");
        trainDataset = loader.getDataSet();
        trainDataset.setClassIndex(0);

        loader.setFile(testFile);
        loader.setNominalAttributes("first");
        testDataset = loader.getDataSet();
        testDataset.setClassIndex(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new Instances[] { trainDataset, testDataset };
}

From source file:demo.Demo.java

License:Open Source License

/**
 * @param args/*from  w ww  .j a  v  a2s .  c o m*/
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {

    CSVLoader loader = new CSVLoader();
    System.out.println("Downloading dataset...");
    URL oracle = new URL("http://repository.seasr.org/Datasets/UCI/csv/mushroom.csv");
    File csvFile = File.createTempFile("data-", ".csv");
    BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
    PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(csvFile)));
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
        out.println(inputLine);
    }
    in.close();
    out.close();
    System.out.println("Dataset written to: " + csvFile.getAbsolutePath());

    loader.setFile(csvFile);
    loader.setNominalAttributes("first-last");
    Instances instances = loader.getDataSet();
    String[] variablesNames = new String[instances.numAttributes()];
    for (int i = 0; i < variablesNames.length; i++) {
        variablesNames[i] = instances.attribute(i).name();
    }

    ChordalysisModelling modeller = new ChordalysisModelling(0.05);

    System.out.println("Learning...");
    modeller.buildModel(instances);
    DecomposableModel bestModel = modeller.getModel();
    bestModel.display(variablesNames);
    System.out.println("The model selected is:");
    System.out.println(bestModel.toString(variablesNames));
    bestModel.display(variablesNames);

}

From source file:demo.DemoInference.java

License:Open Source License

/**
 * @param args/*from   w ww .  j  ava 2  s  . c  om*/
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {

    CSVLoader loader = new CSVLoader();
    System.out.println("Downloading dataset...");
    URL oracle = new URL("http://repository.seasr.org/Datasets/UCI/csv/mushroom.csv");
    File csvFile = File.createTempFile("data-", ".csv");
    BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
    PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(csvFile)));
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
        out.println(inputLine);
    }
    in.close();
    out.close();
    System.out.println("Dataset written to: " + csvFile.getAbsolutePath());

    loader.setFile(csvFile);
    loader.setNominalAttributes("first-last");
    Instances instances = loader.getDataSet();
    String[] variablesNames = new String[instances.numAttributes()];
    String[][] outcomes = new String[instances.numAttributes()][];
    for (int i = 0; i < variablesNames.length; i++) {
        variablesNames[i] = instances.attribute(i).name();
        outcomes[i] = new String[instances.attribute(i).numValues() + 1];//+1 for missing
        for (int j = 0; j < outcomes[i].length - 1; j++) {
            outcomes[i][j] = instances.attribute(i).value(j);
        }
        outcomes[i][outcomes[i].length - 1] = "missing";
        System.out.println("Dom(" + variablesNames[i] + ") = " + Arrays.toString(outcomes[i]));

    }

    ChordalysisModelling modeller = new ChordalysisModelling(0.05);

    System.out.println("Learning...");
    modeller.buildModel(instances);
    DecomposableModel bestModel = modeller.getModel();
    //      bestModel.display(variablesNames);
    System.out.println("The model selected is:");
    System.out.println(bestModel.toString(variablesNames));

    Inference inference = new Inference(bestModel, variablesNames, outcomes);
    inference.setProbabilities(modeller.getLattice());
    String targetVariable = "population";
    System.out.println("initial beliefs on " + targetVariable + " "
            + Arrays.toString(inference.getBelief(targetVariable)));

    System.out.println("adding evidence poisonous and convex shape");
    inference.addEvidence("class", "e");
    inference.addEvidence("cap-shape", "x");
    inference.recordEvidence();

    System.out.println(
            "beliefs on " + targetVariable + " " + Arrays.toString(inference.getBelief(targetVariable)));

    inference.clearEvidences();
    System.out.println("reset beliefs");
    System.out.println(
            "reset beliefs on " + targetVariable + " " + Arrays.toString(inference.getBelief(targetVariable)));

}

From source file:demo.Run.java

License:Open Source License

/**
 * @param args//from   ww  w.  j  a v  a2 s  . c o  m
 */
public static void main(String[] args) {
    if (args.length != 4) {
        System.out.println("Usage:\tjava -Xmx1g -jar Chordalysis.jar dataFile pvalue imageOutputFile useGUI?");
        System.out.println("Example:\tjava -Xmx1g -jar Chordalysis.jar dataset.csv 0.05 graph.png false");
        System.out.println("\nNote:\t'1g' means that you authorize 1GB of memory. "
                + "\nNote:\tIt should be adjusted depending upon the size of your data set (mostly required to load the data set).");
        return;
    }
    System.out.println();
    CSVLoader loader = new CSVLoader();
    File csvFile = new File(args[0]);
    if (!csvFile.exists()) {
        System.out.println("The file doesn't exist");
        return;
    } else {
        System.out.println("Info:\tUsing the dataset file " + csvFile.getAbsolutePath());
    }

    double pValue = Double.valueOf(args[1]);
    if (pValue <= 0 || 1 <= pValue) {
        System.out.println("The p-value should be between 0 and 1 excluded. ");
        return;
    } else {
        System.out.println("Info:\tUsing p=" + pValue);
    }

    File outPutFile = new File(args[2]);
    String[] splitted = outPutFile.getName().split("\\.");
    if (splitted.length < 2) {
        System.out.println(
                "The image output file should declare an extension among \".jpg\", \".png\" or \".gif\"");
        return;
    }
    String extension = splitted[splitted.length - 1];
    if (!extension.equals("jpg") && !extension.equals("png") && !extension.equals("gif")) {
        System.out.println(
                "The format for the graphical representation of the model should be either jpg, png or gif. ");
        return;
    } else {
        System.out.println("Info:\tExporting result as a " + extension + " file");
    }

    boolean gui = Boolean.parseBoolean(args[3]);

    if (gui) {
        System.out.println("Info:\tUsing a graphical user interface");
    } else {
        System.out.println("Info:\tNot using a graphical user interface");
    }

    try {
        loader.setFile(csvFile);
        loader.setNominalAttributes("first-last");
        Instances instances = loader.getDataSet();
        String[] variablesNames = new String[instances.numAttributes()];
        for (int i = 0; i < variablesNames.length; i++) {
            variablesNames[i] = instances.attribute(i).name();
        }
        long start = System.currentTimeMillis();

        ChordalysisModelling modeller = new ChordalysisModelling(pValue);
        modeller.buildModel(instances);
        DecomposableModel bestModel = modeller.getModel();

        if (gui)
            bestModel.display(variablesNames);
        System.out
                .println("The model selected is: (selected in " + (System.currentTimeMillis() - start) + "ms)");
        System.out.println(bestModel.toString(variablesNames));
        ImageIO.write(bestModel.getImage(variablesNames), extension, outPutFile);
    } catch (IOException e) {
        System.out.println("I/O error while loading csv file");
        e.printStackTrace();
    }
}

From source file:demo.RunDot.java

License:Open Source License

/**
 * @param args//  w  ww  .  j a v a2  s . c o m
 */
public static void main(String[] args) {
    if (args.length != 3) {
        System.out.println("Usage:\tjava -Xmx1g -jar Chordalysis.jar dataFile pvalue dotOutputFile");
        System.out.println("Example:\tjava -Xmx1g -jar Chordalysis.jar dataset.csv 0.05 graph.dot");
        System.out.println("\nNote:\t'1g' means that you authorize 1GB of memory. "
                + "\nNote:\tIt should be adjusted depending upon the size of your data set (mostly required to load the data set).");
        return;
    }
    System.out.println();
    CSVLoader loader = new CSVLoader();
    File csvFile = new File(args[0]);
    if (!csvFile.exists()) {
        System.out.println("The file doesn't exist");
        return;
    } else {
        System.out.println("Info:\tUsing the dataset file " + csvFile.getAbsolutePath());
    }

    double pValue = Double.valueOf(args[1]);
    if (pValue <= 0 || 1 <= pValue) {
        System.out.println("The p-value should be between 0 and 1 excluded. ");
        return;
    } else {
        System.out.println("Info:\tUsing p=" + pValue);
    }

    File outPutFile = new File(args[2]);
    String[] splitted = outPutFile.getName().split("\\.");
    if (splitted.length < 2) {
        System.out.println("The image output file should declare a \".dot\" extension");
        return;
    }

    try {
        loader.setFile(csvFile);
        loader.setNominalAttributes("first-last");
        Instances instances = loader.getDataSet();
        String[] variablesNames = new String[instances.numAttributes()];
        for (int i = 0; i < variablesNames.length; i++) {
            variablesNames[i] = instances.attribute(i).name();
        }
        long start = System.currentTimeMillis();

        ChordalysisModelling modeller = new ChordalysisModelling(pValue);
        modeller.buildModel(instances);
        DecomposableModel bestModel = modeller.getModel();

        System.out
                .println("The model selected is: (selected in " + (System.currentTimeMillis() - start) + "ms)");
        System.out.println(bestModel.toString(variablesNames));
        bestModel.exportDOT(outPutFile, variablesNames);
        System.out.println(
                "DOT file exported - note that the variables with no neighbors won't be included in the graph");
    } catch (IOException e) {
        System.out.println("I/O error while loading csv file");
        e.printStackTrace();
    }
}

From source file:demo.RunGUI.java

License:Open Source License

/**
 * @param args/*  ww w .  j a v  a  2s  .  c  o  m*/
 */
public static void main(String[] args) {
    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV file", "csv");
    chooser.setFileFilter(filter);
    int returnVal = chooser.showOpenDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
    }
    CSVLoader loader = new CSVLoader();
    File csvFile = chooser.getSelectedFile();
    if (!csvFile.exists()) {
        System.out.println("The file doesn't exist");
        return;
    }

    double pValue = Double.valueOf(JOptionPane.showInputDialog("Desired p-value ]0,1[", 0.05));
    if (pValue <= 0 || 1 <= pValue) {
        System.out.println("The p-value should be between 0 and 1 excluded. ");
        return;
    }
    try {
        loader.setFile(csvFile);
        loader.setNominalAttributes("first-last");
        Instances instances = loader.getDataSet();
        String[] variablesNames = new String[instances.numAttributes()];
        for (int i = 0; i < variablesNames.length; i++) {
            variablesNames[i] = instances.attribute(i).name();
        }

        ChordalysisModelling modeller = new ChordalysisModelling(pValue);
        modeller.buildModel(instances);
        DecomposableModel bestModel = modeller.getModel();
        System.out.println("The model selected is:");
        System.out.println(bestModel.toString(variablesNames));
        bestModel.display(variablesNames);
    } catch (IOException e) {
        System.out.println("I/O error while loading csv file");
        e.printStackTrace();
    }

}

From source file:demo.RunGUIProof.java

License:Open Source License

/**
 * @param args/*  w  w w .j  a  v a2 s  .  c  o  m*/
 */
public static void main(String[] args) {
    JOptionPane.showMessageDialog(null, introductionMessage, "Chordalysis", JOptionPane.INFORMATION_MESSAGE);

    int result = JOptionPane.showOptionDialog(null, new JTextArea(agreeCitation), "Reference",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (result == JOptionPane.NO_OPTION || result == JOptionPane.CLOSED_OPTION) {
        JOptionPane.showMessageDialog(null,
                "Chordalysis will now stop, because you do not want to reference its source. ", "Chordalysis",
                JOptionPane.WARNING_MESSAGE);
        System.exit(0);
    }

    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV file", "csv");
    chooser.setFileFilter(filter);
    int returnVal = chooser.showOpenDialog(null);
    File csvFile = null;
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        csvFile = chooser.getSelectedFile();
        System.out.println("You chose to open: " + csvFile);
    } else {
        JOptionPane.showMessageDialog(null, noFileSelectedMessage, "Chordalysis", JOptionPane.ERROR_MESSAGE);
        return;
    }
    CSVLoader loader = new CSVLoader();
    if (!csvFile.exists()) {
        JOptionPane.showMessageDialog(null, noFileMessage, "Chordalysis", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    double pValue = -1;
    while (pValue <= 0 || 1 <= pValue) {
        pValue = Double.valueOf(JOptionPane.showInputDialog("Desired p-value (between 0 and 1)", 0.05));
        if (pValue <= 0 || 1 <= pValue) {
            JOptionPane.showMessageDialog(null, incorrectPValueMessage, "Chordalysis",
                    JOptionPane.WARNING_MESSAGE);
        }
    }

    filter = new FileNameExtensionFilter("PNG or DOT or CSV file or DNE file", "png", "dot", "csv", "dne");
    chooser = new JFileChooser();
    chooser.setFileFilter(filter);
    chooser.setDialogTitle("Where to save the graph?");
    chooser.setSelectedFile(new File(csvFile.getAbsolutePath() + ".png"));
    returnVal = chooser.showSaveDialog(null);
    File graphFile = null;
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        graphFile = chooser.getSelectedFile();
        System.out.println("You chose to save the graph to: " + graphFile.getAbsolutePath());
    } else {
        JOptionPane.showMessageDialog(null, noFileSelectedMessage, "Chordalysis", JOptionPane.ERROR_MESSAGE);
        return;
    }

    try {
        loader.setFile(csvFile);

        returnVal = JOptionPane.showConfirmDialog(null, "Are all of your attribute nominal?", "Chordalysis",
                JOptionPane.YES_NO_OPTION);
        if (returnVal == JOptionPane.YES_OPTION) {
            loader.setNominalAttributes("first-last");
        }

        Instances instances = loader.getDataSet();

        String cols = "";
        for (int i = 0; i < instances.numAttributes(); i++) {
            Attribute att = instances.attribute(i);
            if (!att.isNominal()) {
                cols += (i + 1) + ",";
            }
        }
        if (!cols.isEmpty()) {
            cols = cols.substring(0, cols.length() - 1);
            String message = "Some atributes are not nominal (number " + cols
                    + "), please wait during discretization. ";
            JOptionPane.showMessageDialog(null, message, "Chordalysis", JOptionPane.INFORMATION_MESSAGE);
            Discretize discretizer = new Discretize(cols);
            discretizer.setUseEqualFrequency(true);
            discretizer.setBins(3);
            discretizer.setIgnoreClass(true);
            discretizer.setInputFormat(instances);
            instances = Filter.useFilter(instances, discretizer);
            JOptionPane.showMessageDialog(null, "Discretization is now finished.", "Chordalysis",
                    JOptionPane.INFORMATION_MESSAGE);
        }

        String[] variablesNames = new String[instances.numAttributes()];
        String[][] outcomes = new String[instances.numAttributes()][];
        for (int i = 0; i < variablesNames.length; i++) {
            variablesNames[i] = instances.attribute(i).name();
            outcomes[i] = new String[instances.attribute(i).numValues()];
            for (int j = 0; j < outcomes[i].length; j++) {
                outcomes[i][j] = instances.attribute(i).value(j);
            }
        }

        ChordalysisModelling modeller = new ChordalysisModelling(pValue);
        modeller.buildModel(instances);
        DecomposableModel bestModel = modeller.getModel();
        JOptionPane.showMessageDialog(null, new JTextArea("Chordalysis has now finished analysing your data. "
                + "\nIf you found something useful, please reference Chordalysis as"
                + "\n\t- F. Petitjean, G.I. Webb and A. Nicholson, Scaling log-linear analysis to high-dimensional data, ICDM 2013"
                + "\n\t- F. Petitjean and G.I. Webb, Scaling log-linear analysis to datasets with thousands of variables, SDM 2015"
                + "\n\nYou can find the output file at: '" + graphFile.getAbsolutePath() + "'"), "Citation",
                JOptionPane.INFORMATION_MESSAGE);
        System.out.println("The model selected is:");
        System.out.println(bestModel.toString(variablesNames));
        if (graphFile.getName().endsWith("dot")) {
            bestModel.exportDOT(graphFile, variablesNames);
        } else if (graphFile.getName().endsWith("png")) {
            ImageIO.write(bestModel.getImage(variablesNames), "png", graphFile);
        } else if (graphFile.getName().endsWith("dne")) {
            bestModel.exportBNNetica(graphFile, variablesNames, outcomes);
            bestModel.exportDOT(new File(graphFile.getAbsolutePath() + ".dot"), variablesNames);
            ImageIO.write(bestModel.getImage(variablesNames), "png",
                    new File(graphFile.getAbsolutePath() + ".png"));
            bestModel.saveAssociations(variablesNames, new File(graphFile.getAbsolutePath() + ".csv"));
        } else {
            bestModel.saveAssociations(variablesNames, graphFile);
        }

    } catch (IOException e) {
        JOptionPane.showMessageDialog(null,
                "The file '" + csvFile.getAbsolutePath() + "'\ncannot be read properly.",
                "Error while reading file", JOptionPane.ERROR_MESSAGE);
        System.out.println("I/O error while loading csv file");
        e.printStackTrace();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error:" + e.getMessage(), "Chordalysis",
                JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
    }

}

From source file:sentinets.Prediction.java

License:Open Source License

public int setInstances(String inputFile) {
    //String[] nominalVals =  {"42:positive,neutral,negative"};
    String[] nominalVals = { CLASSINDEX + ":" + StringUtils.join(classNames, ",") };
    original = null;/*from  w  w  w.jav  a 2 s  . c om*/
    try {
        System.out.println("[In Prediction] Loading instances. ");
        CSVLoader csvSource = new CSVLoader();
        csvSource.setSource(new File(inputFile));
        csvSource.setFieldSeparator("\t");
        csvSource.setNominalAttributes(CLASSINDEX + "");
        csvSource.setStringAttributes(stringAttr);
        csvSource.setNominalLabelSpecs(nominalVals);
        original = csvSource.getDataSet();
        unlabled = original;
        classProbIndex = original.numAttributes() - 1;
        //System.out.println(unlabled.toSummaryString());
        Remove r = new Remove();
        //r.setAttributeIndices("3-4,6,10-12,14");
        if (classifierType == MODELTYPE.SENTIMENT || classifierType == MODELTYPE.SENTIMENT_WORD
                || classifierType == MODELTYPE.CUSTOM) {
            if (showProbability) {
                /*
                Add afilter;
                afilter = new Add();
                afilter.setAttributeName("last");
                afilter.setAttributeName("prediction_prob");
                afilter.setInputFormat(original);
                original = Filter.useFilter(original, afilter);
                classProbIndex = original.numAttributes()-1;*/
            }
            if (classifierType == MODELTYPE.SENTIMENT) {
                r.setAttributeIndices("3,4,6,8,10-12,14,42,43,45-last");
                System.out.println("Filtering instances for SENTIMENT");
            } else if (classifierType == MODELTYPE.SENTIMENT_WORD || classifierType == MODELTYPE.CUSTOM) {
                r.setAttributeIndices(removeAttr);
                System.out.println("Filtering instances for SENTIMENT WORD");
            }
        }
        //r.setAttributeIndices("3-4,6,10-12,14,40-41,43-last");
        r.setInputFormat(unlabled);
        unlabled = Remove.useFilter(unlabled, r);
        //System.out.println(unlabled.toSummaryString());
        r = new Remove();
        //System.out.println(unlabled.toSummaryString());

    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return 1;
    } catch (IOException e) {
        e.printStackTrace();
        return 2;
    } catch (Exception e) {
        e.printStackTrace();
        return 3;
    }
    int cIdx = unlabled.numAttributes() - 1;
    unlabled.setClassIndex(cIdx);
    System.out.println(
            "Class Attribute is: " + unlabled.classAttribute() + " at index: " + unlabled.classIndex());
    return 0;
}

From source file:sentinets.SentiNets.java

License:Open Source License

public void setInstances(String inputFile) {
    String[] nominalVals = { "15:e,p", "16:s,na_ns" };
    original = null;/*from w ww  . j a  va 2  s .  c  om*/
    try {
        CSVLoader csvSource = new CSVLoader();
        csvSource.setSource(new File(inputFile));
        csvSource.setFieldSeparator("\t");
        csvSource.setNominalAttributes("15-16");
        csvSource.setStringAttributes("3,4,6,8,10-12,14");
        csvSource.setNominalLabelSpecs(nominalVals);
        original = csvSource.getDataSet();
        unlabled = original;
        //System.out.println(unlabled.toSummaryString());
        Remove r = new Remove();
        r.setAttributeIndices("3-4,6,10-12,14");
        r.setInputFormat(unlabled);
        unlabled = Remove.useFilter(unlabled, r);
        //System.out.println(unlabled.toSummaryString());
        r = new Remove();
        if (classifierType == E_P) {
            System.out.println("Filtering instances for E_P");
            r.setAttributeIndices("9");
            r.setInputFormat(unlabled);
            unlabled = Remove.useFilter(unlabled, r);
        } else if (classifierType == S_NS) {
            System.out.println("Filtering instances for S_NS");
            r.setAttributeIndices("8");
            r.setInputFormat(unlabled);
            unlabled = Remove.useFilter(unlabled, r);
        }
        //System.out.println(unlabled.toSummaryString());

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    int cIdx = unlabled.numAttributes() - 1;
    unlabled.setClassIndex(cIdx);
}

From source file:sentinets.TrainModel.java

License:Open Source License

public void setInstances(String inputFile) {
    String[] nominalVals = { "42:positive,negative,neutral" };
    ins = null;//from   w w  w  .  ja v a2 s  .  c o  m
    try {
        CSVLoader csvSource = new CSVLoader();
        csvSource.setSource(new File(inputFile));
        csvSource.setFieldSeparator("\t");
        csvSource.setNominalAttributes("15-16");
        csvSource.setStringAttributes("3,4,6,8,10-12,14");
        csvSource.setNominalLabelSpecs(nominalVals);
        ins = csvSource.getDataSet();
        Remove r = new Remove();
        r.setAttributeIndices("3-4,6,8,10-12,14,40-41");
        r.setInputFormat(ins);
        ins = Remove.useFilter(ins, r);
        //System.out.println(unlabled.toSummaryString());
        r = new Remove();
        System.out.println(ins.toSummaryString());

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    int cIdx = ins.numAttributes() - 1;
    ins.setClassIndex(cIdx);
}