p_splines.py 文件源码

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

项目:dstk 作者: jotterbach 项目源码 文件源码
def fit(self, values, targets, penalty=0.0):
        self._knots = _get_percentiles(values, num_percentiles=self.num_percentiles)
        self.basis_matrix = _get_basis_vector(values, self._knots)

        X = np.vstack((self.basis_matrix, np.sqrt(penalty) * self._penalty_matrix()))
        y = np.asarray(targets + np.zeros((self.num_percentiles + 2, 1)).flatten().tolist())

        self.spline = sm.OLS(y, X).fit()
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号