  Flares are a well-studied aspect of the Sun's magnetic activity. Detecting
and classifying solar flares can inform the analysis of contamination caused by
stellar flares in exoplanet transmission spectra. In this paper, we present a
standardized procedure to classify solar flares with the aid of supervised
machine learning. Using flare data from the RHESSI mission and solar spectra
from the HARPS-N instrument, we trained several supervised machine learning
models, and found that the best performing algorithm is a C-Support Vector
Machine (SVC) with non-linear kernels, specifically Radial Basis Functions
(RBF). The best-trained model, SVC with RBF kernels, achieves an average
aggregate accuracy score of 0.65, and categorical accuracy scores of over 0.70
for the no-flare and weak-flare classes, respectively. In comparison, a blind
classification algorithm would have an accuracy score of 0.33. Testing showed
that the model is able to detect and classify solar flares in entirely new data
with different characteristics and distributions from those of the training
set. Future efforts could focus on enhancing classification accuracy,
investigating the efficacy of alternative models, particularly deep learning
models, and incorporating more datasets to extend the application of this
framework to stars that host exoplanets.
