public class Arff
extends java.lang.Object
implements java.lang.AutoCloseable
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 |
|---|
Arff(java.nio.file.Path path)
Constructor.
|
Arff(java.nio.file.Path path,
java.nio.charset.Charset charset)
Constructor.
|
Arff(java.io.Reader reader)
Constructor.
|
Arff(java.lang.String path)
Constructor.
|
Arff(java.lang.String path,
java.nio.charset.Charset charset)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.lang.String |
name()
Returns the name of relation.
|
smile.data.DataFrame |
read()
Reads all the records.
|
smile.data.DataFrame |
read(int limit)
Reads a limited number of records.
|
smile.data.type.StructType |
schema()
Returns the attribute set of given stream.
|
static void |
write(smile.data.DataFrame df,
java.nio.file.Path path,
java.lang.String relation)
Writes the data frame to an ARFF file.
|
public Arff(java.lang.String path)
throws java.io.IOException,
java.text.ParseException,
java.net.URISyntaxException
java.io.IOExceptionjava.text.ParseExceptionjava.net.URISyntaxExceptionpublic Arff(java.lang.String path,
java.nio.charset.Charset charset)
throws java.io.IOException,
java.text.ParseException,
java.net.URISyntaxException
java.io.IOExceptionjava.text.ParseExceptionjava.net.URISyntaxExceptionpublic Arff(java.nio.file.Path path)
throws java.io.IOException,
java.text.ParseException
java.io.IOExceptionjava.text.ParseExceptionpublic Arff(java.nio.file.Path path,
java.nio.charset.Charset charset)
throws java.io.IOException,
java.text.ParseException
java.io.IOExceptionjava.text.ParseExceptionpublic Arff(java.io.Reader reader)
throws java.io.IOException,
java.text.ParseException
java.io.IOExceptionjava.text.ParseExceptionpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.lang.String name()
public smile.data.type.StructType schema()
public smile.data.DataFrame read()
throws java.io.IOException,
java.text.ParseException
java.io.IOExceptionjava.text.ParseExceptionpublic smile.data.DataFrame read(int limit)
throws java.io.IOException,
java.text.ParseException
limit - reads a limited number of records.java.io.IOExceptionjava.text.ParseExceptionpublic static void write(smile.data.DataFrame df,
java.nio.file.Path path,
java.lang.String relation)
throws java.io.IOException
df - the data frame.path - the file path.relation - the relation name of ARFF.java.io.IOException