Skip to content

Instantly share code, notes, and snippets.

@andrea-dagostino
Last active August 1, 2022 09:45
Show Gist options
  • Select an option

  • Save andrea-dagostino/4b3e051983487287d6265eb76492237e to your computer and use it in GitHub Desktop.

Select an option

Save andrea-dagostino/4b3e051983487287d6265eb76492237e to your computer and use it in GitHub Desktop.
ts_clustering
def split_sequence(sequence, k):
"""
Split a sequence in two, where k is the size of the first sequence
"""
return np.array(sequence[:int(len(sequence) * k)]), np.array(sequence[int(len(sequence) * k):])
def split_sequences(sequences, k=0.80):
"""
Applies split_sequence on all elements of a list or array
"""
return [split_sequence(sequence, k) for sequence in sequences]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment