Context. As an increasing number of spectroscopic surveys become available, an automated approach to spectral classification becomes necessary. Due to the significance of the massive stars, it is of great importance to identify the phenomenological parameters of these stars (e.g., the spectral type), which can be used as proxies to their physical parameters (e.g., mass and temperature). Aims. In this work, we aim to use the random forest (RF) algorithm to develop a tool for the automated spectral classification of OB-type stars according to their sub-types. Methods. We used the regular RF algorithm, the probabilistic RF, which is an extension of RF that incorporates uncertainties, and we introduced the KDE – RF method which is a combination of the kernel-density estimation and the RF algorithm. We trained the algorithms on the equivalent width (EW) of characteristic absorption lines measured in high-quality spectra (signal-to-noise (S/N)≳50) from large Galactic (LAMOST, GOSSS) and extragalactic surveys (2dF, VFTS) with available spectral types and luminosity classes. By following an adaptive binning approach, we grouped the labels of these data in 11 spectral classes within the O2-B9 range. We examined which of the characteristic spectral lines (features) are more important for the classification based on a number of feature selection methods, and we searched for the optimal hyperparameters of the classifiers to achieve the best performance. Results. From the feature-screening process, we find that the full set of 17 spectral lines is needed to reach the maximum performance per spectral class. We find that the overall accuracy score is ∼70%, with similar results across all approaches. We apply our model in other observational data sets providing examples of the potential application of our classifier to real science cases. We find that it performs well for both single massive stars and for the companion massive stars in Be X-ray binaries, especially for data of similar quality to the training sample. In addition, we propose a reduced ten-features scheme that can be applied to large data sets with lower S/N ∼ 20 − 50. Conclusions. The similarity in the performances of our models indicates the robustness and the reliability of the RF algorithm when it is used for the spectral classification of early-type stars. The score of ∼70% is high if we consider (a) the complexity of such multiclass classification problems (i.e., 11 classes), (b) the intrinsic scatter of the EW distributions within the examined spectral classes, and (c) the diversity of the training set since we use data obtained from different surveys with different observing strategies. In addition, the approach presented in this work is applicable to products from different surveys in terms of quality (e.g., different resolution) and different formats (e.g., absolute or normalized flux), while our classifier is agnostic to the luminosity class of a star, and, as much as possible, it is metallicity independent.
Read full abstract