Machine Learning is making the computer learn from studying data and statistics. Machine Learning is a step into the direction of artificial intelligence (AI). Machine Learning is a program that analyses data and learns to predict the outcome.

What is Regression?

The term regression is used when you try to find the relationship between variables. In Machine Learning and statistical modelling, that relationship is used to predict the outcome of future events.

Multiple Regression

Multiple regression is like linear regression, but with more than one independent value, meaning that we try to predict a value based on two or more variables.

Image for post

We can predict the CO2 emission of a car based on the size of the engine, but with multiple regression we can throw in more variables, like the weight of the car, to make the prediction more accurate.

Getting Started

In Python we have modules that will do the work for us. Start by importing the Pandas module.

import pandas

The Pandas module allows us to read csv files and return a DataFrame object.

df = pandas.read_csv("cars.csv")

Then make a list of the independent values and call this variable x. Put the dependent values in a variable called y.

X = df[['Weight', 'Volume']]
y = df['CO2']

We will use some methods from the sklearn module, so we will have to import that module as well:

from sklearn import linear_model

From the sklearn module we will use the ‘LinearRegression’ method to create a linear regression object.

regr = linear_model.LinearRegression()
regr.fit(X, y)

Now we have a regression object that are ready to predict CO2 values based on a car’s weight and volume:

predictedCO2 = regr.predict([[2300, 1300]])

#data-science #machine-learning #artificial-intelligence #programming #technology

The Ultimate Beginners Guide to Multiple Regression in Python.
1.30 GEEK