public class LibSVMLoader extends AbstractFileLoader implements BatchConverter, URLSourcedLoader
Loader,
Serialized FormLoader.StructureNotReadyException| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FILE_EXTENSION
the file extension.
|
protected java.util.Vector<double[]> |
m_Buffer
the buffer of the rows read so far.
|
protected java.io.Reader |
m_sourceReader
The reader for the source file.
|
protected java.lang.String |
m_URL
the url.
|
FILE_EXTENSION_COMPRESSED, m_env, m_File, m_sourceFile, m_structure, m_useRelativePathm_retrievalBATCH, INCREMENTAL, NONE| Constructor and Description |
|---|
LibSVMLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
determineNumAttributes(java.lang.String row,
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.
|
java.lang.String |
getFileDescription()
Returns a description of the file type.
|
java.lang.String |
getFileExtension()
Get the file extension used for libsvm files.
|
java.lang.String[] |
getFileExtensions()
Gets all the file extensions used for this type of file.
|
Instance |
getNextInstance(Instances structure)
LibSVmLoader is unable to process a data set incrementally.
|
java.lang.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.
|
java.lang.String |
globalInfo()
Returns a string describing this Loader.
|
protected double[] |
libsvmToArray(java.lang.String row)
turns a libsvm row into a double array with the class as the last entry.
|
static void |
main(java.lang.String[] args)
Main method.
|
void |
reset()
Resets the Loader ready to read a new data set.
|
java.lang.String |
retrieveURL()
Return the current url.
|
void |
setSource(java.io.InputStream in)
Resets the Loader object and sets the source of the data set to be the
supplied InputStream.
|
void |
setSource(java.net.URL url)
Resets the Loader object and sets the source of the data set to be the
supplied url.
|
void |
setURL(java.lang.String url)
Set the url to load from.
|
getUseRelativePath, makeOptionStr, retrieveFile, runFileLoader, setEnvironment, setFile, setSource, setUseRelativePath, useRelativePathTipTextgetRetrieval, setRetrievalpublic static java.lang.String FILE_EXTENSION
protected java.lang.String m_URL
protected transient java.io.Reader m_sourceReader
protected java.util.Vector<double[]> m_Buffer
public java.lang.String globalInfo()
public java.lang.String getFileExtension()
getFileExtension in interface FileSourcedConverterpublic java.lang.String[] getFileExtensions()
getFileExtensions in interface FileSourcedConverterpublic java.lang.String getFileDescription()
getFileDescription in interface FileSourcedConverterpublic void reset()
throws java.io.IOException
reset in interface Loaderreset in class AbstractFileLoaderjava.io.IOException - if something goes wrongpublic void setSource(java.net.URL url)
throws java.io.IOException
url - the source url.java.io.IOException - if an error occurspublic void setURL(java.lang.String url)
throws java.io.IOException
setURL in interface URLSourcedLoaderurl - the url to load fromjava.io.IOException - if the url can't be set.public java.lang.String retrieveURL()
retrieveURL in interface URLSourcedLoaderpublic void setSource(java.io.InputStream in)
throws java.io.IOException
setSource in interface LoadersetSource in class AbstractLoaderin - the source InputStream.java.io.IOException - if initialization of reader fails.protected double[] libsvmToArray(java.lang.String row)
row - the row to turn into a double arrayprotected int determineNumAttributes(java.lang.String row,
int num)
row - row to determine the number of attributes fromnum - the current number of attributespublic Instances getStructure() throws java.io.IOException
getStructure in interface LoadergetStructure in class AbstractLoaderjava.io.IOException - if an error occurspublic Instances getDataSet() throws java.io.IOException
getDataSet in interface LoadergetDataSet in class AbstractLoaderjava.io.IOException - if there is no source or parsing failspublic Instance getNextInstance(Instances structure) throws java.io.IOException
getNextInstance in interface LoadergetNextInstance in class AbstractLoaderstructure - ignoredjava.io.IOException - always. LibSVMLoader is unable to process a data set
incrementally.public java.lang.String getRevision()
getRevision in interface RevisionHandlerpublic static void main(java.lang.String[] args)
args - should contain the name of an input file.