scikit-learning 多项式回归应用房价预测

本文使用scikit-learn库的load_boston数据集,通过一到三阶多项式回归模型进行房价预测。结果显示,一阶多项式存在欠拟合现象,二阶多项式模型拟合效果较好,而三阶多项式模型由于特征个数超过样本数量导致过拟合。
摘要由CSDN通过智能技术生成

将sklearn.datasets中的load_boston房价数据用多项式回归进行训练,并画出学习曲线

import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import Pipeline
from common.utils import plot_learning_curve
from sklearn.model_selection import ShuffleSplit

def get_bosten_houst_price_train_test_data():
    bosten_houst_price_data = load_boston()
    x = bosten_houst_price_data.data
    y = bosten_houst_price_data.target
    print(bosten_houst_price_data.feature_names)
    #print(x)
    print(x.shape)
    x_train
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值