I'm pretty new in this field and I need some advice for my first professional challenge.

I'm trying to create a sort of client segmentation from a my company's sales log which has the peculiarity that the clients has a pretty long-term relationship and a periodic behavior.

  1. Based on when does he has bought (Ex: Twice a month, once a week, once every three months...) determine the frequency of purchase.

  2. I need to figure out the phase of this client, so I can know in what stage of his/her period is.

  3. I would like to know how much does it buys each time purchase amplitude

Once i have his three elements I want to be able to use that info to detect when the client changes his behavior (specially when they have an missing period or they decrease the buying amplitude)

I would like to get a really neat result, because i think that i will use it to a Markovian process.

So far I've tried astropy's lomb-scargle implementation but it seems that is too-precise and needs to many data points.

  • $\begingroup$ Not sure what you're asking here. You seem to have ideas -- try them out! I'm sure there is no canonical best solution here, especially since we don't know what you data look like. $\endgroup$
    – Raphael
    Aug 24, 2017 at 5:31

1 Answer 1


These are the steps you need to follow.

  1. Model

    You need to pick a model that you think explains your data. It can be very simple (e.g. linear regression) or very complex (e.g. a four-layer neural network). You want to pick as simple a model as possible!

    Example: Assume sales follow $s(x) = a + b\sin(cx)$.

  2. Train

    Using one part of the data, you determine which parameters of the model fit your data best. The method of training depends on your model of choice.

    Example: You fit the parameterized sine against the first half of your data with least-squares and find $(a,b,c) = (3,77, 13)$ is "best".

  3. Validate

    Inspect how well the model explains the rest of the data. You will have to decide in step 1 how you quantify quality here, and what your acceptance criteria are.

    Separately, if that makes sense in your domain, apply the model entirely different data sets that should follow the same model if your hypotheses are correct. Does it predict anything there? What does the answer say about your model and/or your assumptions?

    Example: Inspecting the squared error between $3 + 77\sin(13x)$ and the second half of the timeline data, you notice it is far too large.

  4. Iterate

    Unless the predictive quality of your model is good, go back to step 1. Sometimes, more training data can be the answer, too; note how that weakens your result, though.

  • $\begingroup$ Thanks Raphael, just a noob comment: Do you have any suggestions for start building my model? (anything to read...) $\endgroup$
    – pedropedro
    Aug 25, 2017 at 0:54
  • $\begingroup$ @pedropedro That's unfortunately outside of my area of expertise, sorry. You'd have to look into ML and/or data science sources. Artificial Intelligence, Data Science and Computational Science may be worth checking out, too. $\endgroup$
    – Raphael
    Aug 25, 2017 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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