public class SVMLightLoader extends AbstractFileLoader implements BatchConverter, URLSourcedLoader
Loader,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
FILE_EXTENSION
the file extension.
|
protected Vector |
m_Buffer
the buffer of the rows read so far.
|
protected Reader |
m_sourceReader
The reader for the source file.
|
protected String |
m_URL
the url.
|
FILE_EXTENSION_COMPRESSED, m_env, m_File, m_sourceFile, m_structure, m_useRelativePathm_retrievalBATCH, INCREMENTAL, NONE| Constructor and Description |
|---|
SVMLightLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected Attribute |
determineClassAttribute()
Determines the class attribute, either a binary +1/-1 or numeric attribute.
|
protected int |
determineNumAttributes(double[] values,
int num)
determines the number of attributes, if the number of attributes in the
given row is greater than the current amount then this number will be
returned, otherwise the current number.
|
Instances |
getDataSet()
Return the full data set.
|
String |
getFileDescription()
Returns a description of the file type.
|
String |
getFileExtension()
Get the file extension used for svm light files.
|
String[] |
getFileExtensions()
Gets all the file extensions used for this type of file.
|
Instance |
getNextInstance(Instances structure)
SVMLightLoader is unable to process a data set incrementally.
|
String |
getRevision()
Returns the revision string.
|
Instances |
getStructure()
Determines and returns (if possible) the structure (internally the
header) of the data set as an empty set of instances.
|
String |
globalInfo()
Returns a string describing this Loader.
|
static void |
main(String[] args)
Main method.
|
void |
reset()
Resets the Loader ready to read a new data set.
|
String |
retrieveURL()
Return the current url.
|
void |
setSource(InputStream in)
Resets the Loader object and sets the source of the data set to be
the supplied InputStream.
|
void |
setSource(URL url)
Resets the Loader object and sets the source of the data set to be
the supplied url.
|
void |
setURL(String url)
Set the url to load from.
|
protected double[] |
svmlightToArray(String row)
turns a svm light row into a double array with the class as the last
entry.
|
getUseRelativePath, makeOptionStr, retrieveFile, runFileLoader, setEnvironment, setFile, setSource, setUseRelativePath, useRelativePathTipTextgetRetrieval, setRetrievalpublic static String FILE_EXTENSION
protected String m_URL
protected transient Reader m_sourceReader
protected Vector m_Buffer
public String globalInfo()
public String getFileExtension()
getFileExtension in interface FileSourcedConverterpublic String[] getFileExtensions()
getFileExtensions in interface FileSourcedConverterpublic String getFileDescription()
getFileDescription in interface FileSourcedConverterpublic void reset()
throws IOException
reset in interface Loaderreset in class AbstractFileLoaderIOException - if something goes wrongpublic void setSource(URL url) throws IOException
url - the source url.IOException - if an error occurspublic void setURL(String url) throws IOException
setURL in interface URLSourcedLoaderurl - the url to load fromIOException - if the url can't be set.public String retrieveURL()
retrieveURL in interface URLSourcedLoaderpublic void setSource(InputStream in) throws IOException
setSource in interface LoadersetSource in class AbstractLoaderin - the source InputStream.IOException - if initialization of reader fails.protected double[] svmlightToArray(String row) throws Exception
row - the row to turn into a double arrayException - if a parsing error is encounteredprotected int determineNumAttributes(double[] values,
int num)
throws Exception
values - the parsed valuesnum - the current number of attributesException - if parsing failsprotected Attribute determineClassAttribute()
public Instances getStructure() throws IOException
getStructure in interface LoadergetStructure in class AbstractLoaderIOException - if an error occurspublic Instances getDataSet() throws IOException
getDataSet in interface LoadergetDataSet in class AbstractLoaderIOException - if there is no source or parsing failspublic Instance getNextInstance(Instances structure) throws IOException
getNextInstance in interface LoadergetNextInstance in class AbstractLoaderstructure - ignoredIOException - always. SVMLightLoader is unable to process a
data set incrementally.public String getRevision()
getRevision in interface RevisionHandlerpublic static void main(String[] args)
args - should contain the name of an input file.Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.