<jupyter_start><jupyter_text>Multiple Linear Regression<jupyter_code># Import Pandas for data processing
import pandas as pd
# Read the CSV file
dataset = pd.read_csv('StudentsMLR.csv')
df = dataset.copy()
df
# Split into X (Independent) and Y (predicted)
X = df.iloc[:, :-1]
Y = df.iloc[:, -1]
# Split the rows into training and test set
from sklearn.model_selection import train_test_split

x_train, x_test, y_train, y_test =     \
train_test_split (X, Y, test_size = 0.3, random_state=1234)
# Linear Regression
from sklearn.linear_model import LinearRegression

std_reg = LinearRegression()
# training on the Data
std_reg.fit(x_train, y_train)
# predict the results of test data
y_predict = std_reg.predict(x_test)
y_predict
# Get the R-Squared 
mlr_score = std_reg.score(x_test, y_test)
mlr_score
# Coefficient and Intercept
mlr_coefficient = std_reg.coef_
mlr_intercept = std_reg.intercept_

print(mlr_coefficient)
print(mlr_intercept)
# Equation of the line
#   y = 1.31  + 4.67*Hours + 5.1*SHours

# Calculate the errors using RMSE 
from sklearn.metrics import mean_squared_error
import math

mlr_rmse = math.sqrt(mean_squared_error(y_test, y_predict))
mlr_rmse<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09015025041736227, 'fraction_numerical': 0.01335559265442404, 'mean_word_length': 5.624309392265193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '53539', 'license': 'Apache-2.0', 'n_tokens_mistral': 465, 'n_tokens_neox': 438, 'n_words': 118, 'path': '4-multiple-linear-regression/2-multiple-linear-regression.ipynb', 'repo_name': 'saidulislam/data-science', 'size': '1198'}