Linear Regression - Part 3

In this section, we shall try to apply machine learning to a well known boston dataset.

Real World Examples


In [ ]:
from sklearn.datasets import load_boston

data = load_boston()

In [ ]:
print(data.DESCR)

In [ ]:
data.data[1]

In [ ]:
data.target[1]

In [ ]:
X = data.data
Y = data.target

In [ ]:
from sklearn.dummy import DummyRegressor
dummy_regr = DummyRegressor(strategy="median")
dummy_regr.fit(X, Y)

In [ ]:
from sklearn.metrics import mean_squared_error
mean_squared_error(Y, dummy_regr.predict(X))

In [ ]:
from sklearn import linear_model
regr = linear_model.LinearRegression()
regr.fit(X, Y)

In [ ]:
mean_squared_error(Y, regr.predict(X))

In [1]:
from sklearn.svm import LinearSVR
# Step1: create an instance class as `regr`
# Step2: fit the data into class instance

In [ ]:
# score
mean_squared_error(Y, regr.predict(X))

In [ ]:
from sklearn.ensemble import RandomForestRegressor
# set random_state as zero

In [ ]:
# score

K-NearestNeighbors


In [ ]:


In [ ]: