  We present a machine learning model to classify Active Galactic Nuclei (AGN)
and galaxies (AGN-galaxy classifier) and a model to identify type 1 (optically
unabsorbed) and type 2 (optically absorbed) AGN (type 1/2 classifier). We test
tree-based algorithms, using training samples built from the X-ray Multi-Mirror
Mission -Newton (XMM-Newton) catalogue and the Sloan Digital Sky Survey (SDSS),
with labels derived from the SDSS survey. The performance was tested making use
of simulations and of cross-validation techniques. With a set of features
including spectroscopic redshifts and X-ray parameters connected to source
properties (e.g. fluxes and extension), as well as features related to X-ray
instrumental conditions, the precision and recall for AGN identification are 94
and 93 per cent, while the type 1/2 classifier has a precision of 74 per cent
and a recall of 80 per cent for type 2 AGN. The performance obtained with
photometric redshifts is very similar to that achieved with spectroscopic
redshifts in both test cases, while there is a decrease in performance when
excluding redshifts. Our machine learning model trained on X-ray features can
accurately identify AGN in extragalactic surveys. The type 1/2 classifier has a
valuable performance for type 2 AGN, but its ability to generalise without
redshifts is hampered by the limited census of absorbed AGN at high redshift.
