Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save andrea-dagostino/37b31626926fd4bf9a72d04d4af29fe5 to your computer and use it in GitHub Desktop.
ts_clustering
N = 15 # window size --> we can tweak it and test different options
K = 0.70 # split size --> 80% of the data is in A, 20% in B
SEQS = split_time_series(list(data['Close'].values), N) # creates sequences of length N
SPLIT_SEQS = split_sequences(SEQS, K) # splits sequences into individual sequences
A = [seq[0] for seq in SPLIT_SEQS]
B = [seq[1] for seq in SPLIT_SEQS]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment