housing_regression.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:DATA-SCIENCE 作者: hjj1015 项目源码 文件源码
def plot_learning_curve(est, x, y):
    from sklearn.model_selection import learning_curve,KFold
    training_set_size, train_scores, test_scores = learning_curve(
        est, x, y, train_sizes=np.linspace(.1, 1, 20), cv=KFold(20, shuffle=True, random_state=1))
    estimator_name = est.__class__.__name__
    line = plt.plot(training_set_size, train_scores.mean(axis=1), '--',
                    label="training " + estimator_name)
    plt.plot(training_set_size, test_scores.mean(axis=1), '-',
             label="test " + estimator_name, c=line[0].get_color())
    plt.xlabel('Training set size')
    plt.ylabel('Score (R^2)')
    plt.ylim(0, 1.1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号