predict.py 文件源码

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

项目:momoCrawler 作者: njames741 项目源码 文件源码
def _leave_one_out(algr, X, y):
    loo = LeaveOneOut()
    square_error_sum = 0.0
    for train_index, test_index in loo.split(X):
        X_train, X_test = X[train_index], X[test_index]
        y_train, y_test = y[train_index], y[test_index]
        model = algr.fit(X_train, y_train.ravel())
        predicted_y = model.predict(X_test)
        square_error_sum += float(y_test[0] - predicted_y) ** 2
    mse = square_error_sum / X.shape[0]
    print '-----------------------'
    print 'Leave One Out?mse ' , mse
    print '-----------------------'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号