@ALDAOperator(genericExecutionMode=SWING, level=STANDARD, allowBatchMode=false, shortDescription="Training and cross validation of support vector machines for classifying scratch assays.") public class ScratchAssaySVMTrainer extends MTBOperator
Modifier and Type | Class and Description |
---|---|
static class |
ScratchAssaySVMTrainer.KERNEL_TYPE |
static class |
ScratchAssaySVMTrainer.ScratchOrientation |
static class |
ScratchAssaySVMTrainer.ValidationMethod |
Modifier and Type | Field and Description |
---|---|
private Integer |
C |
private Integer |
degree |
private Integer |
entropyFilterSize |
private String |
error_msg |
(package private) StringBuffer |
falseFileNames |
(package private) StringBuffer |
falseNegativeFileNames |
(package private) StringBuffer |
falsePositiveFileNames |
private int |
fn |
private int |
fp |
private Boolean |
isHorizontal |
private Integer |
k |
private Integer |
maxIter |
private ScratchAssaySVMTrainer.ValidationMethod |
method |
private libsvm.svm_model |
model |
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
negDir |
private ScratchAssaySVMTrainer.ScratchOrientation |
orientation |
(package private) String |
outFile |
private libsvm.svm_parameter |
param |
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
posDir |
private libsvm.svm_problem |
prob |
private Integer |
sigma |
private int |
tn |
private int |
tp |
private ScratchAssaySVMTrainer.KERNEL_TYPE |
type |
private Vector<libsvm.svm_node[]> |
vx |
private Vector<Double> |
vy |
Constructor and Description |
---|
ScratchAssaySVMTrainer() |
ScratchAssaySVMTrainer(String posDir,
String negDir,
int sigma,
int entropyFilterSize,
boolean isHorizontal,
int maxIter) |
Modifier and Type | Method and Description |
---|---|
private void |
addFeatures(double label,
double[] features)
add the given patterns (feature arrays) together with their corresponding label to the
existing patterns used to train the SVM
|
private double |
classify(double[] features) |
private void |
extract(File[] samples,
double label)
segment the given images and extract their features for classification
|
private void |
extract(Vector<File> samples,
double label)
segment the given images and extract their features for classification
|
String |
getDocumentation() |
private void |
leaveOneOutCrossValidation()
leave-one-out cross validation, i.e. iteratively one sample is taken as test
sample whereas all others are used for training |
private MTBTableModel |
makeTable() |
void |
operate() |
private MTBImage |
readImage(String path) |
private void |
saveSVM()
save resulting svm model file
|
void |
setSVMParameters(libsvm.svm_parameter param) |
private void |
showDegreeTextbox() |
private void |
showKTextbox() |
private void |
stratifiedCrossValidation()
stratified k-fold cross validation, i.e. training and test tests contain
approximately the same proportions of positive and negative samples in
every iteration
|
private int[] |
test(Vector<File> samples,
int label) |
private void |
train()
the actual svm training
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="directory containing positive samples", required=true, direction=IN, supplemental=false, description="directory containing positive samples", mode=STANDARD, dataIOOrder=0) private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString posDir
@Parameter(label="directory containing negative samples", required=true, direction=IN, supplemental=false, description="directory containing negative samples", mode=STANDARD, dataIOOrder=1) private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString negDir
@Parameter(label="scratch orientation", required=true, direction=IN, supplemental=false, description="horizontally or vertically oriented scratch", mode=STANDARD, dataIOOrder=2) private ScratchAssaySVMTrainer.ScratchOrientation orientation
@Parameter(label="\u03c3", required=true, direction=IN, supplemental=false, description="standard deviation of gauss filter", mode=STANDARD, dataIOOrder=3) private Integer sigma
@Parameter(label="entropy filter size", required=true, direction=IN, supplemental=false, description="size of entropy filter mask", mode=STANDARD, dataIOOrder=4) private Integer entropyFilterSize
@Parameter(label="regularization parameter (C)", required=false, direction=IN, supplemental=false, description="regularization parameter", mode=STANDARD, dataIOOrder=5) private Integer C
@Parameter(label="kernel type", required=false, direction=IN, supplemental=false, description="type of svm kernel", mode=STANDARD, dataIOOrder=6, callback="showDegreeTextbox", paramModificationMode=MODIFIES_INTERFACE) private ScratchAssaySVMTrainer.KERNEL_TYPE type
@Parameter(label="polynomial degree", required=false, direction=IN, supplemental=false, description="degree for polynomial svm kernel", mode=STANDARD, dataIOOrder=7) private Integer degree
@Parameter(label="validation method", required=false, direction=IN, supplemental=false, description="validation method for x-validation", mode=STANDARD, dataIOOrder=8, callback="showKTextbox", paramModificationMode=MODIFIES_INTERFACE) private ScratchAssaySVMTrainer.ValidationMethod method
@Parameter(label="k (for k-fold x-validation)", required=false, direction=IN, supplemental=false, description="k for k-fold cross validation", mode=STANDARD, dataIOOrder=9) private Integer k
@Parameter(label="maximum iterations", required=false, direction=IN, supplemental=false, description="maximum number of iterations of level set segmentation", mode=ADVANCED, dataIOOrder=10) private Integer maxIter
private libsvm.svm_parameter param
private libsvm.svm_problem prob
private libsvm.svm_model model
private String error_msg
private Vector<libsvm.svm_node[]> vx
private int fp
private int fn
private int tp
private int tn
StringBuffer falsePositiveFileNames
StringBuffer falseNegativeFileNames
StringBuffer falseFileNames
private Boolean isHorizontal
String outFile
public ScratchAssaySVMTrainer() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public ScratchAssaySVMTrainer(String posDir, String negDir, int sigma, int entropyFilterSize, boolean isHorizontal, int maxIter) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
posDir
- directory containing positive samplesnegDir
- directory containing negative samplessigma
- standard deviation of gauss filterentropyFilterSize
- size of entropy filter maskisHorizontal
- is scratch horizontally oriented (assumed to be vertically oriented else)maxIter
- maximum number of iterations for level set segmentationde.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private void extract(File[] samples, double label)
samples
- array of filenames containing imageslabel
- label of the input imagesprivate void extract(Vector<File> samples, double label)
samples
- vector of filenames containing imageslabel
- label of the input imagesprivate void train()
private void saveSVM()
private MTBImage readImage(String path)
path
- private void addFeatures(double label, double[] features)
label
- label for the givven featuresfeatures
- array of feature valuespublic void setSVMParameters(libsvm.svm_parameter param)
param
- private void stratifiedCrossValidation()
private void leaveOneOutCrossValidation()
private int[] test(Vector<File> samples, int label)
samples
- Vector of sample fileslabel
- ground truth labels for the input imagesprivate double classify(double[] features)
features
- private MTBTableModel makeTable()
private void showDegreeTextbox()
private void showKTextbox()
public String getDocumentation()
getDocumentation
in class de.unihalle.informatik.Alida.operator.ALDOperator
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.