Example usage for weka.distributed CSVToARFFHeaderMapTask parseRowOnly

List of usage examples for weka.distributed CSVToARFFHeaderMapTask parseRowOnly

Introduction

In this page you can find the example usage for weka.distributed CSVToARFFHeaderMapTask parseRowOnly.

Prototype

public String[] parseRowOnly(String row) throws IOException 

Source Link

Document

Just parse a row.

Usage

From source file:distributed.core.DistributedJob.java

License:Open Source License

/**
 * Utility method to parse an Instance out of a row of CSV data.
 *
 * @param row the row of data to convert to an Instance
 * @param rowHelper the CSVToARFFHeaderMap task to use for parsing purposes
 * @param headerNoSummary the header of the data (sans summary attributes)
 *          that contains attribute information for the instance
 * @param setStringVals true if the values of string attributes are to be set
 *          on the header (rather than accumulate in the header).
 * @return an Instance//from   w  w  w .  j  av  a 2s . c  o  m
 * @throws IOException if a problem occurs
 */
public static Instance parseInstance(String row, CSVToARFFHeaderMapTask rowHelper, Instances headerNoSummary,
        boolean setStringVals) throws IOException {
    Instance result = null;

    String[] parsed = rowHelper.parseRowOnly(row);
    if (parsed.length != headerNoSummary.numAttributes()) {
        throw new IOException("Parsed a row that contains a different number of values than "
                + "there are attributes in the training ARFF header: " + row);
    }

    try {
        result = rowHelper.makeInstance(headerNoSummary, setStringVals, parsed);
    } catch (Exception ex) {
        throw new IOException(ex);
    }

    return result;
}