classification learner app train all model script export
5 views (last 30 days)
Show older comments
Hi all,
I used classification learner app to train ALL models, but I can only export one model training script at a time, how can I export a script that trains all models?
Thanks!
0 Comments
Answers (2)
Image Analyst
on 5 Apr 2023
The app is the thing that trains the models. It creates models that you can then use to PREDICT responses. It is not meant to create code to TRAIN models. If you want to do that yourself, you'd have to call the various individual classification training functions. See the help on classification
2 Comments
Image Analyst
on 5 Apr 2023
Edited: Image Analyst
on 5 Apr 2023
No, sorry. Why can't you just create some sample data that is somewhat similar?
Drew
on 5 Apr 2023
As you know, the "Generate Function" button in the Export section of the Classification Learner app generates MATLAB code for training a model. There is no way to generate MATLAB code for training all models at once. You have to generate the functions for each model one-by-one. It looks like you have done this.
In your comment, you wrote, "And I did create a function to take X-y (data and label) as input to train various classifiers and I used parfor to accelerate training, but my function is still much slower than using app interface to train the same amount of models, for example, my code takes ~120s and the app only takes ~40s, which the speed is my concerns."
At the high level, it should be possible to obtain similar model training speed with your CLI (command line interface) code and the app-interface. Without seeing your CLI code, some possible sources of the difference:
(1) Maybe the CLI code is doing additional operations which are not done at training time in the app. What form of validation are you using, that is, for example, 5-fold cross-validation, or something else? Are you using a separate test set? Are you partitioning the data only once, or multiple times? The app only partitions the data once, and it does that prior to starting training.
(2) Perhaps the CLI code is using "parfor" for parallelization in a sub-optimal way for your machine, with its unique memory limitations, etc. Some model training code functions will automatically use multi-threading without the use of "parfor".
See Also
Categories
Find more on Classification Learner App in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!