xgboost.py 文件源码

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

项目:search-MjoLniR 作者: wikimedia 项目源码 文件源码
def _loess_predict(X, y_tr, X_pred, bandwidth):
    X_tr = np.column_stack((np.ones_like(X), X))
    X_te = np.column_stack((np.ones_like(X_pred), X_pred))
    y_te = []
    for x in X_te:
        ws = np.exp(-np.sum((X_tr - x)**2, axis=1) / (2 * bandwidth**2))
        W = scipy.sparse.dia_matrix((ws, 0), shape=(X_tr.shape[0],) * 2)
        theta = np.linalg.pinv(X_tr.T.dot(W.dot(X_tr))).dot(X_tr.T.dot(W.dot(y_tr)))
        y_te.append(np.dot(x, theta))
    return np.array(y_te)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号