Question: Previous data: import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error, r2_score #load the data diabX, diabY

Previous data:
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error, r2_score #load the data diabX, diabY = datasets.load_diabetes(return_X_y=True)
# for only one feature diabX = diabX[:, np.newaxis, 2]
#train test split diabX_train = diabX[:-20] diabX_test = diabX[-20:] diabY_train = diabY[:-20] diabY_test = diabY[-20:]
regression_model = linear_model.LinearRegression()
regression_model.fit(diabX_train, diabY_train)
diabY_pred = regression_model.predict(diabX_test)
print('Coefficients: ', regression_model.coef_) print('Intercept: ',regression_model.intercept_) print('MSE: %.2f'% mean_squared_error(diabY_test, diabY_pred))
print('Coef. of determination: %.2f'% r2_score(diabY_test, diabY_pred))
plt.scatter(diabX_test, diabY_test, color='red') plt.plot(diabX_test, diabY_pred, color='black', linewidth=2) plt.xlabel('diabetesX'); plt.ylabel('diabetesY'); plt.grid(True) plt.show()


Instructions You are required to use the same dataset that you used in your last lab. You'll be performing some more regression via LARS Lasso (https://scikit-learn.org/stable/modules/linear model.html#lasso) and Regerssion via Decision Trees (https://scikit-learn.org/stable/modules/tree.html#regression). Play around with the parameters that you can change in the algorithms in the librarys and plot error graphs to compare. What do you think is better and why give a general answer for the understanding. Figure 1 1 300 250 200 diabetesY . 150 100 50 -0.08 -0.06 -0.04 -0.02 0.04 0.06 0.08 0.00 0.02 diabetesX vineet@vineet-HP-Laptop-15-bs1xx: - File Edit View Search Terminal Help Intercept: 152.91886182616167 Mean squared error: 2548.07 Coefficient of determination: 0.47 (base) vineet@vineet-HP-Laptop-15-bs1xx:~$ python c.py Coefficients: [938.23786125] Intercept: 152.91886182616167 Mean squared error: 2548.07 Coefficient of determination: 0.47 (base) vineet@vineet-HP-Laptop-15-bs1xx:-$ python copy Traceback (most recent call last): File "c.py", line 16, in
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
