public class ArffParser extends Object
A dataset is firstly described, beginning with the name of the dataset (or the relation in ARFF terminology). Each of the variables (or attribute in ARFF terminology) used to describe the observations is then identified, together with their data type, each definition on a single line. The actual observations are then listed, each on a single line, with fields separated by commas, much like a CSV file.
Missing values in an ARFF dataset are identified using the question mark '?'.
Comments can be included in the file, introduced at the beginning of a line with a '%', whereby the remainder of the line is ignored.
A significant advantage of the ARFF data file over the CSV data file is the meta data information.
Also, the ability to include comments ensure we can record extra information about the data set, including how it was derived, where it came from, and how it might be cited.
| Constructor and Description |
|---|
ArffParser()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static Attribute[] |
getAttributes(File file)
Returns the attribute set of given file.
|
static Attribute[] |
getAttributes(InputStream stream)
Returns the attribute set of given stream.
|
static Attribute[] |
getAttributes(String path)
Returns the attribute set of given file.
|
static Attribute[] |
getAttributes(URI uri)
Returns the attribute set of given URI.
|
int |
getResponseIndex()
Returns the column index (starting at 0) of dependent/response variable.
|
AttributeDataset |
parse(File file)
Parse a dataset from given file.
|
AttributeDataset |
parse(InputStream stream)
Parse a dataset from given stream.
|
AttributeDataset |
parse(String path)
Parse a dataset from given file.
|
AttributeDataset |
parse(URI uri)
Parse a dataset from given URI.
|
void |
setResponseIndex(int index)
Sets the column index (starting at 0) of dependent/response variable.
|
public int getResponseIndex()
public void setResponseIndex(int index)
public static Attribute[] getAttributes(URI uri) throws FileNotFoundException, IOException, ParseException
public static Attribute[] getAttributes(String path) throws FileNotFoundException, IOException, ParseException
public static Attribute[] getAttributes(File file) throws FileNotFoundException, IOException, ParseException
public static Attribute[] getAttributes(InputStream stream) throws IOException, ParseException
IOExceptionParseExceptionpublic AttributeDataset parse(URI uri) throws FileNotFoundException, IOException, ParseException
public AttributeDataset parse(String path) throws FileNotFoundException, IOException, ParseException
public AttributeDataset parse(File file) throws FileNotFoundException, IOException, ParseException
public AttributeDataset parse(InputStream stream) throws IOException, ParseException
IOExceptionParseExceptionCopyright © 2015. All rights reserved.