top of page

Multiple Linear Regression:

Instead of just looking at how one thing relates to another thing (simple linear regression), you can look at the relationship between a lot of different things and the thing you want to predict.

A linear regression model is a statistical model that’s frequently used in data science.

It’s also one of the basic building blocks of machine learning! Multiple linear regression (MLR/multiple regression) is a statistical technique.

It can use several variables to predict the outcome of a different variable.

The goal of multiple regression is to model the linear relationship between your independent variables and your dependent variable.

It looks at how multiple independent variables are related to a dependent variable.

Project | 03
Project | 03 Multiple Linear Regression

 

 

# Importing the dataset
dataset = read.csv('50_Startups.csv')

# Encoding categorical data
dataset$State = factor(dataset$State,
                       levels = c('New York', 'California', 'Florida'),
                       labels = c(1, 2, 3))

 

# Splitting the dataset into the Training set and Test set
# install.packages('caTools')
library(caTools)
set.seed(123)
split = sample.split(dataset$Profit, SplitRatio = 0.8)
training_set = subset(dataset, split == TRUE)
test_set = subset(dataset, split == FALSE)

 

# Feature Scaling
# training_set = scale(training_set)
# test_set = scale(test_set)

 

# Fitting Multiple Linear Regression to the Training set
regressor = lm(formula = Profit ~ .,
               data = training_set)

 

# Predicting the Test set results
y_pred = predict(regressor, newdata = test_set)

bottom of page