Hands On Machine Learning – Example 1.1 with CSV

Required CSV

oecd_bli_2015.csv

gdp_per_capita.csv

 

prepare_country_stats()

 

Completed code for example 1.1

 

Plotting using sklearn.linear_model.LinearRegression():

 

 

 

 

 

 

 

 

 

 

 

 

Plotting using sklearn.neighbors.KNeighborsRegressor()with sampling n = 3: