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
from sklearn import linear_model
MTL = linear_model.MultiTaskLasso(alpha = 0.5)
MTL.fit([[1, 0], [1, 3], [2, 2]], [[0, 2], [1, 4], [2, 4]])
print("Prediction result: \n", MTL.predict([[0, 1]]), "\n")
print("Coefficients: \n", MTL.coef_, "\n")
print("Intercepts: \n", MTL.intercept_, "\n")
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
Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.Dive into the future of technology - explore the
Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated :
23 Aug, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...