le.py 文件源码

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

项目:AliMusicTrendPredict 作者: strint 项目源码 文件源码
def fitJA(j, start_date_rank):
    pltf.clf()
    p = artists_play_inday[j]
    p = p[start_date_rank:]
    print p
    apcount = [0] * (183 - start_date_rank)
    apdate = range(start_date_rank, 183)
    for i in p:
        apcount[i[1] - start_date_rank] = i[0]

    print apcount

    d_train = np.asarray(apdate)
    c_train = np.asarray(apcount)

    # create matrix versions of these arrays
    D_train = d_train[:, np.newaxis]
    d_test_plot = np.asarray(range(start_date_rank, 244))
    D_test_plot = d_test_plot[:, np.newaxis]

    pltf.scatter(d_train, c_train, label="training points")

    for degree in [1,2,3]:
        model = make_pipeline(PolynomialFeatures(degree), Ridge())
        model.fit(D_train, c_train)
        c_test_plot = model.predict(D_test_plot)
        pltf.plot(d_test_plot, c_test_plot, label="degree %d" % degree)

    pltf.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=5, mode="expand", borderaxespad=0.)
    pltf.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号