## 4 Simulation and Dataset Generation
### Dataset Generation  
Datasets of a few hundred entries are created via the simulation presented in Section 4. Specifically, the whole testing campaign presented in Section 5 makes use of a main archive of 12 large datasets, each one containing 840 (or 672 if reduced) nominal simulations: there are 12 because they concern the four monitored elements (three sensors and one actuator), for each of the three attitude modes (control-free, Earth-pointing, and slew maneuver). Fault injection, since the starting datasets are nominal, is performed offline, on MATLAB, with the type of faults and classes decided a priori. Identical fault injection algorithms are placed in the functional simulator directly after sensors and actuators: these online fully integrated versions are useful for single runs or specially constructed case studies, where diagnosis operations are executed live, during the run of a single simulation, such as testing cases explored in Section 5.4. Any class imbalance issue is avoided by directly generating the required precise number of dataset entries: this means that the actual number of elements in the dataset is also important, since it must be divisible exactly, successive times,  
Figure 7: Functional model of a generic sensor.  
by the number of classes and subclasses chosen. The numbers 840 or 672 as total entries (which will appear again in Section 5) are optimally large and are a heritage of preliminary testing experiments, where grouping and sub-grouping into three or seven classes was necessary. Signals can also go through the fault injection process a second time if multiple faults are needed. The algorithm also applies labels to each signal to specify their individual behavior: these labels are essential for Machine Learning classifiers to learn, and therefore must be kept track of, even during shuffling of the signal dataset. Finally, the actual feature extraction process can start: the 26 time and frequency features, selected and explored in Section 3, are calculated from each signal, and a brand new dataset composed only of these discrete inputs is created. Before starting each training, the dataset is split into two: 90% of the elements are actually used for training and validation purposes, while the remaining 10% are stored and used only at the end of the training.  
All accuracies reported throughout the tables in Section 5 refer to the precision reached while evaluating this final 10% testing share of the dataset: validation accuracies are partial results, and therefore, are not reported. The full initial dataset size for each testing case is reported in the description of each training scenario. Training, in all cases, is performed with five-fold cross-validation, which helps not to run into overfitting issues. Cross-validation works by partitioning the shuffled dataset into a training set and a validation set: the training set is directly used to tune the algorithm and supervise the learning, while the validation set evaluates its performance. By repeating this validation process multiple times (five in this case) and by progressively using each slot of the dataset as a validation set, chances of asymmetric sampling are minimized and the net is rigorously trained on all portions of the given dataset in equal shares. Figure 8 presents this whole process in a more graphic way.