def add_query_subsequence(self, subsequence): self.n_query_subsequences += 1 if not self.is_leaf: distances = [time_series_twed(subsequence, node.center) for node in self.children] nearest_child = self.children[np.argmin(distances)] nearest_child.add_query_subsequence(subsequence)
def add_db_subsequence(self, subsequence, level=0): if self.is_leaf: counter = Counter({subsequence.original_id: 1}) self._inverted_file += counter else: distances = [time_series_twed(subsequence, node.center) for node in self.children] nearest_child = self.children[np.argmin(distances)] nearest_child.add_db_subsequence(subsequence, level+1)
def add_query_subsequence(self, subsequence): self.n_query_subsequences += 1 self.tree.active_nodes.append(self) # self.tree.score = self.tree.score.add(self.weight*self.d_vector, fill_value=0) if not self.is_leaf: distances = [ time_series_twed(subsequence, node.center) for node in self.children ] nearest_child = self.children[np.argmin(distances)] nearest_child.add_query_subsequence(subsequence)