You are on page 1of 2

Multiple linear regression is a statistical method used to analyze the relationship between

multiple independent variables and a single dependent variable. It is an extension of simple


linear regression, which only involves one independent variable.

In multiple linear regression, the relationship between the independent variables and the
dependent variable is expressed in the form of an equation:

Y = β0 + β1X1 + β2X2 + ... + βnXn + ε

where Y is the dependent variable, X1, X2, ..., Xn are the independent variables, β0 is the
intercept or constant term, β1, β2, ..., βn are the coefficients that represent the effect of each
independent variable on the dependent variable, and ε is the error term.

The goal of multiple linear regression is to estimate the coefficients that best fit the data, and
to use this equation to make predictions about the dependent variable for new values of the
independent variables. This can be done using various statistical techniques, such as least
squares regression or maximum likelihood estimation.

Multiple linear regression can be used in many fields, such as economics, finance, marketing,
and engineering, to understand the relationships between different variables and to make
predictions about future outcomes. However, it is important to be aware of the assumptions
and limitations of the method, and to carefully interpret the results.

Example

from sklearn.linear_model import LinearRegression

import pandas as pd

# Load the dataset

data = pd.read_csv('data.csv')

# Define the predictor variables and the target variable

X = data[['var1', 'var2', 'var3']]

y = data['target']

# Create a linear regression model

model = LinearRegression()

# Fit the model to the data

model.fit(X, y)
# Print the coefficients of the model

print(model.coef_)

# Predict the target variable for a new set of predictor variables

new_data = pd.DataFrame({'var1': [1, 2, 3], 'var2': [4, 5, 6], 'var3': [7, 8, 9]})

predictions = model.predict(new_data)

print(predictions)

You might also like