  We add the magnetic degrees of freedom to the widely used Gaussian
Approximation Potential of machine learning (ML) and present a model that
describes the potential energy surface of a crystal based on the atomic
coordinates as well as their noncollinear magnetic moments. Assuming an
adiabatic approximation for the spin directions and magnitudes, the ML model
depends solely on spin coordinates and orientation, resulting in computational
efffciency and enabling ab initio spin dynamics. Leveraging rotational
symmetries of magnetic interactions, the ML model can incorporate various
magnetic interactions, expanding into two-body, three-body terms, etc.,
following the spirit of cluster expansion. For simplicity, we implement the ML
model with a two-body form for the exchange interaction. Comparing total
energies and local fields predicted by the model for noncollinear spin
arrangements with explicit results of constrained noncollinear density
functional calculations for bcc Fe yields excellent results, within 1 meV/spin
for the total energy. Further optimization, including three-body and other
terms, is expected to encompass diverse magnetic interactions and enhance the
model's accuracy. This will extend the model's applicability to a wide range of
materials and facilitate the machine learning ab initio spin dynamics.
