The highly anisotropic thermal conductivity in layered materials is crucial for a broad range of applications such as thermal management of electronic devices, thermal insulation, and thermoelectrics. Understanding of anisotropic thermal transport in layered materials largely depends on atomistic simulations based on density functional theory (DFT) or empirical potentials, which however suffer either low computational efficiency or accuracy. Recently, machine learning interatomic potentials (MLIPs) are emerging as a powerful tool to bridge the gap. Despite the recent progress in developing MLIPs, little attention has been paid to constructing a potential that can accurately predict the thermal properties of layered materials, which is more challenging compared with the case of isotropic materials because of the highly anisotropic bonding and weak van der Waals interactions in layered materials. Here, we introduce a MLIP within the Gaussian approximation potential (GAP) framework for bulk hexagonal boron nitride (h-BN) with a typical layered structure. We demonstrate that the GAP can well predict the highly anisotropic phonon transport properties and thermal conductivity of bulk h-BN with DFT-level accuracy at 3 orders of magnitude reduced cost. Particularly, we investigate the effect of four-phonon scattering on the thermal conductivity of bulk h-BN using the GAP. The suppression of thermal conductivity by four-phonon scattering is negligible below 300 K due to the orders of magnitude weaker four-phonon scattering than three-phonon scattering, which is mainly attributed to the breaking of the reflection symmetry selection rule and the splitting of the flexural acoustic branch in bulk h-BN. As temperature increases, four-phonon scattering results in a larger reduction in thermal conductivity, which increases up to 21.64% (in-plane) and 35.71% (cross-plane) at 1000 K. Atomistic simulations based on MLIPs are expected to be able to greatly promote the understanding of phonon transport and the prediction of thermophysical properties in layered materials.