-
Notifications
You must be signed in to change notification settings - Fork 2
Training
Once the training set has been constructed, feeding it into the loadAndExtract function will launch the procedure for dataset creation and formatting. It will run through all the training stacks, and, for each selected frame, will apply the preprocessing operations (if any). The resulting signature for each of the z-pixels in the image will be therefore be composed of the values of the corresponding pixel in each preprocessed image, for every frame. (see upper part of image below). For each class, it will extract a number of randomly-selected z-pixel signatures (determined by how many have been labelled by the user × the class's subsampling rate) and concatenate those signatures. If a focus shifting radius greater than 0 has been set, then the whole operation will be repeated however many times the radius requires it.
Z, The total number of z-pixels in the set after formatting, is: Z = ∑(#labelled z-pixels for class i × subsampling rate of class i) × (2 × focus shifting radius +1)
D, the dimension of the z-pixel signatures, is: D = #subselected frames × #preprocessing operations.
The size of the formatted matrix will be Z × D.
Then, Principal Component Analysis is be applied to the dataset, and only the first P components (the user chooses P) will be kept to reduce the dimensionality of the dataset. Note that you can set a subsampling rate so that the PCA is only applied to a subset of observations, which reduces the memory footprint of the operation.
Above an example, with 3 preprocessing operations, 3 stacks in the set, and a focusing radius of 0.
The function will return:
- A structure variable (normally simply named
data) containing two fields:data.components,a Z×P Matrix of doubles containing the formatted data after PCA, anddata.labels, containing the class index labels of each row in thedata.componentsmatrix. - Another structure variable (normally named
pcavals) that contains the information necessary to redo the PCA processing on other data at the prediction stage. - (optionally) A structure variable similar to the first output for testing and evaluation purposes (see below).
Once the data has been read and formatted, training can be launched. The training function will launch the training and apply the relevant parameters in the training_set variable. There are slight differences in how the training is launched between the random forest branch and the SVM branch, but they are still fundamentally similar.
Depending on whether you are using parallel training, the function will either be blocking (i.e. it wil prevent the execution of any other command until it exits) and will display training progress (non-parallel case), or it will be non-blocking and will not display anything (parallel case). In the parallel case, you can monitor training progress with matlab's diary function and the job monitor. In any case, the saveTrainedSet function will write the trained set to disk only once it has finished training. You can see how we handle the parallel case in the training_script.m script at the root of the repo.
The trained set, once saved to disk, can be used for prediction on any machine and can be loaded into the prediction GUI.
A great way to improve classification accuracy is to systematically evaluate key parameters in the training set. The script evaluation_script.m gives an example of how it can be done.
The evalparams function can swap any field of the training set structure for a new value, and the rest of the script runs the training and the prediction steps on either test data processed at the LoadAndExtract step, or on completely different stacks if specified in the predstack cell of strings.
The user can specify a number of parameter changes to evaluate by specifying, in the evaluate cell variable, other cells that contain key-value arguments that specify what field to change (key string) and the new value (value). Each of those new sets of changes to do to the training set must be specified as a K×2 cell: K key-value changes for each field you want to change, and 2 elements for each field to change: The key and the value.
The saveTrainedSet function will save a training set to disk (only after it has finished training). It returns a false flag if the training is not finished. The saved trained set contains all the information to predict on completely new stacks.