Class ArffParser
- java.lang.Object
-
- smile.data.parser.ArffParser
-
public class ArffParser extends java.lang.ObjectWeka ARFF (attribute relation file format) file parser. ARFF is an ASCII text file format that is essentially a CSV file with a header that describes the meta-data. ARFF was developed for use in the Weka machine learning software.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 Summary
Constructors Constructor and Description ArffParser()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Attribute[]getAttributes(java.io.File file)Returns the attribute set of given file.static Attribute[]getAttributes(java.io.InputStream stream)Returns the attribute set of given stream.static Attribute[]getAttributes(java.lang.String path)Returns the attribute set of given file.static Attribute[]getAttributes(java.net.URI uri)Returns the attribute set of given URI.intgetResponseIndex()Returns the column index (starting at 0) of dependent/response variable.AttributeDatasetparse(java.io.File file)Parse a dataset from given file.AttributeDatasetparse(java.io.InputStream stream)Parse a dataset from given stream.AttributeDatasetparse(java.lang.String path)Parse a dataset from given file.AttributeDatasetparse(java.net.URI uri)Parse a dataset from given URI.ArffParsersetResponseIndex(int index)Sets the column index (starting at 0) of dependent/response variable.
-
-
-
Method Detail
-
getResponseIndex
public int getResponseIndex()
Returns the column index (starting at 0) of dependent/response variable.
-
setResponseIndex
public ArffParser setResponseIndex(int index)
Sets the column index (starting at 0) of dependent/response variable.
-
getAttributes
public static Attribute[] getAttributes(java.net.URI uri) throws java.io.IOException, java.text.ParseException
Returns the attribute set of given URI.- Throws:
java.io.IOExceptionjava.text.ParseException
-
getAttributes
public static Attribute[] getAttributes(java.lang.String path) throws java.io.IOException, java.text.ParseException
Returns the attribute set of given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
getAttributes
public static Attribute[] getAttributes(java.io.File file) throws java.io.IOException, java.text.ParseException
Returns the attribute set of given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
getAttributes
public static Attribute[] getAttributes(java.io.InputStream stream) throws java.io.IOException, java.text.ParseException
Returns the attribute set of given stream.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public AttributeDataset parse(java.net.URI uri) throws java.io.IOException, java.text.ParseException
Parse a dataset from given URI.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public AttributeDataset parse(java.lang.String path) throws java.io.IOException, java.text.ParseException
Parse a dataset from given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public AttributeDataset parse(java.io.File file) throws java.io.IOException, java.text.ParseException
Parse a dataset from given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public AttributeDataset parse(java.io.InputStream stream) throws java.io.IOException, java.text.ParseException
Parse a dataset from given stream.- Throws:
java.io.IOExceptionjava.text.ParseException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG