0
$\begingroup$

I clustered my dataset based on location using DBSCAN(haversine). Everything is OK until this. However, I'd like to use the time series while I'm clustering my dataset. For example. You were at home at 13 pm and went to the market and park for one hour per each and came back home. In this case, the algorithm provides "1" cluster number each time for home which is extremely normal. But I want to give different cluster number for last home cluster if there is another cluster between home clusters.

Another idea is clustering time with the location. it doesn't have to be another cluster between home clusters. If there is a one-hour difference or another different time period, I'd like to see another cluster for it.

So, do you think is it possible to do it?

Example dataset looks like

location    time      cluster   cluster_want_to_see
home        13.08.10  1         1 
home        13.08.28  1         1 
home        13.08.68  1         1 
market      14.09.50  9         9  
market      14.20.51  9         9 
market      14.30.10  9         9
park        15.10.16  3         3 
park        15.50.02  3         3 
home        16.15.10  1         **7**   #return to home must be in another cluster
home        16.17.23  1         **7**
market2     17.02.36  5         5
market2     17.02.58  5         5
home        18.08.02  1         **8**
home        18.23.05  1         **8**   
$\endgroup$
0
$\begingroup$

You could use Generalized DBSCAN and use two thresholds. One eps on distance, and one eps on time.

Or you just do postprocessing:

If there is a different cluster inbetween, then relabel the points to a new cluster... That is straightforward and easy to code...

$\endgroup$
  • $\begingroup$ I don't understand about the second method. If I'm wrong pls correct me but you recommend to me creating two different clusters for location and time, don't you? Then compare them and if there is a different cluster, give another cluster label. Is it right? If it is right, I already tried it, however, clustering time series is a big nightmare. I couldn't figure out how to decide the fit value. I mean before using the clustering method, as you know I need to create a matrix for fitting to the clustering algorithm. OK, the first one is time but what should I choose for the second one? $\endgroup$ – emily.mi Mar 4 at 15:23
  • $\begingroup$ No. I'm saying to split clusters in postprocessing if there is a differently labeled point inbetween. So in your example, between the first 1s and the bottom 1s there is 9 and 3. So you would split the top 1s from the bottom 1s, because there is a different cluster inbetween. $\endgroup$ – Anony-Mousse Mar 4 at 15:59
  • $\begingroup$ I got it what you mean. But don't you think it will be very costly? It must compare every value with the previous value. It necessary big "for loop," I think. What do you think? $\endgroup$ – emily.mi Mar 5 at 16:08
  • $\begingroup$ No, if your data is sorted by time, then it is O(n), a trivial for loop over the sorted data. Compared to DBSCAN it's incredibly cheap. $\endgroup$ – Anony-Mousse Mar 5 at 19:06
  • $\begingroup$ Hi again. I really don't understand how I can realize the splitting the data without the "for loop". Could you please give me more detail? I understand the idea, and I really like it. But how? or can you give me a "keyword" for searching your idea in the google? $\endgroup$ – emily.mi Mar 11 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.