TrainRegression and TrainImagesRegression are not working for me

Hello every one,

I have a problem with regression applications. I’d like to know if there are any workflow, precautions, etc. I was applying the TrainRegression/TrainImagesRegression. I used packages from 6.2, 7.0 and 7.1

For TrainiImagesRegression :

The used predictor images are of type float, and of 30 bands images

the label image is a float image (how to provide stats file for both of them? if I use io.imstat , an error of mismatching size is reproduced!)

The output model: contains only 2 classes (I expected too many classes since it is a regression problem, and a real output valued is the target). When generating the output image (using ImageRegression), it produces an outuput image similar to the mask file (an roi file with 1s where the regressor should predict the values)

for TrainRegression , the training is using the predictor and label image, as stated in the documentation as 31 bands (30 for input and last band for the lable image). The model wasn’t completed, becauuse of error related to mse= - nan, as the following:

Error using 7.1 :

Mean Square Error = -nan

Output parameters value:

io.mse: 3.402823466e+38

The model file can not be inferred, with the following:

svm_type epsilon_svr

kernel_type rbf

gamma 1

nr_class 2

total_sv 0

rho -nan


I’d like to know/request also, the following:

Can I set a gamma parameter to the libsvm parameter set or not? instead of search for it using .opt parameter (I did a work around by asigning a search grid for gamma with adjacent values, as given in my commend, hereinafter)

Can I scale the data between 0 and 1, rather than normalize the data? (my data contains hot encoded classes)

What is the structure of the training and validation vector file (should it contain different polygons for different values? as an analogy with a classification problem, or just one polygon for all real-valued data)

Could we have documentation for model file structure?

my command looks like: (I couldn’t use the io.imstat file because it gives an error, it appears that the application uses the same xml file to scale the predictor and label image)

otbcli_TrainImagesRegression pfile1.tif pfile2.tif -io.ip lfile1.tif lfile2.tif -io.vd vec1.shp vec2.shp -io.out Model_svm.txt -sample.nt 10000 -sample.type periodic -ram 8000 -classifier libsvm -classifier.libsvm.k rbf -classifier.libsvm.opt 1 -classifier.libsvm.c 1000 -classifier.libsvm.gamma_grid.min_val 0.001 -classifier.libsvm.gamma_grid.max_val 0.002

I am grateful for the attention that you may put for this issue.


I think there is an error in the conception of the module TrainImagesRegression. Please check it. It creates at most two classes.

It looks like there are no-data values in your image as NaN or -Inf which can cause trouble in computations.
Can you try on a subset that contains only valid pixels (i.e. without any no-data value)?
To compute image statistics, you must use the ComputeImageStatistics application, that exports a .xml file. If you still have NaN values in your stats, it likely won’t work…