Create Baseline Regression Model


# Load libraries
from sklearn.datasets import load_boston
from sklearn.dummy import DummyRegressor
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

Load Boston Housing Dataset

# Load data
boston = load_boston()

# Create features
X, y =,

Split Data Into Training And Test Set

# Make test and training split
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

Create Dummy Regression Always Predicts The Mean Value Of Target

# Create a dummy regressor
dummy_mean = DummyRegressor(strategy='mean')

# "Train" dummy regressor, y_train)
DummyRegressor(constant=None, quantile=None, strategy='mean')

Create Dummy Regression Always Predicts A Constant Value

# Create a dummy regressor
dummy_constant = DummyRegressor(strategy='constant', constant=20)

# "Train" dummy regressor, y_train)
DummyRegressor(constant=array(20), quantile=None, strategy='constant')

Evaluate Performance Metric

# Get R-squared score
dummy_constant.score(X_test, y_test)