Q:

What happens when scikit-learn does a Lasso Model?

I have started an MLS course. As a beginner and non-mathematician it has been hard.
I am trying to understand the exercise about Lasso Models.
I have done Lasso models on R-cran, but this is my first time with Python.
I have a dataset of cars with seven variables. The exercise consists on doing a Lasso Model to predict the gasoline consumption of the cars, the dependent variable, so $x$ is a table with the rest of variables and $y$ is the consumption.
Then, if I launch Lasso on scikitlearn:
modelLasso = Lasso(alpha=0.1).fit(x, y)

I do not understand the result. Has it generated a prediction on $y$ of every row in the table?
If so, how can I access to the array of predictions of the model and how do I use the model to predict the consumption given new $x$ values?

A:

Here is a little lasso example using the Boston Housing Data. The code also shows how to: 

choose optimal alpha, 
display data and predictions, 
display estimated coefficients, 
and how to make a prediction by hand. 

# Import toy data
from sklearn.datasets import load_boston
import pandas as pd
# Load toy data
boston = load_boston(return_X_y=False)
# Make data a pandas data frame
boston = pd.DataFrame(boston.data)
# Print head of toy data
#print(boston.head())
# Define x,y (only take few columns for x)
y = boston[[12]] # choose column 12
x = boston[[10,11]] # only column 10,11

from sklearn.linear_model import Lasso
from sklearn.linear_model import LassoCV
lasso = Lasso(max_iter=10000)

# Perform lasso CV to get the best parameter alpha for regulation
# usually use scaled data mean = 0, sd = 1 by applying scale()
# I don't do this here for brevity
# https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.scale.html
lassocv = LassoCV(alphas=None, cv=10, max_iter=10000)
lassocv.fit(x, y.values.ravel())

# Fit lasso using the best alpha
lasso.set_params(alpha=lassocv.alpha_)
lasso.fit(x, y)

# Show the estimated coefficients/intercept
print('Intercept (Lasso): \n', lasso.intercept_)
print('Coefficients (Lasso): \n', lasso.coef_)

# Predict lasso / print first predicted value
preds = lasso.predict(x)
print('Lasso prediction: \n', preds[0])

# Print first x values
print('x-values: \n', x.head(1))

# Predict "by hand"
print(2.89333694+1.00035566*15.3 - 0.02439867*396.9)

Output is:
Intercept (Lasso): 
 [2.89333694]
Coefficients (Lasso): 
 [ 1.00035566 -0.02439867]

Lasso prediction: 
 8.514947307107153

x-values: 
      10     11
0  15.3  396.9

8.514946415000002

