{'fraction_non_alphanumeric': 0.035568454088347454, 'fraction_numerical': 0.022103735700064117, 'mean_word_length': 5.081264108352144, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
DKPNet41: Directed knight pattern network-based cough sound classification model for automatic disease diagnosis

Problem Cough-based disease detection is a hot research topic for machine learning, and much research has been published on the automatic detection of Covid-19. However, these studies are useful for the diagnosis of different diseases. Aim In this work, we collected a new and large (n=642 subjects) cough sound dataset comprising four diagnostic categories: ‘Covid-19’, ‘heart failure’, ‘acute asthma’, and ‘healthy’, and used it to train, validate, and test a novel model designed for automatic detection. Method The model consists of four main components: novel feature generation based on a specifically directed knight pattern (DKP), signal decomposition using four pooling methods, feature selection using iterative neighborhood analysis (INCA), and classification using the k-nearest neighbor (kNN) classifier with ten-fold cross-validation. Multilevel multiple pooling decomposition combined with DKP yielded 41 feature vectors (40 extracted plus one original cough sound). From these, the ten best feature vectors were selected. Based on each vector's misclassification rate, redundant feature vectors were eliminated and then merged. The merged vector's most informative features automatically selected using INCA were input to a standard kNN classifier. Results The model, called DKPNet41, attained a high accuracy of 99.39% for cough sound-based multiclass classification of the four categories. Conclusions The results obtained in the study showed that the DKPNet41 model automatically and efficiently classifies cough sounds for disease diagnosis.


Introduction
The Covid-19 pandemic has affected people's lives worldwide. Despite the availability of vaccination, many countries still experience a resurgence in Covid-19 infection rates, especially with variant viral strains [1,2]. While the definitive diagnosis of Covid-19 infection requires confirmatory viral assays, upstream clinical triage can identify patients at risk, so that isolation can be used to avert further spread. As respiratory symptoms and signs in Covid-19 may resemble that of other conditions such as heart failure, methods that can discern the Covid-19 presentation from other ailments would be clinically useful. Artificial intelligence methods have found burgeoning applications in medicine [3], especially for the computer-aided diagnosis of diverse diseases [4][5][6]. Unsurprisingly, research interest in unmanned or automatic computer-aided diagnosis of Covid-19 has grown apace in the last year. Biomedical signal readouts of X-ray computed tomography and cough sound types can be fed into various machine learning or deep learning models to automatically detect Covid-19 [7]. Once validated, intelligent medical assistant systems can be prioritized for deployment in medical centers and hospitals to facilitate disease screening [8].
In this work, we focused on disease detection using cough sound signals, which are widely available and inexpensive to acquire. We collected a large dataset of cough sounds from healthy subjects as well as patients with Covid-19 infection, heart failure, and acute asthma. Acute asthma is a common disease that may present with altered cough sounds from vocal cord dysfunction [9]. Left heart failure may cause fluid to accumulate in the lungs, leading to respiratory symptoms. Nocturnal cough is a clinical sign of heart failure [10].
Artificial intelligence-based disorder detection/diagnosis has become a very popular area of research, with increasing numbers of articles on automatic disease diagnosis being published [11,12]. Unsupervised deep learning models are often used to train, validate, and test biomedical data. Their high levels of attained classification accuracy render them suitable for many biomedical applications [13,14]. However, automated disease diagnostic systems incorporating machine learning based on handcrafted features can also be effective [15][16][17]. While deep networks can achieve high accuracy with large data sets [18], handcrafted models exact lower computational costs [16]. As such, either method can be deployed in intelligent medical systems to optimize accuracy or computational efficiency [19][20][21].
Various automated computer-aided diagnostic methods for the detection of asthma, Covid-19, and heart failure have been published using diverse medical imaging and biomedical signals as input [22,23]. Using the RapidMiner application [24], Yunus et al. [25] designed a heart failure classification system based on 11 data attributes (age, sex, smoking, anemia, platelets, diabetes, ejection fraction, high blood pressure, serum sodium, serum creatine, time). They tested the model on 299 samples from the UCI machine learning repository [26] and achieved classification accuracy rates of 86.95% and 94.31% with the k-nearest neighbor (kNN) and random forest implementations, respectively. Al-khassaweneh and Abdelrahman [27] used a method based on the Wigner distribution and wavelet transform to diagnose asthma, and attained a 100% accuracy rate, albeit with small study subject numbers (12 asthmatics and 12 healthy subjects). From cough sounds acquired with a system comprising a thermos camera, airflow sensor, and microphone and then uploaded to the Internet, Belkacem et al. [28] were able to diagnose Covid-19 remotely via a mobile connection. The technique incorporated a computationally demanding model based on convolution, recurrent neural networks, and mel-frequency cepstral coefficients. Brown et al. [29] reported a precision rate and area under the curve of 80% and 82%, respectively, using a support vector machine classifier. Islam et al. [30] studied an artificial neural network model for asthma diagnosis based on multichannel analyses of lung sounds collected from 30 asthmatics and 30 healthy subjects. Among the four channels analyzed, Channel 2 yielded the highest accuracy of 82.3% with an artificial neural network classifier, while the accuracy rates for Channels 1, 3, and 4 were less salutary (66.70%, 70.0%, and 63.3%, respectively, with support vector machine classifiers). With a larger dataset comprising 728 asthmatics and 522 healthy medical personnel, Badnjević et al. [31] reported a high accuracy rate of 98.85% for the detection of asthmatic and healthy subjects using a model that was also based on an artificial neural network. In the study, the training was implemented as 80% and the validation was set at 20%. Hassan et al. [32] applied a model based on a recurrent neural network and long short-term memory to analyze breath, cough, and voice signals from 20 Covid-19 and 60 healthy subjects. Implementing a 70:30 split ratio, they attained a high accuracy rate of 97% for Covid-19 detection using cough sounds.
Studies in the literature generally focus on diagnosing a single disease [25]. Therefore, no automatic machine learning approach can diagnose more than one disease [31]. A major research gap in the literature is that cough-based disease diagnosis models demonstrate a low level of accuracy [29,30]. The few studies reaching high accuracy values use small-sized datasets [27]. Another research gap in the literature is that the proposed methods have a high computational complexity [28,32]. To fill these gaps, a new and unique dataset with a higher subject count was collected in this study. The collected dataset includes four diagnostic types. These types are: 'Covid-19', 'heart failure', 'acute asthma', and 'healthy' categories. The categories can be detected based on cough sounds. In addition, a new paradigm with low computational complexity is proposed. In this context, we developed a machine learning model based on a specifically directed graph called the directed knight pattern (DKP) that outputs 41 feature vectors (DKPNet41) for downstream feature vector and feature selection as well as classification. A machine learning method should not only generate features but must also be able to select the salient feature vectors and features. We employed a histogram-based function using DKP as the main feature generator, in which two kernels and chess moves were used to generate 1,536 features per run. As the pattern itself cannot discern high-level features, an appropriate pooling method for decomposition is needed for multilevel feature generation. However, pooling methods are not satisfactory for routing according to the capsule network [33] as only peak values are routed with maximum pooling. To ameliorate, we deployed four pooling methods: average, minimum, maximum, and conditional pooling, to generate forty sub-bands. Together with the original cough sound signal, 41 feature vectors were obtained from which the DKPNet41 selected the ten best feature vectors to create the final vector of length 1536 × 10 = 15360. We next used the iterative neighborhood component (INCA) feature selector [34] to sieve out the most informative 726 features from the extracted 15,360 features in the final vector, which were then input to the kNN classifier [35].
This new model was devised with high accuracy and low computational complexity in mind. The model was trained and validated on a new large multiclass cough sound dataset that was prospectively acquired. The research gaps evident in the literature, such as a small number of subjects, low accuracy, high computational complexity, and lack of satisfactory diagnosis when there are multiple disease categories, were rectified with this study. In this context, the main contributions of this research are: -Artificial intelligence-enabled cough sound classification an urgently needed area of research. The new multiclass cough sound dataset was prospectively acquired and made publicly accessible with hyperlink http://web.firat.edu.tr/turkertuncer/acute_asthma_cough. rar. -A novel DKP-based model was presented that combined chess moves and two binary feature extraction kernels to generate features. -The handcrafted DKPNet41 is a computationally lightweight cognitive learning model comprising multiple pooling decomposition, multilevel feature extraction, iterative feature selector, and classification steps. Multilevel multiple pooling decomposition combined with directed knight pattern yielded 41 feature vectors (40 extracted plus one original cough sound). From these, the best ten feature vectors were selected. Based on each vector's misclassification rate, redundant feature vectors were eliminated, and then merged. The merged vector's most informative features automatically selected using INCA were input to a standard kNN classifier.

Dataset
From December 2020 to April 2021, 842 subjects who were diagnosed with Covid-19, heart failure, or acute asthma, or who were assessed as healthy (see Table 1), were recruited from the pulmonology and cardiology clinics of Firat University Hospital, Elazıg, Turkey. Smartphone microphones were used to collect cough sounds, which were saved in ogg, mpeg, mp4, or m4a formats at sampling rates of 44.1 or 48 kHz, depending on the type of mobile phone. We recorded 120, 2, 1, and 719 participants' cough sounds in ogg, mp4, mpeg, and m4a format, respectively, to show the robust classification ability of the proposed model. Furthermore, we have not used any preprocessing algorithm, only cough sounds have been segmented. In addition, few speech signals were deleted manually. These cough sounds were collected from definitively diagnosed patients. For diagnosis, doctors checked PCR test results of the Covid19 patients, and thereafter we collected cough sounds from these patients. Each cough sound signal was subdivided into smaller segments (the length of each segment is one second) for a total of 2944 samples and 842 subjects used in the analysis (see Figure 1 for examples). The collected dataset is publicly accessible and downloadable at the hyperlink http://web.firat.edu.tr/turkertuncer /acute_asthma_cough.rar.
To denote the distinctive of these cough sounds per the classes, we extracted spectrogram images of cough sound samples, and the obtained images are shown in Figure 1.
As can be seen from spectrogram images (see Figure 1), these cough has variable attributes and Figure 1 clearly demonstrated seperable attributes of the collected cough sounds per the category.

Method
Feature engineering using unsupervised deep learning is computationally demanding. In this study, we designed a novel computationally lightweight machine learning model that employed a specific DKP-based pattern -where the direction of each edge defined the generated bits-as the primary local feature generation function to develop handcrafted binary features from two directed kernels, i.e., signum and ternary. The DKP is a local textural feature generator that generates 1,536 features per run, but it cannot perform high-level feature extraction, for which a decomposer is generally utilized. Although pooling decomposers have been employed to create layers with deep learning models such as convolutional neural networks [36] and multi-layer perceptron mixers [37], pooling decomposers are not necessarily the optimal routers for handcraft modeling. Instead, we deployed four pooling methods in a ten-level architecture to generate 4 × 10 sub-bands. Together with the original cough sound signal, 41 feature vectors were obtained per cough sound signal segment. From these 41 feature vectors, the best ten feature vectors were selected based on the individual vectors' accuracy rates to eliminate redundancy. Then and then merged to form a final vector of size 10 × 1,536 = 15,360. From the merged vector, INCA automatically selected the most informative 726 features, which were then input to a standard kNN classifier (see Figure 2). The detailed steps of the DKPNet41 model are explained in the following sections. As given in Figure 2, the model acquires cough sound as input. In the study, segmented cough sounds are used. The developed model produces features from the main cough and decomposition sounds. In this phase, DKP is employed as a unique feature extraction approach. In the decomposition process, sub-bands are obtained using the average pooling method, and features are produced from each sub-band using the DKP method. The decomposition process is repeated ten times. Each iteration produces four feature vectors via the pooling process. In the next phase, the model selects and combines the best feature vectors (projection from 41 feature vectors to 10 feature vectors). Finally, the most significant features are selected from the feature vector, and these features are classified as categories 'acute asthma', 'Covid-19', 'heart failure', and 'healthy'. The details of the proposed method are given in the subsections.

Feature extraction
Step 0: Read cough sound.
Step 1: Create sub-bands using average, maximum, minimum, and conditional pooling functions. These functions use two-sized nonoverlapping windows to decompose cough sounds.
In algorithm 1, the maximum, minimum and average pooling methods were used with maximum, minimum, and average statistical moments, respectively. Conditional pooling used the three statistical moments according to the condition defined in Equation 1. . 2. Schematic of the directed knight pattern-based model.
Next, DKP is deployed for local feature extraction using the 40 subbands generated in Algorithm 1, plus the original cough sound.
Step 2: Extract 1,536 features from each sub-band and cough sound using DKP.
where f t is the t th generated feature vector; and DKP(.), the proposed DKP feature generator function. The latter is explained in detail below.
Step 2.1: Deploy overlapping window division. Here, the onedimensional signal input is divided into nine overlapping blocks.
where b and x are nine-sized overlapping blocks and a one-dimensional signal, respectively.
Step 2.2: Generate a 3 × 3 sized matrix by deploying vector-to-matrix transformation.
In Equation 5, m defines a 3 × 3 sized matrix, which is used to apply the DKP.
In Figure 3, the DKP consists of two directed graph patterns denoted as black and red arrows, with edges (enumerated) that can be used to generate the binary features. The black arrows trace the starting and destination points of sequential knight moves on a 3 × 3 matrix computerized "chessboard", while the red arrows point to the destination points after each corresponding knight move, with reference to the center of the "chessboard". Directed upper and lower ternary functions and directed signum functions are employed to generate bits. Using the directions in the analytical plane (see Figure 3), bits are calculated as follows.
Step 2.4. Generate bits using both DKP patterns and directed kernels.

Algorithm 1
Pseudocode for sub-band creation using multilevel multiple pooling.  Fig. 3. Graphical depiction of directed chess moves (knight patterns) and directions used to generate bits.
and ⎡ where bf z l l th bit of z th bit group using z th directed kernel (∂ z ). Here, Equation 6 and Equation 7 define feature bit generation using the first and second graphs depicted using black and red arrows, respectively, in Figure 3. In both graph patterns, six-bit groups, each with a length of eight, are generated. Here, the main feature generators are directed kernels defined in equations (8) to (11).
Step 2.5: Calculate map signals by deploying binary-to-decimal conversion.
From Equation 12, the DKP generates six maps (mp) signals for feature extraction.
Step 2.6: Extract histograms of the generated six map signals.
In Equation 13, the initial histogram values are assigned null values. Equation (14) defines the histogram extraction mathematically.
Here, mf represents the merged features.
Step 3: Calculate the accuracy rates of each of the extracted 41 feature vectors in Step 2, and deploy the kNN classifier with five-fold cross-validation (see Figure 4).
Step 4: Select top feature vectors based on individually calculated accuracy rates in Step 3. The proposed DKPNet41 is a parametric method. This work selects the top ten feature vectors to obtain optimum performance.
Step 5: Concatenate the top ten feature vectors to obtain the final feature vector (X) of length 15,360.

Feature selection using INCA
Step 6: Select top informative features by deploying INCA [34]. INCA is an iterative and improved version of neighborhood components analysis. The latter is a weight-based selector without the ability to automatically select the most suitable number of features, unlike INCA, which is a parametric selector. These parameters are the misclassification rate generator, the initial value of iteration, and the end value of iteration. The parameters used in this work are listed in Table 2.
By using these parameters, the INCA selector evaluates 1000 − 40 + 1 = 961 feature vectors to select the most appropriate features, i.e., 726 features from the 15,360 features in the final merged vector from Step 5.

Classification
Step 7: Classify the chosen 726 features by deploying standard kNN (parameters are defined similar to Table 2) with ten-fold crossvalidation.

Performance analysis
To evaluate the performance of the DKPNet41 model, we evaluated standard performance evaluation metrics based on the mathematical formulae given below.
where tp denotes true positives; tn, true negatives; fp, false positives; fn, false negatives; Acc, accuracy; Pre, precision; Rec, recall; and F1, F1score (harmonic average of precision and recall). Individual performance metrics for all and individual diagnostic categories, respectively, were calculated and then listed in Table 3. As provided in Table 3, the developed model reached an average accuracy of 99.39% with the ten-fold-cross-validation strategy. In addition, the model achieved a 100% classification success for acute asthma, healthy, and heart failure categories. The confusion matrix of these results is shown in Figure 5.
In summary, the DKPNet41 model attained excellent overall multiclass classification accuracy, unweighted average recall, and an F1-score of 99.39%, 99.51%, and 99.45%, respectively, with ten-fold cross-validation. Moreover, fold-wise accuracies were calculated, and the foldwise results were consistently excellent (see Figure 6). Fold-wise results were calculated to demonstrate the consistency of the proposed method. As can be seen from Figure 6, the proposed method indicates a very high classification success for all folds.
As an alternative to cross-validation, we performed hold-out validation at a range of split ratios: 90:10, 80:20, 70:30, 60:40, and 50:50. Similar high accuracy rates, unweighted average recall, and F1scores at varying split ratios (Table 4) were obtained, which confirmed the robustness of the DKPNet14 model. The results given in Table 4 show that the proposed method outperforms the hold-out validation strategy. In addition, the high success rate applies to all split ratios. The results are given in Figure 6, and Table 4 thus show the superiority of the proposed method. Finally, we performed a complexity to assess the model's time burden using big O notation (Table 5). This analysis is provided in Table 5.
The most complex step of the DKPNet41 model is feature selection with INCA, which possesses a relatively low computational complexity. However, when the total complexity is examined, it is apparent that the proposed method has low computational complexity. Furthermore, the obtained accuracy values (fold-wise and split ratio(s) results) and computational complexity demonstrate that the proposed method is of practical use.

Discussion
We have developed a novel computationally efficient handcrafted DKPNet41 model for the automated diagnosis of cough sounds and confirmed its accurate performance by training and validating the model on a new large multiclass cough sound dataset that was prospectively acquired from healthy subjects and patients with Covid-19, heart failure and acute asthma. As far as we know, the method proposed in this study is the first of its kind and produces results that can be used in the preliminary diagnosis of more than one disease. The proposed method can automatically classify cough sounds collected through a simple microphone with a high accuracy rate. In addition, this method has low   Table 3 Calculated overall and individual performance metrics of the DKPNet41 model using ten-fold cross-validation. computational complexity. For performance, multilevel pooling-based decompositions and DPK feature generation function were applied to cough sounds to generate 40 sub-bands with 1,536 features each. Fortyone feature vectors (40 sub-bands plus original cough sound) were obtained. The model automatically selected the top ten feature vectors with the highest accuracy rates (i.e., least miscalculation) using kNN with 5-fold cross-validation (Figure 7), which were then merged to form a final feature vector of size 15,360. INCA was deployed to select from the final merged feature vector the most informative 726 features, which were then fed into the final kNN classifier. kNN was deployed at three steps in the DKPNet41 model: selection of ten feature vectors selection, selection of the most informative features from the merged final feature vector using INCA, and final classification. Regarding the latter, we tested and compared the results of various classifiers on our model.   Figure 8 shows the calculated accuracy rates after testing. The classifier with the best results was Fine kNN (13 th classifier), which attained a 98.23% accuracy using default settings.
To refine the Fine kNN, Bayesian optimization [38] was implemented with 30 iterations to tune its parameters. At initialization, k was set equal to 1; the distance metric was Manhattan, and the voting value was null. By doing so, the accuracy rate climbed from 98.23% to 98.51%.
The top ten feature vectors were concatenated to improve accuracy, and INCA was applied to the merged feature vector. INCA evaluated 961 feature vectors. The misclassification rates of these feature vectors (see Figure 9) was lowest at a feature vector length of 726, and the classification accuracy peaked at 99.39% at this reduced feature vector length.
The 726 features were selected from the ten best feature vectors. The top ten feature vectors are: 1 st (raw signal), 3 rd , 7 th , 6 th , 9 th , 4 th , 8 th , 13 th , 12 th , and 5 th feature vectors, and these feature vectors contain 1536 features. Moreover, the classification rates of these features range from 97.89% to 98.51%. The selected number of the features per used feature vector is depicted in Figure 10.
As can be seen from Figure 10, we incorporated the chosen ten feature vectors to create a final feature vector.
The performance of the DKPNet41 model compares favorably with other state-of-the-art cough sound classification methods, attaining superior accuracy rates for multiclass classification. Our study results as compared with other results in the literature, are summarized in Table 6.
To date, there is no automated cough sound classification study in the literature in which 'acute asthma', 'Covid-19', 'heart failure' and 'healthy' classes are used together. Therefore, we present a novel automated cough sound classification model using a four-class system. Many studies use Covid-19 versus Control classes or Asthma versus healthy classes in the literature. These works solve a binary classification problem by analyzing a cough sound dataset from a two-class perspective. Others, such as Pal and Sankarasubbu [7] used a dataset with four classes ( Table 6). The classes are 'Covid-19', 'bronchitis', 'healthy' and 'asthma'. They used a deep neural network to classify the sounds. Pal and Sankarasubbu's [7] method attained a 90.80% accuracy rate for  Table 5 Complexity analysis of the DKPNet41 model.
Step  [43]. 'Asthma', 'chronic obstructive pulmonary disease' and 'healthy' classes were categorized in this study. Knocikova et al. [43] achieved a 90% classification accuracy in the study. In this context, the highlights of our DKPNet41 model are listed  below.
The benefits of this are: -Cough sounds can be easily collected at a low cost using a simple smartphone microphone. We prospectively collected and made available a large multiclass cough sound dataset that can be downloaded as well by other investigators for new model development. -It can be noted from Table 6 that this is the first paper to classify normal, asthma, Covid-19, and heart failure using cough sounds (4class system). -DKPNet41 achieved the highest classification performance using six different validation techniques. Hence, the proposed DKPNet41 model is robust and accurate. -We studied cough sounds from patients with Covid-19, heart failure, and acute asthma patients. The latter is a common disorder that may not manifest abnormality on lung imaging, which precludes the automated diagnosis of asthma using an image-based classification model. -The DKPNet41 model uses a novel graph pattern to extract handcrafted local features and is then able to cognitively select the best feature vectors and features automatically. -The model possesses an excellent multiclass classification accuracy of 99.39% for cough sound-based diagnosis. -The model is computationally lightweight with low complexity and time burden (Table 5).
The Limitations of this method are as follows: -A larger dataset can be collected from more patients to test the DKPNet41 model. -More disorders can be detected using cough sounds.

Conclusions
We have developed a novel handcrafted DKPNet41 learning model and trained and validated it on a new cough sound dataset. The model extracted features using a new local feature generator based on DKP, combined with two directed kernels to generate comprehensive features. Forty sub-bands were generated using four pooling decomposers. Together with the original cough sound signal, 41 feature vectors underwent further automatic feature vector and feature selections. From accuracy measures employed to analyze the 41 feature vectors, the top ten feature vectors were selected, and then the most informative features from these ten feature vectors were chosen using the INCA selector. INCA selected 726 features per run fed to a standard kNN classifier. The model attained a 99.39% accuracy with ten-fold cross-validation. Holdout validation analyses at 90:10, 80:20, 70:30, 60:40 and 50:50 split ratios demonstrated consistently high corresponding accuracy rates of 100%, 99.83%, 98.53%, 98.05% and 97.08%, respectively, which support the robustness of the model. The limitation of this work is that we have used a relatively small dataset to develop our proposed DKPNet41 system. In the future, we will validate our automated system with larger cough datasets.
New intelligent chip diagnostic models and applications can be developed for artificial intelligence-enabled cough sound diagnosis. Our work demonstrates that cough sound-based intelligent disease diagnostics is feasible and can be implemented in pulmonology and cardiology clinics. Newer handcrafted learning models/networks similar to DKPNet41 can be developed that will be more computationally efficient than the available deep networks. In the near future, a new generation handcrafted feature-based deep networks/models can be devised. It is among our future plans to test and revise the developed model using more data and disease types. In addition, it is aimed to ensure its practical usability by integrating it into an embedded card.