I want to build a machine learning model to choose a location for the next vending machine in Boston. I want to divide the map into small neighborhood, and I came up with features that are related to the geospatial locations and user information.

One paradox that concerns me is that: we'll use past vending machines' features (X) and sales (y) to train the model; in that case, the model that predict the next vending machine will likely choose some place very close to the old vending machine locations. But at the same time, we wouldn't want to build a vending machine in exactly the same location as an older one.

Additionally, vending machines are usually built one by one as time goes by; the model used to choose the 10th vending machine in the city, and the 1300th vending machine could be very different. This almost made me think this is a time-series problem. How to build a model that can take these problems into consideration? Any insight on features, logistics, or models are all deeply appreciated!

  • $\begingroup$ Possibly relevant: arxiv.org/abs/2110.10819. $\endgroup$ Sep 29, 2022 at 15:50
  • 5
    $\begingroup$ "predict the next vending machine location" This sounds a bit like an odd question. Why do you do this? Are you the person that has to choose the location and wishes to find the best location for improving sales, or are you an outsider to the company that (for whatever reason) wants to predict how vending machine companies are deciding on their next location? Is this homework? $\endgroup$ Sep 29, 2022 at 15:59
  • 4
    $\begingroup$ Site selection is not this simple. Placing a new vending machine "cannibalizes" sales from nearby ones. A time series approach is likely doomed because the characteristics of the market change as vending machines are installed. People who solve these problems well (and there are few of them, I believe) model the economic dynamics of the marketplace, including where customers live, how they travel, what their needs are, what resources they have, how they choose among competing options, and so on. $\endgroup$
    – whuber
    Sep 29, 2022 at 19:32

4 Answers 4


Let's consider the inputs and outputs for a moment.

Say your model takes as inputs things like sales and geolocation. The output is if that location is a vending machine or not.

Now...is that useful? Your model does not tell you where to place a vending machine. It tells you if that spot on the map is already a vending machine. That isn't what you want.

What you likely want is to find a location on the map which is not a vending machine and optimizes some criteria (likely potential sales). You might want:

  • A lot of foot traffic
  • Not to be too close to other vending machines
  • etc.

You need to feed in all that information into some sort of function which scores the location in terms of it being a good or bad location based on the above criteria. Then, you want to find the location which optimizes that function.

A really simple example of this might be to put a vending machine somewhere which is farthest from all other vending machines. Of course this might put the machine in the middle of a field somewhere, which is why you need to add constraints to this optimization somehow.

  • $\begingroup$ What if you had data from 5 years ago when there were less vending machines, and you trained it to predict where you put the vending machines in the last 5 years? $\endgroup$
    – user253751
    Sep 29, 2022 at 17:02
  • $\begingroup$ @user253751 Possibly, that model could predict "This location is likely to meet the constrained optimization implicit in the placement of the vending machines within the last 5 years". I suppose the question becomes if that optimization has since changed. If not, then that might work. $\endgroup$ Sep 29, 2022 at 17:25
  • $\begingroup$ @user253751 I will say this however; the features necessary to do this would likely go beyond what OP has mentioned. $\endgroup$ Sep 29, 2022 at 17:50

I would try to create some explanatory variables for each geographic location, such as the income distribution at this location, traffic, amount of pedestrians, and similar features. Then I would use the data from existing vending machines to train a model that predicts your response variable from those explanatory variables, e.g. the profit made by a vending machine.

If that works, you can predict for each spot in the city the amount of money made by a vending machine placed there. Then you select the places where this prediction returns particularly favorable values and where you don't already have a vending machine.

You might also do an experiment and place some new vending machines next to already existing ones, use (some function of) the distances to other vending machines as an additional explanatory variable, and thus learn how the "vending machine density" of a location affects the sales of a new vending machine.

I don't really see a time series property here. I would guess that the sales numbers of a vending machine are only affected by the explanatory features referred to above. If the sales numbers of a vending machine depend on those of previously installed vending machines then, I would suspect, only via those features.


@whuber made a very good point: "Placing a new vending machine 'cannibalizes' sales from nearby ones". Cannibalization may be desirable or not, depending on whether the OP is eating the market of his competitor, or himself.

Instead of a writing a machine learner to predict locations, it might be more useful to simulate vending machines. We have a City, say 東京, with existing vending machines owned by a number of companies (maybe try modelling as 2, Us and Them). Initially I imagine that the obvious good locations, such railway stations,are taken. We have a number of graphical views, such number of potential customers, distance to nearest machine, revenue of each machine, etc. Now you can model the effects of new locations, and new products, subject to whatever assumptions you may be making. Next step might be allowing the simulation to try out new locations, Monte Carlo style.


If you want to frame it as a time series problem, then you might want to go the autoregressive decoder route, where you feed in the sequence of past "outputs" (using teacher forcing, as is commonly used to parallelize transformer model training) in addition to your regular input features in order to help the model predict the next location. Note that the time series formulation and using the historical data as ground truth assumes that the historical placements and timings were optimal, which is a shaky assumption. However, you should be able to approximate human performance provided you have supplied your model with enough information.

Note that this is likely a high perplexity task so don't expect your training losses to get very low-- but even an RNN should be a good fit for this. Recurrent memories retain information about likely candidates and can pivot to another close or "next-best" option if the model's top-1 pick in the current timeframe isn't the "best fit" to the historical data.

In any case, it sounds to me like your problem has an inherent autoregressive property. If you wanted to flatten out the time element, the problem becomes something like, "given the currently deployed machines and the other input features, predict a heatmap, top-k or a single-best location for future machines", for which a variety of architectures could be reasonable candidates.


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.