  The second $Gaia$ Data Release (DR2) contains astrometric and photometric
data for more than 1.6 billion objects with mean $Gaia$ $G$ magnitude $<$20.7,
including many Young Stellar Objects (YSOs) in different evolutionary stages.
In order to explore the YSO population of the Milky Way, we combined the $Gaia$
DR2 database with WISE and Planck measurements and made an all-sky
probabilistic catalogue of YSOs using machine learning techniques, such as
Support Vector Machines, Random Forests, or Neural Networks. Our input
catalogue contains 103 million objects from the DR2xAllWISE cross-match table.
We classified each object into four main classes: YSOs, extragalactic objects,
main-sequence stars and evolved stars. At a 90% probability threshold we
identified 1,129,295 YSO candidates. To demonstrate the quality and potential
of our YSO catalogue, here we present two applications of it. (1) We explore
the 3D structure of the Orion A star forming complex and show that the spatial
distribution of the YSOs classified by our procedure is in agreement with
recent results from the literature. (2) We use our catalogue to classify
published $Gaia$ Science Alerts. As $Gaia$ measures the sources at multiple
epochs, it can efficiently discover transient events, including sudden
brightness changes of YSOs caused by dynamic processes of their circumstellar
disk. However, in many cases the physical nature of the published alert sources
are not known. A cross-check with our new catalogue shows that about 30% more
of the published $Gaia$ alerts can most likely be attributed to YSO activity.
The catalogue can be also useful to identify YSOs among future $Gaia$ alerts.
