Clear Filters
Clear Filters

classification learner app train all model script export

4 views (last 30 days)
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!

Answers (2)

Image Analyst
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
Yuhong
Yuhong on 5 Apr 2023
Hi,
Yes. I understand what the app is doing. 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. And I can't post my code publicly here, can I send my code to you privately? Thanks.
Image Analyst
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?

Sign in to comment.


Drew
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".
  1 Comment
Yuhong
Yuhong on 5 Apr 2023
Hi,
Thanks for your reply. I really wish to show you my code, but it's part of my research project I can't do it publicly, can you make a anonymous space for me to upload my code? Thanks.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!