  Motivated by a cycling infrastructure planning application, we present a
machine learning approach to solving bilevel programs with a large number of
independent followers, which as a special case includes two-stage stochastic
programming. We propose an optimization model that explicitly considers a
sampled subset of followers and exploits a machine learning model to estimate
the objective values of unsampled followers. Unlike existing approaches, we
embed machine learning model training into the optimization problem, which
allows us to employ follower features that cannot be represented using leader
decisions. We prove bounds on the optimality gap of the generated leader
decision as measured by the original objective that considers the full follower
set. We develop follower sampling algorithms to tighten the bounds and a
representation learning approach to learn follower features, which are used as
inputs to our machine learning model. Through numerical studies, we show that
our approach generates leader decisions of higher quality compared to
baselines. Finally, we perform a real-world case study in Toronto, Canada,
where we solve a cycling network design problem with over one million
followers. Compared to the current practice, our approach improves a
transportation metric by 19.2% and can lead to a potential cost saving of $18M.
