List of usage examples for weka.distributed CSVToARFFHeaderMapTask makeInstanceFromObjectRow
public Instance makeInstanceFromObjectRow(Instances trainingHeader, boolean setStringValues, Object[] row, boolean sparse) throws Exception
From source file:distributed.core.DistributedJob.java
License:Open Source License
/** * Utility method to convert a row of values into an Instance * * @param row the row of data to convert to an Instance * @param rowHelper the configured CSVToARFFHeaderMap task to use for getting * default nominal values from//from w w w. j a v a 2 s . c o m * @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). * @param sparse true if a sparse instance should be created instead of a * dense one * @return an Instance * @throws IOException if a problem occurs */ public static Instance objectRowToInstance(Object[] row, CSVToARFFHeaderMapTask rowHelper, Instances headerNoSummary, boolean setStringVals, boolean sparse) throws IOException { if (row.length != headerNoSummary.numAttributes()) { throw new IOException("The supplied Object[] row contains a different " + "number of values than there are attributes in the supplied " + "ARFF header"); } try { return rowHelper.makeInstanceFromObjectRow(headerNoSummary, setStringVals, row, sparse); } catch (Exception ex) { throw new IOException(ex); } }