regressor.py 文件源码

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

项目:piecewise 作者: DataDog 项目源码 文件源码
def predict(self, t_new):
        """ Use the segments in this model to predict the v value for new t values.
        Params:
            t_new (np.array): t values for which predictions should be made
        Returns:
            np.array of predictions
        """
        v_hats = np.empty_like(t_new, dtype=float)
        for idx, t in enumerate(t_new):
            # Find the applicable segment.
            seg_index = bisect.bisect_left(self._starts, t) - 1
            seg = self.segments[max(0, seg_index)]
            # Use it for prediction
            v_hats[idx] = seg.predict(t)
        return v_hats


## Data structures used during the fitting of the regression in `piecewise()`.


# Segment represents a time range and a linear regression fit through it.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号