Algorithm for segmentation of sequence data
I have a large sequence of vectors of length N. I need some unsupervised learning algorithm to divide these vectors into M segments.
For example:

K-means is not suitable, because it puts similar elements from different locations into a single cluster.
Update:
The real data looks like this:

Here, I see 3 clusters: [0..50], [50..200], [200..250]
Update 2:
I used modified k-means and got this acceptable result:

Borders of clusters: [0, 38, 195, 246]
Topic sequence clustering machine-learning
Category Data Science
As you see for instance a threshold of 20 (i.e.
