<jupyter_start><jupyter_text>Multiple Linear Regression<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.model_selection import train_test_split

diabetes = datasets.load_diabetes() #load dataset
diabetes_X = diabetes.data
X_train, X_test, y_train, y_test = train_test_split(diabetes_X, diabetes.target, test_size=0.20, random_state=42, shuffle=True) #split 20% into test set
y_test = y_test.reshape(-1,1)
y_train = y_train.reshape(-1, 1)
print('Size of the training set is {}'.format(X_train.shape))
print('Size of the Label training set is {}'.format(y_train.shape))
print('Size of the Label teest set is {}'.format(y_test.shape))
print('Size of the test set is {}'.format(X_test.shape))
# Create linear regression object
regr = linear_model.LinearRegression()

# Train the model using the training sets
regr.fit(X_train, y_train)

# Make predictions using the testing set
y_pred = regr.predict(X_test)

# The coefficients
print('Coefficients: \n', regr.coef_)
# The mean squared error
print("Mean squared error: %.2f"
      % mean_squared_error(y_test, y_pred))
# Explained variance score: 1 is perfect prediction
print('Variance score: %.2f' % r2_score(y_test, y_pred))<jupyter_output>Coefficients: 
 [[  37.90031426 -241.96624835  542.42575342  347.70830529 -931.46126093
   518.04405547  163.40353476  275.31003837  736.18909839   48.67112488]]
Mean squared error: 2900.17
Variance score: 0.45
{'fraction_non_alphanumeric': 0.10412573673870335, 'fraction_numerical': 0.0870988867059594, 'mean_word_length': 5.791111111111111, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '667776', 'license': 'MIT', 'n_tokens_mistral': 623, 'n_tokens_neox': 533, 'n_words': 146, 'path': 'Module 4/multilinear_regression.ipynb', 'repo_name': 'axel-sirota/interpreting-data-with-advanced-models', 'size': '1527'}