Azure ML Tips And Tricks
While working with Azure Machine Learning, we ran into some situations that seem simple to handle in hindsight, but are rarely discussed online. Here are some simple Azure ML tips and tricks that we found useful.
1. Saving and Reusing a Trained Model
In one of our projects, we found that we needed to use the same trained model multiple times rather than just once in a predictive experiment. To do this, save a trained model by right clicking the output port of the Train Model module and selecting the Save as Trained Model option.
After giving the trained model a name and saving it, you will be able to find a module with the given name under the Trained Models sections of the module selection bar
or by typing the name into the module search bar. From here, you will be able to use the trained model in your experiments as you would any other module.
2. Clearing Features On Your Dataset
The Edit Metadata module allows you to select columns from your dataset that you would like to make modifications to. You can change the data type, whether or not the data is categorical, the field type, or the column names.
We found the most useful part of this module to be the clear feature option. This allows you to keep non-feature, non-categorical data in the dataset without affecting the rest of the experiment. In particular, we used it to keep identifying columns in the dataset without having to append them back to the data after going through predictive analysis, which would be problematic if the order of the data is not preserved.
You can find the Edit Metadata module in the module selection bar under Data Transformation > Manipulation or by using the module search bar.
3. Printing From An Execute R Script Module
There is unfortunately no debugger in the Execute R Script Module, so debugging R code that works locally but not in ML can be a pain. Thankfully, you can add print statements to your scripts,
and they will print to the R Device output of the module. You can see this by right clicking the Execute R Script module, selecting R Device, and then hitting Visualize.
The printed message is in the standard output section of the R Device visualization.
4. The Tune Model Hyperparameters Module
As an alternative to finding the most suitable hyperparameters for your model on your own, Azure ML has the Tune Model Hyperparameters module. It runs for a set number of iterations looking for the hyperparameters that give your model the highest performance in whatever metric you specify based on your data.
It then outputs the best trained model. You can find this module in the module selection bar under Machine Learning > Train or using the module search bar. Usage of this module is similar to that of the Train Model module, but the Tune Model Hyperparameters module has an additional input for a validation dataset and an additional output for the results of the hyperparameter sweep.
Note that this module typically takes a long time to run, so if you are working in a free workspace it is likely to exceed the one hour limit on the running time of each module. Even if you are in a standard workspace, there is a 3 day limit on the running time of an experiment (which we found out the hard way). The running time of this module can easily exceed that limit if you are running it for many iterations or training takes a long time.
5. Adding R Packages To A Workspace
While this process is relatively simple, it’s more lengthy than the others, so we’ve written about it in a separate post that will be release next week titled, Adding R Packages in Azure ML. Make sure to come back next week to learn all about this process!