 Open in App
Not now

• Last Updated : 23 Aug, 2021

MultiTaskLasso  Regression is an enhanced version of  Lasso regression. MultiTaskLasso is a model provided by sklearn that is used for multiple regression problems to work together by estimating their sparse coefficients. There is the same feature for all the regression problems called tasks. This model is trained with a mixed l1/l2 norm for regularization. It is similar to the Lasso regression in many aspects. The major difference is of the alpha parameter where the alpha is a constant that multiplies the l1/l2 norms.

The MultiTaskLasso model has the following parameters:

alpha: a float value that multiplies l1/l2 norms. by default 1.0
fit_intercept: decide whether to use intercept for calculations.
normalize: used to normalize the regressors in the data
max_itr: number of maximum iteration. by default -1000
selection: to determine how the updation of the coefficient will take place values – {‘cyclic’, ‘random’} by default cyclic
tol: tolerance for optimization.
random_state: A random feature is selected to update.

Code : To illustrate the working of MultiTaskLasso Regression in python

## python3

 `# import linear model library``from` `sklearn ``import` `linear_model` `# create MultiTaskLasso model``MTL ``=` `linear_model.MultiTaskLasso(alpha ``=` `0.5``)` `# fit the model to a data``MTL.fit([[``1``, ``0``], [``1``, ``3``], [``2``, ``2``]], [[``0``, ``2``], [``1``, ``4``], [``2``, ``4``]])` `# perform prediction and print the result``print``(``"Prediction result: \n"``, MTL.predict([[``0``, ``1``]]), ``"\n"``)` `# print the coefficients``print``(``"Coefficients: \n"``, MTL.coef_, ``"\n"``)` `# print the intercepts``print``(``"Intercepts: \n"``, MTL.intercept_, ``"\n"``)` `# print the number of iterations performed``print``(``"Number of Iterations: "``, MTL.n_iter_, ``"\n"``)`

Output:

```Prediction result:
[[0.8245348  3.04089134]]

Coefficients:
[[0.         0.26319779]
[0.         0.43866299]]

Intercepts:
[0.56133701 2.60222835]

Number of Iterations: 2```

My Personal Notes arrow_drop_up