# Predict the best time of call

I have a dataset including a set of customers in different cities of California, time of calling for each customer, and the status of call (True if customer answers the call and False if customer does not answer).

I have to find an appropriate time of calling for future customers such that the probability of answering the call is high. So, what is the best strategy for this problem? Should I consider it as a classification problem which the hours (0,1,2,... 23) are the classes? Or should I consider it as a regression task which the time is a continuous variable? How can I make sure that the probability of answering the call will be high?

Any help would be appreciated. It also would be great if you refer me to similar problems.

Below is a snapshot of the data.

You might actually encounter problems if you model this as a regression problem without a suitable transformation. For instance, we know that most calls are probably answered during daytime and less during night time and early morning. A linear regression would have difficulty because the relationship is likely curvilinear, not linear. For the same reason, treating this as a classification task with logistic regression would also be problematic.

As suggested by other respondents, reclassifying your data into time periods will help, and I'd suggest you try something like a decision tree or random forest first.

That all said, this might be a case for simple descriptive statistics. If you plot the proportion answered calls by time of day (split by city or any other demographic), is there a clear best time? If so, why complicate things with a model?

You could try the following:

1. Divide up the day into various parts - early-morning, morning, noon, afternoon, evening, late evening, night, etc.
2. Assign time boundaries to each part of the day, e.g. noon could be 12 pm to 1 pm.
3. Create 3 new labels - "part of the day to call the customer", for each positive case (status of call=true) assign it the corresponding label (morning/noon/evening). These labels will be in one-hot encoded format e.g. prefer_morning=0/1, prefer_noon, prefer_evening, etc.
4. Build 3 models to predict whether the lead prefers morning/noon/or evening time of the day for a call to be successful.

Additionally, I recommend adding additional features such as occupation, gender, etc. since the features listed in the table (city, etc.) are too ambiguous and do not give much information to differentiate among customers.

EDITED as per suggestion in comments:

When using the model, each lead would get classified as prefers_morning=yes/no, prefers_noon=yes/no and prefers_evening=yes/no. Based on the time of the day, for example in the morning, the call center agent (or software) could pick up and call leads classified in the morning preference set. When its noon, the call software picks up form the noon preferred list, and so on.

• @sandeep-s-sandhu This is a simple way to convert the problem to a data science classification problem. But it seems that this approach may have some disadvantages: 1. label information only includes positive case, loss the information of negative case 2. A customer can only have one of the labels. In practice, a customer can have more than one label (i.e., I prefer people to call me at either late evening or night.). What do you think? – nkhuyu Nov 29 '16 at 23:15
• @nkhuyu, 1) the label also includes negative case. I think you misunderstood the statement "Create a new label - "part of the day to call the customer", for each positive case (status of call=true)". This step intends to create an additional label, the original label of whether the call was successful or not remains as-is. 2) Yes, you're right, edited the answer to reflect this. – Sandeep S. Sandhu Nov 30 '16 at 4:20
• @sandeep-s-sabdhu Thank you for the response. Yes, I misunderstood it. OK. Then you will have two labels (status of call, your new label). Then how can you solve this problem? It's not a regular classification problem. – nkhuyu Nov 30 '16 at 4:33
• @nkhuyu, thanks for noting this, I've now edited and clarified this in step #4. Each of the three models will give a set of leads who will pick the call for that particular time of day, the call center uses this to prioritize their calls. – Sandeep S. Sandhu Nov 30 '16 at 5:49
• Step 1 is followed by step 3 and I've suggested these to create appropriate labels for training. The main query was - "I have to find an appropriate time of calling...". Its up to the OP to decide if these should be morning/noon/evening or more granular such as by the hour. – Sandeep S. Sandhu Aug 16 '17 at 12:00

I would use a logistic regression - you're going to need sample's where they did not pick up. Then I would treat the hour as a seasonal dummy regressor (23 hours as dummy variables and let one flow to the intercept).

If you do not treat it as a seasonal dummy regressor, you are going to have to perform some sort of transformation, because the relationship isn't going to be linear.

Someone previously suggested substituting mid-afternoon, etc as a categorical variable. That is a bad idea because you have the detail and you're losing detail there. That would have a similar effect to utilizing optimal binning to make the relationship linear, but I still don't think that would work. Try the seasonal dummy regressors.