Source: 🤖Homemade Machine Learning repository
☝Before moving on with this demo you might want to take a look at:
Linear regression is a linear model, e.g. a model that assumes a linear relationship between the input variables (x)
and the single output variable (y)
. More specifically, that output variable (y)
can be calculated from a linear combination of the input variables (x)
.
Multivariate Linear Regression is a linear regression that has more than one input parameter and one output label.
Demo Project: In this demo we will build a model that will predict
Happiness.Score
for the countries based onEconomy.GDP.per.Capita
andFreedom
parameters.
# To make debugging of linear_regression module easier we enable imported modules autoreloading feature.
# By doing this you may change the code of linear_regression library and all these changes will be available here.
%load_ext autoreload
%autoreload 2
# Add project root folder to module loading paths.
import sys
sys.path.append('../..')
# Import 3rd party dependencies.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly
import plotly.graph_objs as go
# Configure Plotly to be rendered inline in the notebook.
plotly.offline.init_notebook_mode()
# Import custom linear regression implementation.
from homemade.linear_regression import LinearRegression