For Facebook users, checking in to a place from your phone (and now, adding location to any post) is a simple way to keep your friends updated on all the places you’re going and things you’re doing. Before starting my internship at Facebook, I thought checking in was fun, but I never considered the additional value of check-ins from the perspective of an engineer.

After working here for a summer, I see check-ins in a new light: by providing information about how people interact with businesses, they allow us to create a better product experience for our users. In particular, our check-in data was extremely useful to me during my internship as I worked on several projects intended to help users find open businesses: writing an algorithm to predict hours of operation, building crowd-sourcing tools to obtain actual hours, and developing rules for validating user-suggested hours.

Predicting Operating Hours

Early in the summer, I started looking into the distribution of check-in times for individual places. For instance, I examined the times of day when people check in to places like restaurants, bars, stadiums, and tourist attractions:

With this type of data, it seemed like it would be possible to make good predictions of when places were open. To do so, I developed a simple algorithm consisting of three main steps:

  • Making initial predictions. We first set an openness threshold representing the minimum number of check-ins that must occur during a given hour of the week for us to predict the place as open during that hour. This threshold should be large enough to ensure that the algorithm is robust to stray check-ins that occur even when the place is closed. On the other hand, if the threshold is too large, we might miss hours during which the place is open but has few check-ins. Currently, we set the threshold as a fixed percentage of the total number of check-ins, a simple decision that works well for our purposes.
  • Filling short gaps. Many places have “slow hours” when they are open but have relatively few visitors. For instance, restaurants might experience lulls in the afternoon between lunch and dinner. For this reason, the second step of the algorithm consists of taking a second pass over the initial predictions, finding any short spans of closed predictions sandwiched by open predictions, and marking those spans as open.
  • Aggregating across days. The final step of the algorithm collapses the predictions across days based on the assumption that places tend to have similar hours on different days of the week. If the predictions for a group of consecutive days are sufficiently similar, we combine those days into one group. For each group, we compute a single set of predictions in which the prediction for a given hour equals the majority prediction for that hour from the days in the group.

So far, we are using the predictions from this algorithm in two ways. First, we’ve started factoring them into the ranking function for the check-in search page so that places predicted as currently open show up higher in the search results list. Imagine that you’re checking in to a place in Palo Alto from your smart phone and you’ve typed in the letter “I”. If it’s 11am, you’re more likely to be looking for Izzy’s Brooklyn Bagels than Illusions Nightclub, whereas the opposite is true if it’s 11pm. We use the hour predictions to help you find the right place more quickly in situations like this.

Second, in order to expose the prediction information to users, I added a new field called “Hours (estimated)” to the Info tab of Place Pages without official hours. Note that if you come across a place without official or estimated hours listed, it’s either because the place doesn’t have enough check-ins for us to make good predictions or because the check-ins occur so frequently at all hours of the day that the place appears to be always open. Also, we treat 5am as the start of the day, so you might see places predicted to close after midnight in the early hours of the morning. The algorithm certainly isn’t perfect, but it does well for many places. For example, the Chipotle nearest to Stanford’s campus is open daily from 11am to 10pm, and we predict those exact hours:

Getting Help from Our Users

For some places, people don’t start checking in until a few hours after opening or keep checking in after the official closing time, so our predictions are a bit off. To let users help fix our predicted hours, I implemented a new interface for suggesting hours and added it to the “Suggest Information” section on Place Pages.

I also added the ability for users to enter hours in the Places Editor, Facebook’s crowd-sourcing tool that helps us obtain accurate information about places.

If you try suggesting hours for a place, you might find that your suggested hours don’t appear right away on the Place Page. Like all of our user suggestions, they must go through a validation process. In general, to decide whether to accept a suggestion as fact, we consider all of the suggestions we have for that field and determine whether there is agreement on a single value. We trust suggestions more if they come from users who have made accurate suggestions in the past.

While writing the code to decide which hour suggestions to accept, I found that our check-in data came in handy yet again. I developed a “check-in similarity score” that quantifies the similarity between a user’s suggested hours and the times when people actually visit a place. If the similarity score is high and the suggestion comes from a trusted user, it can be accepted immediately.

Improving the User Experience

As a final piece of my work with hours, I added a few simple features to make the open status of places with accepted hours more visible to users. For instance, I added a “Status” field on the Info tab of place pages to show whether a place is currently open (and how long it will remain open) or closed (and when it will open next). I also added this information to the Places tab of city Pages, where users can search through places in a city by category and now also see which ones are currently open.

Overall, during my internship this summer, I helped make progress towards obtaining and displaying accurate hours for as many of our Place Pages as possible. As a result of this work, the check-in weighted percentage of places with listed hours (either estimated or official) has increased from 12% to 62%, and it will continue to increase as the user suggestions for hours keep coming in.

Ultimately, we want Facebook to have the information necessary to help tell you exactly where you can find an early-morning cup of coffee, a late-night snack, or a Saturday afternoon farmers market. I loved having the opportunity this summer to contribute to that goal.

Laney Kuenzel is an engineering intern on the Entities team.

Leave a Reply

To help personalize content, tailor and measure ads, and provide a safer experience, we use cookies. By clicking or navigating the site, you agree to allow our collection of information on and off Facebook through cookies. Learn more, including about available controls: Cookies Policy