sampler.py 文件源码

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

项目:dzetsaka 作者: lennepkade 项目源码 文件源码
def transform_3d(self, X):
            X_resampled = sp.zeros((X.shape[0], self.n_samples, X.shape[2]))
            xnew = sp.linspace(0, 1, self.n_samples)
            for i in range(X.shape[0]):
                end = last_index(X[i])
                for j in range(X.shape[2]):
                    X_resampled[i, :, j] = resampled(X[i, :end, j], n_samples=self.n_samples, kind=self.interp_kind)
                # Compute indices based on alignment of dimension self.scaling_col_idx with the reference
                indices_xy = [[] for _ in range(self.n_samples)]

                if self.save_path and len(DTWSampler.saved_dtw_path)==(self.d+1): # verify if full dtw path already exists
                    current_path = DTWSampler.saved_dtw_path[i]
                else:
                    # append path
                    current_path = dtw_path(X_resampled[i, :, self.scaling_col_idx], self.reference_series)           
                    if self.save_path: # save current path is asked
                        DTWSampler.saved_dtw_path.append(current_path)                

                for t_current, t_ref in current_path:
                    indices_xy[t_ref].append(t_current)
                for j in range(X.shape[2]):
                    if False and j == self.scaling_col_idx:
                        X_resampled[i, :, j] = xnew
                    else:
                        ynew = sp.array([sp.mean(X_resampled[i, indices, j]) for indices in indices_xy])
                        X_resampled[i, :, j] = ynew
            return X_resampled
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号