Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

lasso regression

# Import Lasso
from sklearn.linear_model import Lasso

# Instantiate a lasso regressor: lasso
lasso = Lasso(alpha=0.4, normalize=True)

# Fit the regressor to the data
lasso.fit(X, y)

# Compute and print the coefficients
lasso_coef = lasso.coef_
print(lasso_coef)

# Plot the coefficients
plt.plot(range(len(df_columns)), lasso_coef)
plt.xticks(range(len(df_columns)), df_columns.values, rotation=60)
plt.margins(0.02)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: convert pandas.core.indexes.numeric.int64index to list 
Python :: python get 2d array output as matrix 
Python :: dataframe unstack 
Python :: open gui window python 
Python :: geopandas geometry length 
Python :: python leetcode 
Python :: python tkinter entry widget 
Python :: np.r_ 
Python :: fillna not work 
Python :: Hungry Chef codechef solution 
Python :: pytest local modules 
Python :: Python code to find Area of Rectangle 
Python :: Set value for particular cell in pandas DataFrame using index 
Python :: split and only grab first part of string 
Python :: Spotify API Authentication in Python 
Python :: python reduce 
Python :: Python Making a New Directory 
Python :: smtp python set subject 
Python :: connect mongodb with python 
Python :: selenium get h1 text python 
Python :: Highlight Active Links in Django Website 
Python :: load static 
Python :: how to create multidimensional array in python using numpy 
Python :: Filter Pandas rows by specific string elements 
Python :: nltk bigrams 
Python :: Reverse an string Using Stack in Python 
Python :: best fit line python log log scale 
Python :: duplicates in python list 
Python :: selenium python get element by type 
Python :: python .findall 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =