|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectclassifier.LibSvm
public class LibSvm
Implementation of the SvmInterface interface for the libsvm (http://www.csie.ntu.edu.tw/~cjlin/libsvm/) implementation of the SMO algorithm. This class just translates the necessary commands into methodcalls that are understandable by the java implementation of libsvm.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface classifier.Classifier |
---|
Classifier.DATA_TYPE |
Constructor Summary | |
---|---|
LibSvm(org.apache.log4j.Logger logger,
ClassificationAction ca)
|
Method Summary | |
---|---|
void |
applyAttributeFilter(java.util.List<java.lang.Integer> attributeFilter,
int featureNumberFilter,
java.io.File toBeFilteredFile)
After having used featureselection to get a filter, this filter can be used to change the featurefiles in order to optimize the svms. |
boolean |
buildClassifier()
This method builds an SVM model file from a file with trainingexamples. |
java.lang.Double |
classify_single_instance_fast(double[] features)
|
java.lang.String |
classify_single_instance(java.lang.String instance)
|
void |
classify(java.lang.String testFile,
java.lang.String outputClassification)
Use the trained (or untrained, the modelfile must be set before though) SVM to classify data, and write the output to an outputfile |
CrossValidationResult |
crossValidate(int n,
int maxPosTrain,
int maxNegTrain)
Performs a crossvalidation of trainingfile. |
java.lang.String |
generateFeatureString(java.util.List<java.lang.Double> data,
Classifier.DATA_TYPE dataType)
Creates a string of features for only one featurevector |
java.lang.String |
getFileExtension()
|
java.lang.String |
getModelFile()
|
int[] |
getPosNegExamplesInFile(java.io.File file)
Returns the amount of positive and negative examples in a trainingfile. |
double |
getSigmoid_A()
|
double |
getSigmoid_B()
|
weka.core.Instances |
getTrainingFileInstances()
|
boolean |
loadClassifier()
Sets the modelfile, and - dependend on the implementation - there may be an attempt to build the SVM from this modelfile. |
boolean |
loadClassifier(java.lang.String svmFile)
|
java.io.File |
mergeFeatureFiles(java.io.File tempFilePositive,
java.io.File tempFileNegative)
Merges the featurefiles (one with positive training features, one with negative training features), in order to make the actual training file. |
java.util.List<ValPosCombination> |
performAttributeEvaluation(boolean sort,
weka.attributeSelection.AttributeEvaluator evaluator)
Performs feature selection by evaluating different attributes. |
java.lang.String[] |
prepareCrossvalidationCommand(int fold,
java.lang.String fileIn,
java.lang.String fileOut)
Creates an array with string values, to be parsed by svm_train from the libsvm package. |
java.lang.String[] |
prepareTrainingCommand(java.lang.String fileIn,
java.lang.String fileOut)
Creates an array with string values, to be parsed by svm_train from the libsvm package. |
void |
setModelFile(java.lang.String svmModelFile)
|
void |
setOptions(ClassifierOptions options)
|
void |
setSigmoid_A(double sigmoid_A)
|
void |
setSigmoid_B(double sigmoid_B)
|
void |
setSVMOptions(SVMOptions svm_options)
Changes the options for the SVM itself (mainly the kernel function) |
java.lang.String |
to_genomeview_output(int id,
java.lang.Double distance,
int funsite_start,
int funsite_stop,
java.lang.String classification_name)
|
java.lang.String |
to_splice_machine_output(java.lang.Double distance,
int splicesite,
int increase,
java.lang.String classification_name)
|
java.lang.String |
to_splice_machine_output(java.lang.String classification_result,
int splicesite,
int increase,
java.lang.String classification_name)
|
java.io.File |
writeTemporaryFeatureData(java.lang.String tempFileName,
boolean forward_strand,
java.util.List<java.util.List<java.lang.Double>> data,
Classifier.DATA_TYPE dataType)
This method writes the temporary featuredata (being all the features extracted from 1 sequence, each feature in a different list) to a file. |
java.io.File |
writeTemporaryFeatureData(java.lang.String tempFileName,
java.util.List<java.util.List<java.lang.Double>> data,
Classifier.DATA_TYPE dataType)
This method writes the temporary featuredata (being all the features extracted from 1 sequence, each feature in a different list) to a file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LibSvm(org.apache.log4j.Logger logger, ClassificationAction ca)
Method Detail |
---|
public java.lang.String getFileExtension()
getFileExtension
in interface Classifier
public CrossValidationResult crossValidate(int n, int maxPosTrain, int maxNegTrain)
crossValidate
in interface Classifier
n
- The fold of the crossvalidation. Frequent numbers are 2,5 and 10maxPosTrain
- The maximum amount of positive training examples during the
training phase of the crossvalidation.maxNegTrain
- The maximum amount of negative training examples during the
training phase of the crossvalidation.
public java.lang.String[] prepareCrossvalidationCommand(int fold, java.lang.String fileIn, java.lang.String fileOut)
prepareCrossvalidationCommand
in interface Classifier
fold
- The fold of the crossvalidation
public java.lang.String[] prepareTrainingCommand(java.lang.String fileIn, java.lang.String fileOut)
prepareTrainingCommand
in interface Classifier
fold
- The fold of the crossvalidation
public boolean buildClassifier()
buildClassifier
in interface Classifier
public java.io.File mergeFeatureFiles(java.io.File tempFilePositive, java.io.File tempFileNegative)
mergeFeatureFiles
in interface Classifier
tempFilePositive
- The name of the file with features for positive trainingtempFileNegative
- The name of the file with features for negative training
public java.io.File writeTemporaryFeatureData(java.lang.String tempFileName, boolean forward_strand, java.util.List<java.util.List<java.lang.Double>> data, Classifier.DATA_TYPE dataType)
writeTemporaryFeatureData
in interface Classifier
tempFileName
- The name of the file to which the data should be written.data
- The featuredatadataType
- The type of data (see enum in this interface)
public java.lang.String generateFeatureString(java.util.List<java.lang.Double> data, Classifier.DATA_TYPE dataType)
generateFeatureString
in interface Classifier
data
- The featuredatadataType
- The datatype (positive,negative,unclassified)
public java.io.File writeTemporaryFeatureData(java.lang.String tempFileName, java.util.List<java.util.List<java.lang.Double>> data, Classifier.DATA_TYPE dataType)
writeTemporaryFeatureData
in interface Classifier
tempFileName
- The name of the file to which the data should be written.data
- The featuredatadataType
- The type of data (see enum in this interface)
public boolean loadClassifier()
loadClassifier
in interface Classifier
modelFile
- The name of the modelfilepublic boolean loadClassifier(java.lang.String svmFile)
loadClassifier
in interface Classifier
public void classify(java.lang.String testFile, java.lang.String outputClassification)
classify
in interface Classifier
testFile
- The name of the file that contains the extracted features,
outputdirectory is supposed to be in the filename.outputFile
- The name of the outputfile, outputdirectory is
supposed to be in the filename.public java.lang.String classify_single_instance(java.lang.String instance)
classify_single_instance
in interface Classifier
public java.lang.Double classify_single_instance_fast(double[] features)
classify_single_instance_fast
in interface Classifier
public java.lang.String to_splice_machine_output(java.lang.String classification_result, int splicesite, int increase, java.lang.String classification_name)
to_splice_machine_output
in interface Classifier
public java.lang.String to_splice_machine_output(java.lang.Double distance, int splicesite, int increase, java.lang.String classification_name)
to_splice_machine_output
in interface Classifier
public java.lang.String to_genomeview_output(int id, java.lang.Double distance, int funsite_start, int funsite_stop, java.lang.String classification_name)
to_genomeview_output
in interface Classifier
public java.util.List<ValPosCombination> performAttributeEvaluation(boolean sort, weka.attributeSelection.AttributeEvaluator evaluator)
performAttributeEvaluation
in interface Classifier
sort
- Whether to sort the resulting valposcombinations according to their valuesevaluator
- The evaluator used for performing the evaluation of the attributes
public weka.core.Instances getTrainingFileInstances()
getTrainingFileInstances
in interface Classifier
public void applyAttributeFilter(java.util.List<java.lang.Integer> attributeFilter, int featureNumberFilter, java.io.File toBeFilteredFile)
applyAttributeFilter
in interface Classifier
attributeFilter
- The filter: this is an array with the numbers of the attributes
that MUST be preserved.public void setSVMOptions(SVMOptions svm_options)
svm_options
- The new options for the kernel functionpublic void setOptions(ClassifierOptions options)
setOptions
in interface Classifier
public int[] getPosNegExamplesInFile(java.io.File file)
getPosNegExamplesInFile
in interface Classifier
file
- The trainingfile
public java.lang.String getModelFile()
getModelFile
in interface Classifier
public void setModelFile(java.lang.String svmModelFile)
setModelFile
in interface Classifier
public double getSigmoid_A()
getSigmoid_A
in interface Classifier
public void setSigmoid_A(double sigmoid_A)
setSigmoid_A
in interface Classifier
public double getSigmoid_B()
getSigmoid_B
in interface Classifier
public void setSigmoid_B(double sigmoid_B)
setSigmoid_B
in interface Classifier
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |