Error loading TreeBagger from .MAT file in deployed app.

6 views (last 30 days)
Hiya =)
I've been browsing the forums looking for information on this... When run in MatLab my app works fine. But when it is deployed, I get this message:
Warning: Variable 'model' originally saved as a TreeBagger cannot be instantiated as an object and will be read in as a uint32.
I have a deployed app that trains models and stores them out using save() with '-struct' semantics. Another deployed app loads and uses these models regularly.
Note that my TreeBagger is actually a field within the struct (maybe this is significant):
model.meta % a whole bunch of info
model.model % the TreeBagger object
I have come across the following article that may explain the behaviour. It discusses saving (but not loading?) of user-defined objects:
This is where I am confused. The TreeBagger object is not really user-defined as such. It's part of a rather expensive toolbox, and would presumably define its own saveobj and loadobj methods if it needed to...
Do I need to follow the linked article and hack the TreeBagger class, or is there a simple solution?
Thanks in advance!
-g-
  2 Comments
Geoff
Geoff on 2 Feb 2012
Just need to bump this question again, as I'm really stuck and there's an awful lot at stake for this project! I am flabbergasted at the things that seem to go wrong when you deploy an application! It's almost like starting the development again.
I tried copying the TreeBagger class definition m-file into my deployment directory (it was a long shot), but no luck.
Any suggestions? =(

Sign in to comment.

Accepted Answer

owr
owr on 2 Feb 2012
  1 Comment
Geoff
Geoff on 2 Feb 2012
Thank you so much! I spent ages trying to find this information but my searches never turned up anything useful.

Sign in to comment.

More Answers (1)

Geoff
Geoff on 2 Feb 2012
Just for completeness, I'll post the solution from owr's linked article....
The class definition must be imported by including a pragma in my function that calls load(). As follows:
function [model] = loadmodel( filename )
%#function TreeBagger
model = load( filename, '-mat' );
end
Yaay!!!
Cheers =)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!