2
$\begingroup$

I was wondering if anyone had any idea how to solve this problem.

So basically I have a dataset where some person approximately comes at some regular interval and I don't know what that interval is. I need to determine if the person comes in at approximately regular intervals, not necessarily what is the specifically value of the interval. For example if a certain person comes to my house to deliver milk over some period on say

Week 1: Mon, Wed, Fri,

Week 2:Mon, Wed, Fri

Week 3:Mon, Thu, Fri

Week 4:Mon, Wed, Fri

Week 5:Mon, Wed, Fri

Week 6:Mon, Wed, Fri

Week 7:Mon, Wed, Fri

Week 8:Mon, Thu, Fri

So as we can see out of these 8 weeks only in 2 weeks the person didn't come on Wednesday and instead came on Thursday which can be attributed to maybe a holiday the day before. So the solution to this example is that the person does follow a regular pattern.

Similarly this is another example. Say the person came on -

Mon, Thu, Sun, Wed, Sat, Tue, Fri, Mon, Wed, Sun

where this person follows a regular pattern because except for the last Wednesday he comes every fourth day.

This is an example of where a person doesn't follow a pattern, say the person came on

Mon, Wed, Sat, Fri, Thu, Fri, Wed, Fri, Sun, Sun, Sat

I have to do this for hundreds of different people.

Another equivalent problem is if I know which days over a certain period of time (say a month) some person arrives I need to determine if they follow some pattern or not

I thought about trying to fit the data into a sinusoidal curve but I'm not sure if it will work when I have a person who comes every say Mon, Tue, Fri or the 7th of every month or the first and third monday of every month etc.

I'm open to any method as long as it has good accuracy. Also, depending on whichever algorithm you think is best, if possible could you share a link to some code which solves a similar problem so I can get a general idea of how I'm supposed to implement my algorithm. I'm pretty new to machine learning / data science. Thank You!

$\endgroup$
0
$\begingroup$

It appears as though you are attempting to determine the presence of seasonality in this time series, i.e. a process that repeats itself at regular intervals.

In this regard, it might be a good idea to decompose your time series and check for the presence of seasonality trends.

As an example, this graph in R shows clear seasonality patterns for weather across different seasons:

seasonality

By decomposing the series, this might give visual cues as to whether seasonality exists among visits by individuals at particular times.

$\endgroup$
  • $\begingroup$ Thank you. I don't think this is a feasible solution because unless I misunderstood you I won't possibly be able to check each time series for a person visually if I have to to do it for hundreds of people. $\endgroup$ – maxachmed Apr 5 at 15:43
  • $\begingroup$ Fair point. While I would recommend examining seasonality in any case, one thing you could do is obtain the differences in visits across the dataset, i.e. 2 days, 3 days between each visit, etc. Then, plot these differences using a histogram - if you find that one particular time lag stands out then you could use this as a generalisation. $\endgroup$ – Michael Grogan Apr 5 at 15:52

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.