Train a regression model

Brief Description

Train a classifier from multiple images to perform regression.

Tags

Learning

Long Description

This application trains a classifier from multiple input images or a csv file, in order to perform regression. Predictors are composed of pixel values in each band optionally centered and reduced using an XML statistics file produced by the ComputeImagesStatistics application.

The output value for each predictor is assumed to be the last band (or the last column for CSV files). Training and validation predictor lists are built such that their size is inferior to maximum bounds given by the user, and the proportion corresponds to the balance parameter. Several classifier parameters can be set depending on the chosen classifier. In the validation process, the mean square error is computed between the ground truth and the estimated model.

This application is based on LibSVM and on OpenCV Machine Learning classifiers, and is compatible with OpenCV 2.3.1 and later.

Parameters

Input and output data (io): This group of parameters allows setting input and output data.

Input Image List (io.il): A list of input images. First (n-1) bands should contain the predictor. The last band should contain the output value to predict.

Input CSV file (io.csv): Input CSV file containing the predictors, and the output values in last column. Only used when no input image is given

Input XML image statistics file (io.imstat): Input XML file containing the mean and the standard deviation of the input images.

Output regression model (io.out): Output file containing the model estimated (.txt format).

Mean Square Error (io.mse): Mean square error computed with the validation predictors

Training and validation samples parameters (sample): This group of parameters allows you to set training and validation sample lists parameters.

Maximum training predictors (sample.mt): Maximum number of training predictors (default = 1000) (no limit = -1).

Maximum validation predictors (sample.mv): Maximum number of validation predictors (default = 1000) (no limit = -1).

Training and validation sample ratio (sample.vtr): Ratio between training and validation samples (0.0 = all training, 1.0 = all validation) (default = 0.5).

Classifier to use for the training (classifier): Choice of the classifier to use for the training.

LibSVM classifier (libsvm): This group of parameters allows setting SVM classifier parameters.

SVM Kernel Type (classifier.libsvm.k): SVM Kernel Type.

Linear (linear): Linear Kernel, no mapping is done, this is the fastest option.

Gaussian radial basis function (rbf): This kernel is a good choice in most of the case. It is an exponential function of the euclidian distance between the vectors.

Polynomial (poly): Polynomial Kernel, the mapping is a polynomial function.

Sigmoid (sigmoid): The kernel is a hyperbolic tangente function of the vectors.

SVM Model Type (classifier.libsvm.m): Type of SVM formulation.

Epsilon Support Vector Regression (epssvr): The distance between feature vectors from the training set and the fitting hyper-plane must be less than Epsilon. For outliers the penalty multiplier C is used

Nu Support Vector Regression (nusvr): Same as the epsilon regression except that this time the bounded parameter nu is used instead of epsilon

Cost parameter C (classifier.libsvm.c): SVM models have a cost parameter C (1 by default) to control the trade-off between training errors and forcing rigid margins.

Cost parameter Nu (classifier.libsvm.nu): Cost parameter Nu, in the range 0..1, the larger the value, the smoother the decision.

Parameters optimization (classifier.libsvm.opt): SVM parameters optimization flag.

Probability estimation (classifier.libsvm.prob): Probability estimation flag.

Epsilon (classifier.libsvm.eps): The distance between feature vectors from the training set and the fitting hyper-plane must be less than Epsilon. For outliersthe penalty mutliplier is set by C.

Decision Tree classifier (dt): This group of parameters allows setting Decision Tree classifier parameters. See complete documentation here \url{http://docs.opencv.org/modules/ml/doc/decision_trees.html}.

Maximum depth of the tree (classifier.dt.max): The training algorithm attempts to split each node while its depth is smaller than the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are met, and/or if the tree is pruned.

Minimum number of samples in each node (classifier.dt.min): If the number of samples in a node is smaller than this parameter, then this node will not be split.

Termination criteria for regression tree (classifier.dt.ra): If all absolute differences between an estimated value in a node and the values of the train samples in this node are smaller than this regression accuracy parameter, then the node will not be split further.

Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split (classifier.dt.cat): Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split.

K-fold cross-validations (classifier.dt.f): If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K is equal to cv_folds.

Set Use1seRule flag to false (classifier.dt.r): If true, then a pruning will be harsher. This will make a tree more compact and more resistant to the training data noise but a bit less accurate.

Set TruncatePrunedTree flag to false (classifier.dt.t): If true, then pruned branches are physically removed from the tree.

Gradient Boosted Tree classifier (gbt): This group of parameters allows setting Gradient Boosted Tree classifier parameters. See complete documentation here \url{http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html}.

Loss Function Type (classifier.gbt.t): Type of loss functionused for training.

Squared Loss (sqr):

Absolute Loss (abs):

Huber Loss (hub):

Number of boosting algorithm iterations (classifier.gbt.w): Number "w" of boosting algorithm iterations, with w*K being the total number of trees in the GBT model, where K is the output number of classes.

Regularization parameter (classifier.gbt.s): Regularization parameter.

Portion of the whole training set used for each algorithm iteration (classifier.gbt.p): Portion of the whole training set used for each algorithm iteration. The subset is generated randomly.

Maximum depth of the tree (classifier.gbt.max): The training algorithm attempts to split each node while its depth is smaller than the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are met, and/or if the tree is pruned.

Artificial Neural Network classifier (ann): This group of parameters allows setting Artificial Neural Network classifier parameters. See complete documentation here \url{http://docs.opencv.org/modules/ml/doc/neural_networks.html}.

Train Method Type (classifier.ann.t): Type of training method for the multilayer perceptron (MLP) neural network.

Back-propagation algorithm (back): Method to compute the gradient of the loss function and adjust weights in the network to optimize the result.

Resilient Back-propagation algorithm (reg): Almost the same as the Back-prop algorithm except that it does not take into account the magnitude of the partial derivative (coordinate of the gradient) but only its sign.

Number of neurons in each intermediate layer (classifier.ann.sizes): The number of neurons in each intermediate layer (excluding input and output layers).

Neuron activation function type (classifier.ann.f): This function determine whether the output of the node is positive or not depending on the output of the transfert function.

Identity function (ident):

Symmetrical Sigmoid function (sig):

Gaussian function (Not completely supported) (gau):

Alpha parameter of the activation function (classifier.ann.a): Alpha parameter of the activation function (used only with sigmoid and gaussian functions).

Beta parameter of the activation function (classifier.ann.b): Beta parameter of the activation function (used only with sigmoid and gaussian functions).

Strength of the weight gradient term in the BACKPROP method (classifier.ann.bpdw): Strength of the weight gradient term in the BACKPROP method. The recommended value is about 0.1.

Strength of the momentum term (the difference between weights on the 2 previous iterations) (classifier.ann.bpms): Strength of the momentum term (the difference between weights on the 2 previous iterations). This parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough.

Initial value Delta_0 of update-values Delta_{ij} in RPROP method (classifier.ann.rdw): Initial value Delta_0 of update-values Delta_{ij} in RPROP method (default = 0.1).

Update-values lower limit Delta_{min} in RPROP method (classifier.ann.rdwm): Update-values lower limit Delta_{min} in RPROP method. It must be positive (default = 1e-7).

Termination criteria (classifier.ann.term): Termination criteria.

Maximum number of iterations (iter): Set the number of iterations allowed to the network for its training. Training will stop regardless of the result when this number is reached

Epsilon (eps): Training will focus on result and will stop once the precision isat most epsilon

Max. iterations + Epsilon (all): Both termination criteria are used. Training stop at the first reached

Epsilon value used in the Termination criteria (classifier.ann.eps): Epsilon value used in the Termination criteria.

Maximum number of iterations used in the Termination criteria (classifier.ann.iter): Maximum number of iterations used in the Termination criteria.

Random forests classifier (rf): This group of parameters allows setting Random Forests classifier parameters. See complete documentation here \url{http://docs.opencv.org/modules/ml/doc/random_trees.html}.

Maximum depth of the tree (classifier.rf.max): The depth of the tree. A low value will likely underfit and conversely a high value will likely overfit. The optimal value can be obtained using cross validation or other suitable methods.

Minimum number of samples in each node (classifier.rf.min): If the number of samples in a node is smaller than this parameter, then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.

Termination Criteria for regression tree (classifier.rf.ra): If all absolute differences between an estimated value in a node and the values of the train samples in this node are smaller than this regression accuracy parameter, then the node will not be split.

Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split (classifier.rf.cat): Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split.

Size of the randomly selected subset of features at each tree node (classifier.rf.var): The size of the subset of features, randomly selected at each tree node, that are used to find the best split(s). If you set it to 0, then the size will be set to the square root of the total number of features.

Maximum number of trees in the forest (classifier.rf.nbtrees): The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the prediction time linearly.

Sufficient accuracy (OOB error) (classifier.rf.acc): Sufficient accuracy (OOB error).

KNN classifier (knn): This group of parameters allows setting KNN classifier parameters. See complete documentation here \url{http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html}.

Number of Neighbors (classifier.knn.k): The number of neighbors to use.

Decision rule (classifier.knn.rule): Decision rule for regression output

Mean of neighbors values (mean): Returns the mean of neighbors values

Median of neighbors values (median): Returns the median of neighbors values

Shark Random forests classifier (sharkrf): This group of parameters allows setting Shark Random Forests classifier parameters. See complete documentation here \url{http://image.diku.dk/shark/doxygen_pages/html/classshark_1_1_r_f_trainer.html}.

It is noteworthy that training is parallel.Maximum number of trees in the forest (classifier.sharkrf.nbtrees): The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the prediction time linearly.

Min size of the node for a split (classifier.sharkrf.nodesize): If the number of samples in a node is smaller than this parameter, then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.

Number of features tested at each node (classifier.sharkrf.mtry): The number of features (variables) which will be tested at each node in order to compute the split. If set to zero, the square root of the number of features is used.

Out of bound ratio (classifier.sharkrf.oobr): Set the fraction of the original training dataset to use as the out of bag sample.A good default value is 0.66.

Shark kmeans classifier (sharkkm): This group of parameters allows setting Shark kMeans classifier parameters. See complete documentation here \url{http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/algorithms/kmeans.html}.

Maximum number of iteration for the kmeans algorithm. (classifier.sharkkm.maxiter): The maximum number of iteration for the kmeans algorithm. 0=unlimited

The number of class used for the kmeans algorithm. (classifier.sharkkm.k): The number of class used for the kmeans algorithm. Default set to 2 class

set user defined seed (rand): Set specific seed. with integer value.

Load otb application from xml file (inxml): Load otb application from xml file

Save otb application to xml file (outxml): Save otb application to xml file

Limitations

None

Authors

OTB-Team

See also

OpenCV documentation for machine learning http://docs.opencv.org/modules/ml/doc/ml.html

Example of use

- Values for GUIs:
io.il: training_dataset.tif

io.out: regression_model.txt

io.imstat: training_statistics.xml

classifier: libsvm

- Command line to execute:

otbcli_TrainRegression -io.il training_dataset.tif -io.out regression_model.txt -io.imstat training_statistics.xml -classifier libsvm