MTLEARN Procedure
Example 23.1 Tuning the Hyperparameters of a Multitask Learning Model
This example illustrates how you can use the AUTOTUNE statement in the MTLEARN procedure to tune hyperparameters of a multitask learning model.
This example assumes that the CAS engine libref mylib and the caslib that is associated with mylib have already been created.
The following DATA step creates the input data table mylib.toyData in your CAS session. This data table contains seven variables: id is the row ID variable; X1, X2, and X3 are the input variables; and Y1, Y2, and Y3 are the target variables.
data mylib.toydata;
input id X1 X2 X3 Y1 Y2 Y3;
cards;
0 0.912621 1.288759 1.568040 2.813182 2.792080 2.792080
1 -0.696839 -1.487805 1.383056 0.187085 0.559484 0.559484
2 0.970062 2.405601 -1.638553 -1.903736 -2.301208 -2.301208
3 0.291515 -0.176170 -0.175393 3.842113 3.799427 3.799427
4 0.721477 0.472668 -0.522688 5.171737 4.906125 4.923472
5 1.563781 -1.04760 -0.298725 21.160617 20.762561 20.592648
6 0.426927 1.319816 -0.022467 -2.231491 -2.361400 -2.472938
7 -1.046538 -0.190017 -1.75929 -9.438538 -9.388092 -9.392649
8 0.155960 0.299715 -0.366969 0.109865 -0.00258535 -0.0210573
9 1.568768 -0.900524 0.334290 20.422254 19.799980 19.799980
;
run;
The following DATA step creates the input graph table mylib.toyr in your CAS session. This data table encodes the relationships between the targets. In this example, the targets Y2 and Y3 are connected, meaning that the regression weights for Y2 and Y3 are expected to be similar. This data table contains four variables: id is the row ID variable; and Y1, Y2, and Y3 are the target variables.
data mylib.toyr;
input id Y1 Y2 Y3;
cards;
0 0 1 -1
;
run;
The following statements run PROC MTLEARN and display the results in ODS tables:
proc mtlearn data = mylib.toydata
graphType = CUSTOM
regL1 = 20
regL2 = 500
maxIter = 1000
tolerance = 5e-4
seed = 12345
graphTable = mylib.toyr
modelOut = mylib.mtl_outW
graphOut = mylib.mtl_outR
;
input X1 X2 X3;
target Y1 Y2 Y3;
autotune
/* Tuning Parameters
You do not need to specify any tuning parameters for the default
tuning process. If you want to make adjustments to the default
tuning process, uncomment the following block of code and change
any of the tuning parameters' attributes.
tuningParameters=(
MAXITERS ( lb=100 ub=5000 init=100 )
TOLERANCE ( lb=1E-6 ub=1E-3 init=1E-6 )
REGL1 ( lb=0.0 ub=1000.0 init=0.01 )
REGL2 ( lb=0.0 ub=1000.0 init=0.01 )
)
*/
;
/* Remove this line to see all results */
ods select BestConfiguration EvaluationHistoryPlot IterationHistoryPlot;
run;
The preceding statements produce the table and the plots shown in Output 23.1.1 through Output 23.1.3. The table in Output 23.1.1 displays the evaluation number, the values of the tuning parameters, and the error metric value for the best multitask learning model that the tuner found. Note that the ODS SELECT statement limits the displayed results to a single table and two plots. You can remove this statement to display all tables and plots. For the full list of ODS tables that PROC MTLEARN produces, see Table 3.
Output 23.1.1: Best Configuration Table
| Best Configuration | |
|---|---|
| Evaluation | 72 |
| Maximum Number of Iterations | 459 |
| Tolerance | 0.001 |
| L1 (LASSO) Penalization Weight | 0 |
| Graph Penalization Weight | 814.141471 |
| Root Average Square Error | 0.0825157251 |
Output 23.1.2 displays a scatter plot of all configurations that the tuner tried. The objective values are shown on the Y axis, and the evaluation numbers are shown on the X axis.
Output 23.1.2: Evaluation History Plot

The plot in Output 23.1.3 displays how the best found objective value and the elapsed time changed with each iteration of the tuner.
Output 23.1.3: Iteration History Plot
