# A Cost-Sensitive Diagnosis Method Based on the Operation and Maintenance Data of UAV
## 2 Materials and Methods
### Two-Step Ensemble Method Based on MetaCost Framework
#### 2.3.3 MC-LGB: A Two-Step Ensemble Cost-Sensitive Model  
In order to optimize the total misclassification cost, the original MetaCost framework has the defects of a decline in excessive accuracy and an increased modeling time. Based on the characteristics of the operation and maintenance data of UAVs, we attempted a modification of the original framework by changing the sampling method, improving the performance of the meta-classifier, and adjusting the organization form so as to enhance the overall performance of the diagnosis model and reduce the required computing resources while decreasing the total misdiagnosis cost. Generating subsets for training meta-classifiers through sampling is an important part of constructing diverse meta-classifiers, which is realized by employing the bootstrap resampling in the original MetaCost framework. The sample size of different fault modes varies greatly in the actual UAV flight data, meaning that instances of specific fault modes might not be included in the subsets generated by the bootstrap method, resulting in parts of meta-classifiers lacking the ability to diagnose all existing fault modes. Therefore, stratified bootstrapping was used by us to construct the subsets, to ensure the diversity of the meta-classifiers, and to enhance the stability of the diagnosis model. In order to achieve the expected performance, an important aspect of optimizing the ensemble learning model is improving the capacity of the meta-classifier. According to the characteristics of UAV fault diagnosis, the chosen meta-classifier needs to be lightweight enough to be integrated, while exhibiting a relatively classy diagnosis ability to avoid overfitting. In addition, the independency and diversity of the meta-classifiers are also essential in the MetaCost framework. After constructing varied subsets, different features can also be selected to obtain the diverse meta-classifiers. LightGBM, as an ensemble learning method with a decent classification performance and ultrafast training speed on actual UAV data, perfectly meets the meta-classifier requirements in the MetaCost framework. With the EFB technology, LightGBM can construct multiple decision trees under the same subset, which further enhances the diversity and independency of the meta-classifiers under the premise of stratified sampling beforehand. In addition, employing LightGBM-based models, constructed by boosting, would perhaps increase the sensitivity of the MetaCost model organized by bagging form, for processing large-scale data. In an effort to improve the global diagnostic performance while meeting the cost-sensitive function, selecting LightGBM as the meta-classifier solves the modeling speed issue with MetaCost efficiently, adapting to the limitations in computational resources. In addition, the MetaCost model with LightGBM as a meta-classifier has decent robustness in handling the grievous Gaussian noise interference [36]. Referring to the idea of the D-MetaCost algorithm proposed by [PERSON] [37], a particular proportion of the cost-insensitive meta-classifiers before data relabeling can be integrated with the cost-sensitive meta-classifiers in the end, for offsetting some of the accuracy losses obtained after retraining. After the first ensemble, a proportion of the cost-insensitive meta-classifiers are selected based on the classification accuracy evaluation, to participate in the final ensemble. Thanks to the above improvements, this paper proposes a two-step ensemble cost-sensitive diagnosis model based on the MetaCost framework (MC-LGB), for a UAV fault diagnosis based on operation and maintenance data. The basic workflow of the proposed model is shown in Figure 1. The MC-LGB model is divided into three stages to realize the cost-sensitive classification function: 1 st ensemble stage, intermediate stage, and 2 nd ensemble stage.