6. Ensemble Modeling
Activity 6.01: Stacking with Standalone and Ensemble Algorithms
Solution
- Import the relevant libraries:
import pandas as pd import numpy as np import seaborn as sns %matplotlib inline import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.metrics import mean_absolute_error from sklearn.model_selection import KFold from sklearn.linear_model import LinearRegression from sklearn.tree import DecisionTreeRegressor from sklearn.neighbors import KNeighborsRegressor from sklearn.ensemble import GradientBoostingRegressor, \ RandomForestRegressor
- Read the data:
data = pd.read_csv('boston_house_prices.csv') data.head()
Note
The preceding code snippet assumes that the dataset is presented in the same folder as that of the exercise notebook. However, if your dataset is present in the
Datasets
folder, you need to use the following code:data = pd.read_csv('../Datasets/boston_house_prices.csv')
You will...