类 ConverterUtils.DataSource
java.lang.Object
weka.core.converters.ConverterUtils.DataSource
- 所有已实现的接口:
Serializable
,RevisionHandler
- 封闭类:
- ConverterUtils
public static class ConverterUtils.DataSource
extends Object
implements Serializable, RevisionHandler
Helper class for loading data from files and URLs. Via the ConverterUtils
class it determines which converter to use for loading the data into
memory. If the chosen converter is an incremental one, then the data
will be loaded incrementally, otherwise as batch. In both cases the
same interface will be used (
hasMoreElements
,
nextElement
). Before the
data can be read again, one has to call the reset
method.
The data source can also be initialized with an Instances object, in
order to provide a unified interface to files and already loaded datasets.- 版本:
- $Revision: 6416 $
- 作者:
- FracPete (fracpete at waikato dot ac dot nz)
- 另请参阅:
-
构造器概要
构造器构造器说明DataSource
(InputStream stream) Initializes the datasource with the given input stream.DataSource
(String location) Tries to load the data from the file.DataSource
(Loader loader) Initializes the datasource with the given Loader.DataSource
(Instances inst) Initializes the datasource with the given dataset. -
方法概要
修饰符和类型方法说明returns the full dataset, can be null in case of an error.getDataSet
(int classIndex) returns the full dataset with the specified class index set, can be null in case of an error.returns the determined loader, null if the DataSource was initialized with data alone and not a file/URL.Returns the revision string.returns the structure of the data.getStructure
(int classIndex) returns the structure of the data, with the defined class index.boolean
hasMoreElements
(Instances structure) returns whether there are more Instance objects in the data.static boolean
returns whether the extension of the location is likely to be of ARFF format, i.e., ending in ".arff" or ".arff.gz" (case-insensitive).boolean
returns whether the loader is an incremental one.static void
for testing only - takes a data file as input.nextElement
(Instances dataset) returns the next element and sets the specified dataset, null if none available.static Instances
read
(InputStream stream) convencience method for loading a dataset in batch mode from a stream.static Instances
convencience method for loading a dataset in batch mode.static Instances
convencience method for loading a dataset in batch mode.void
reset()
resets the loader.
-
构造器详细资料
-
DataSource
Tries to load the data from the file. Can be either a regular file or a web location (http://, https://, ftp:// or file://).- 参数:
location
- the name of the file to load- 抛出:
Exception
- if initialization fails
-
DataSource
Initializes the datasource with the given dataset.- 参数:
inst
- the dataset to use
-
DataSource
Initializes the datasource with the given Loader.- 参数:
loader
- the Loader to use
-
DataSource
Initializes the datasource with the given input stream. This stream is always interpreted as ARFF.- 参数:
stream
- the stream to use
-
-
方法详细资料
-
isArff
returns whether the extension of the location is likely to be of ARFF format, i.e., ending in ".arff" or ".arff.gz" (case-insensitive).- 参数:
location
- the file location to check- 返回:
- true if the location seems to be of ARFF format
-
isIncremental
public boolean isIncremental()returns whether the loader is an incremental one.- 返回:
- true if the loader is a true incremental one
-
getLoader
returns the determined loader, null if the DataSource was initialized with data alone and not a file/URL.- 返回:
- the loader used for retrieving the data
-
getDataSet
returns the full dataset, can be null in case of an error.- 返回:
- the full dataset
- 抛出:
Exception
- if resetting of loader fails
-
getDataSet
returns the full dataset with the specified class index set, can be null in case of an error.- 参数:
classIndex
- the class index for the dataset- 返回:
- the full dataset
- 抛出:
Exception
- if resetting of loader fails
-
reset
resets the loader.- 抛出:
Exception
- if resetting fails
-
getStructure
returns the structure of the data.- 返回:
- the structure of the data
- 抛出:
Exception
- if something goes wrong
-
getStructure
returns the structure of the data, with the defined class index.- 参数:
classIndex
- the class index for the dataset- 返回:
- the structure of the data
- 抛出:
Exception
- if something goes wrong
-
hasMoreElements
returns whether there are more Instance objects in the data.- 参数:
structure
- the structure of the dataset- 返回:
- true if there are more Instance objects available
- 另请参阅:
-
nextElement
returns the next element and sets the specified dataset, null if none available.- 参数:
dataset
- the dataset to set for the instance- 返回:
- the next Instance
-
read
convencience method for loading a dataset in batch mode.- 参数:
location
- the dataset to load- 返回:
- the dataset
- 抛出:
Exception
- if loading fails
-
read
convencience method for loading a dataset in batch mode from a stream.- 参数:
stream
- the stream to load the dataset from- 返回:
- the dataset
- 抛出:
Exception
- if loading fails
-
read
convencience method for loading a dataset in batch mode.- 参数:
loader
- the loader to get the dataset from- 返回:
- the dataset
- 抛出:
Exception
- if loading fails
-
main
for testing only - takes a data file as input.- 参数:
args
- the commandline arguments- 抛出:
Exception
- if something goes wrong
-
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 返回:
- the revision
-