<jupyter_start><jupyter_text><jupyter_code><jupyter_output><empty_output><jupyter_text>The dataset for this example is available at:https://drive.google.com/open?id=1mVmGNx6cbfvRHC_DvF12ZL3wGLSHD9f_<jupyter_code>from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
dataset = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/petrol_consumption.csv')
dataset
dataset.head()
dataset.describe()<jupyter_output><empty_output><jupyter_text>Preparing the DataThe next step is to divide the data into attributes and labels as we did previously. However, unlike last time, this time around we are going to use column names for creating an attribute set and label. Execute the following script:<jupyter_code>X = dataset[['Petrol_tax', 'Average_income', 'Paved_Highways',
             'Population_Driver_licence(%)']]
y = dataset['Petrol_Consumption']
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)

y_pred = regressor.predict(X_test)
df = pd.DataFrame({'Actual': y_test, 'Predicted': y_pred})
df
from sklearn import metrics
import numpy as np
print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred))
print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred))
print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)))<jupyter_output>Mean Absolute Error: 56.8222474789647
Mean Squared Error: 4666.344787588362
Root Mean Squared Error: 68.31064915215168
{'fraction_non_alphanumeric': 0.10060975609756098, 'fraction_numerical': 0.03414634146341464, 'mean_word_length': 7.7287234042553195, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '510260', 'license': 'Apache-2.0', 'n_tokens_mistral': 609, 'n_tokens_neox': 549, 'n_words': 134, 'path': 'Lab_5_linear_regression_with_csv.ipynb', 'repo_name': 'Shivani-pawar26/Machine_learning', 'size': '1640'}