02-04-2019 05:24 AM
If you want to classify based on certain attribute measures then the classifier must also be trained on those exact same attributes. A simple example is that if you want to use a NIR attribute to help distinguish vegetation classes from others you must train based on a NIR attribute (and then provide that same information in the dataset to be classified). It's the same with all attributes.
So the answer to "Do I use the variance texture before creating the miz file/before the Initialize Random Forest operator, or is it done when classifying the machine learning against the raster input?" is both.
02-05-2019 03:35 PM - edited 02-05-2019 03:36 PM
Attached are my two spatial models.
The Machine Learning is what is done first. I have tried to add the variance texture, which runs without error, but maybe incorrect.
When I try to add the same variance texture and matrix to the tree output spatial model before the classification Erdas must get confused as it seems to freeze and the only option is to reboot.
I guess my understanding is a little lacking in this area. I must have used variance texture incorrectly.
02-05-2019 10:14 AM
Your training model is only using Variance (of each band) as the variables to train from. Is that intentional? Generally Machine Learning wants numerous variables to train from inorder to adequately discriminate between the different class types you are training on. It should work with just the three variables, I just wonder how good your results are going to be. Also - you don't need that intermediate Feature Output operator. Wont stop the process - it'll just make it run slower because it will write out a temporary file. Get rid of the two superfluous operators at the end too.
In your classification model, is the input raster the three variance bands? If it's just the original raster you used in the first model (which looked like it was a RGB three band image) then the DN values wont correspond to t he variance variable values your trained from. you need to feed the same variable information to the classifier as you trained with. So for a raster classification you need bands representing all the variables you trained form (in the order they were trained on).
02-06-2019 07:56 PM
Yes I wasn't sure where to put the variance texture. Initially I just linked the raster input to the raster statistics per feature but in an earlier reply you said I should include variance texture. Is there any chance you could alter my spatial models to what you think it should look like and I can test it? I'm a bit confused sorry.
02-19-2019 07:21 AM
It's difficult to be sure without access to your data, but the attached models use both the three original image bands and the derived Variance Textures (i.e. 6 variables) in the Machine Learning process. Hopefully it will at least give you some ideas,
02-19-2019 02:25 PM
Thanks for your help with this. Much appreciated.
I'm just trying it now with a couple of tweaks. I'll let you know how it goes.
02-20-2019 05:21 PM
I notice now when running the tree_output_2012 model it fails on the Classify Machine Learning step.
This also happened when I made changes last time but I went back to the original way I set it up and it worked.
I get local variable 'prediction' referenced before assignement. This wouldn't have anything to do with the fact that the Machine Intellect Input runs straight away before the rest of the model catches up?
20/02/19 12:16:13 SessionMgr(9000): Raster X: 8965 Raster Y: 11363 RasterCount: 6 20/02/19 12:16:13 SessionMgr(9000): Error occured while running rasterclassifier 20/02/19 12:16:13 SessionMgr(9000): Input contains NaN, infinity or a value too large for dtype('float32'). 20/02/19 12:16:13 SessionMgr(9000): Error occured while running predict in file rasterclassifier 20/02/19 12:16:13 SessionMgr(9000): local variable 'prediction' referenced before assignment 20/02/19 12:16:13 SessionMgr(9000): Spatial model execution failed.
02-20-2019 09:48 AM
I forgot that the Variance texture is going to be a f64 value and have a much larger range than the original input bands. So you should really scale it back to a similar range and datatype before using it in both training and classification. I also forgot that the Machine Learning operators don't like NoData, so you need a Replace NoData With operator. What you replace it with will depend on the data range you end up with, but 0 is a good starting point.
02-22-2019 09:46 PM
I can see you can convert raster type to match the raster (unsigned 8 bit), but with the stacking of layers I still end up with 6 planes.
That may be why it's failing. Can I convert it to 3 planes like the original raster?
02-22-2019 05:14 AM
Simple conversionmay not be sufficient - make sure that you're not truncatign the data range by doing that. I suspect you may need to scale the data to 8-bit.
And dont forget that for machine learning you want lots of variables to analyse. So if you train on 6 variabels (three oringal band values plus three derived variance textures) you need to classify based on the same 6 variables. 6 planes of data should be correct based on the models I sent you.