|
MaltParser 1.4.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.maltparser.ml.libsvm.Libsvm
public class Libsvm
Implements an interface to the LIBSVM learner (currently the LIBSVM 2.91 is used). More information about LIBSVM can be found at LIBSVM -- A Library for Support Vector Machines.
Nested Class Summary | |
---|---|
static class |
Libsvm.Verbostity
|
Field Summary | |
---|---|
protected boolean |
excludeNullValues
|
protected int |
learnerMode
|
static String |
LIBSVM_VERSION
|
protected String |
name
|
protected int |
numberOfInstances
|
protected InstanceModel |
owner
|
protected String |
pathExternalSVMTrain
|
protected boolean |
saveInstanceFiles
|
Fields inherited from interface org.maltparser.ml.LearningMethod |
---|
BATCH, CLASSIFY |
Constructor Summary | |
---|---|
Libsvm(InstanceModel owner,
Integer learnerMode)
Constructs a LIBSVM learner. |
Method Summary | |
---|---|
void |
addInstance(SingleDecision decision,
FeatureVector featureVector)
|
protected void |
closeInstanceWriter()
|
Map<Integer,Integer> |
createFeatureIdToCountMap(ArrayList<Integer> divideFeatureIndexVector)
|
double |
crossValidate(FeatureVector featureVector,
int nrOfSplits)
This method does a cross validation of the training instances added and return the average score over the nrOfSplit divisions. |
void |
decreaseNumberOfInstances()
|
void |
divideByFeatureSet(Set<Integer> featureIdsToCreateSeparateBranchesForSet,
ArrayList<Integer> divideFeatureIndexVector,
String otherId)
|
protected void |
finalize()
|
void |
finalizeSentence(DependencyStructure dependencyGraph)
|
protected JarEntry |
getConfigFileEntry(String suffix)
|
DependencyParserConfig |
getConfiguration()
Returns the current configuration |
protected File |
getFile(String suffix)
|
protected InputStreamReader |
getInstanceInputStreamReader(String suffix)
|
protected InputStreamReader |
getInstanceInputStreamReaderFromConfigFile(String suffix)
|
protected OutputStreamWriter |
getInstanceOutputStreamWriter(String suffix)
|
BufferedWriter |
getInstanceWriter()
|
int |
getLearnerMode()
|
String |
getLearningMethodName()
|
int |
getNumberOfInstances()
|
InstanceModel |
getOwner()
|
String |
getParamString()
Returns the parameter string for used for configure LIBSVM |
String[] |
getSVMParamStringArray(libsvm.svm_parameter param)
|
void |
increaseNumberOfInstances()
|
protected void |
initParameters(libsvm.svm_parameter param)
Assign a default value to all svm parameters |
protected void |
initSpecialParameters()
|
protected void |
initSvmParam(String paramString)
Initialize the LIBSVM according to the parameter string |
static void |
maltSVMFormat2OriginalSVMFormat(InputStreamReader isr,
OutputStreamWriter osw,
int[] cardinalities)
Converts the instance file (Malt's own SVM format) into the LIBSVM (SVMLight) format. |
void |
moveAllInstances(LearningMethod method,
FeatureFunction divideFeature,
ArrayList<Integer> divideFeatureIndexVector)
|
void |
noMoreInstances()
|
void |
parseParameters(String paramstring,
libsvm.svm_parameter param)
Parses the parameter string. |
boolean |
predict(FeatureVector featureVector,
SingleDecision decision)
|
libsvm.svm_problem |
readProblemMaltSVMFormat(InputStreamReader isr,
int[] cardinalities,
libsvm.svm_parameter param)
Reads an instance file into a svm_problem object according to the Malt-SVM format, which is column fixed format (tab-separated). |
void |
setLearnerMode(int learnerMode)
|
protected void |
setLearningMethodName(String name)
|
protected void |
setNumberOfInstances(int numberOfInstances)
|
protected void |
setOwner(InstanceModel owner)
|
void |
svm_predict_with_kbestlist(libsvm.svm_model model,
libsvm.svm_node[] x,
KBestList kBestList)
|
void |
terminate()
|
String |
toString()
|
String |
toStringParameters(libsvm.svm_parameter param)
Returns a string containing all svm-parameters of interest |
void |
train(FeatureVector featureVector)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String LIBSVM_VERSION
protected InstanceModel owner
protected int learnerMode
protected String name
protected int numberOfInstances
protected boolean saveInstanceFiles
protected boolean excludeNullValues
protected String pathExternalSVMTrain
Constructor Detail |
---|
public Libsvm(InstanceModel owner, Integer learnerMode) throws MaltChainedException
owner
- the guide model ownerlearnerMode
- the mode of the learner TRAIN or CLASSIFY
MaltChainedException
Method Detail |
---|
public void addInstance(SingleDecision decision, FeatureVector featureVector) throws MaltChainedException
addInstance
in interface LearningMethod
MaltChainedException
public void finalizeSentence(DependencyStructure dependencyGraph) throws MaltChainedException
finalizeSentence
in interface LearningMethod
MaltChainedException
public void noMoreInstances() throws MaltChainedException
noMoreInstances
in interface LearningMethod
MaltChainedException
public void train(FeatureVector featureVector) throws MaltChainedException
train
in interface LearningMethod
MaltChainedException
public double crossValidate(FeatureVector featureVector, int nrOfSplits) throws MaltChainedException
LearningMethod
crossValidate
in interface LearningMethod
MaltChainedException
public void moveAllInstances(LearningMethod method, FeatureFunction divideFeature, ArrayList<Integer> divideFeatureIndexVector) throws MaltChainedException
moveAllInstances
in interface LearningMethod
MaltChainedException
public boolean predict(FeatureVector featureVector, SingleDecision decision) throws MaltChainedException
predict
in interface LearningMethod
MaltChainedException
public void terminate() throws MaltChainedException
terminate
in interface LearningMethod
MaltChainedException
public BufferedWriter getInstanceWriter()
getInstanceWriter
in interface LearningMethod
protected void closeInstanceWriter() throws MaltChainedException
MaltChainedException
protected void initSvmParam(String paramString) throws MaltChainedException
paramString
- the parameter string to configure the LIBSVM learner.
MaltChainedException
public String getParamString()
public InstanceModel getOwner()
protected void setOwner(InstanceModel owner)
public int getLearnerMode()
public void setLearnerMode(int learnerMode) throws MaltChainedException
MaltChainedException
public String getLearningMethodName()
public DependencyParserConfig getConfiguration() throws MaltChainedException
MaltChainedException
public int getNumberOfInstances() throws MaltChainedException
MaltChainedException
public void increaseNumberOfInstances()
increaseNumberOfInstances
in interface LearningMethod
public void decreaseNumberOfInstances()
decreaseNumberOfInstances
in interface LearningMethod
protected void setNumberOfInstances(int numberOfInstances)
protected void setLearningMethodName(String name)
protected OutputStreamWriter getInstanceOutputStreamWriter(String suffix) throws MaltChainedException
MaltChainedException
protected InputStreamReader getInstanceInputStreamReader(String suffix) throws MaltChainedException
MaltChainedException
protected InputStreamReader getInstanceInputStreamReaderFromConfigFile(String suffix) throws MaltChainedException
MaltChainedException
protected File getFile(String suffix) throws MaltChainedException
MaltChainedException
protected JarEntry getConfigFileEntry(String suffix) throws MaltChainedException
MaltChainedException
public final libsvm.svm_problem readProblemMaltSVMFormat(InputStreamReader isr, int[] cardinalities, libsvm.svm_parameter param) throws MaltChainedException
isr
- the instance stream reader for the instance filecardinalities
- a array containing the number of distinct values for a particular column.param
- a svm_parameter object
LibsvmException
MaltChainedException
protected void initSpecialParameters() throws MaltChainedException
MaltChainedException
protected void initParameters(libsvm.svm_parameter param) throws MaltChainedException
param
- a svm_parameter object
MaltChainedException
public String toStringParameters(libsvm.svm_parameter param)
param
- a svm_parameter object
public String[] getSVMParamStringArray(libsvm.svm_parameter param)
public void parseParameters(String paramstring, libsvm.svm_parameter param) throws MaltChainedException
paramstring
- the parameter stringparam
- a svm_parameter object
LibsvmException
MaltChainedException
public void svm_predict_with_kbestlist(libsvm.svm_model model, libsvm.svm_node[] x, KBestList kBestList) throws MaltChainedException
MaltChainedException
public static void maltSVMFormat2OriginalSVMFormat(InputStreamReader isr, OutputStreamWriter osw, int[] cardinalities) throws MaltChainedException
isr
- the input stream reader for the source instance fileosw
- the output stream writer for the destination instance filecardinalities
- a vector containing the number of distinct values for a particular column
LibsvmException
MaltChainedException
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public String toString()
toString
in class Object
public void divideByFeatureSet(Set<Integer> featureIdsToCreateSeparateBranchesForSet, ArrayList<Integer> divideFeatureIndexVector, String otherId) throws MaltChainedException
divideByFeatureSet
in interface LearningMethod
MaltChainedException
public Map<Integer,Integer> createFeatureIdToCountMap(ArrayList<Integer> divideFeatureIndexVector) throws MaltChainedException
createFeatureIdToCountMap
in interface LearningMethod
MaltChainedException
|
MaltParser 1.4.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |