正则化线性回归(波士顿房价预测)
导入模块
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from sklearn.linear_model import Lasso
from sklearn.linear_model import Ridge
from sklearn.linear_model import ElasticNet
%matplotlib inline
font = FontProperties(fname='/Library/Fonts/Heiti.ttc')
获取数据
df = pd.read_csv('housing-data.txt', sep='\s+', header=0)
X = df[['RM']].values
y = df['MEDV'].values