List of usage examples for weka.distributed CSVToARFFHeaderMapTask makeInstance
public Instance makeInstance(Instances trainingHeader, boolean setStringValues, String[] parsed) throws Exception
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 ww w. jav a 2s.c om * @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; }