Classifying by Bayesian Method and Some Applications

This chapter sums up and proposes some results related to classification problem by Bayesian method. We present the classification principle, Bayes error, and establish its relationship with other measures. The determination for Bayes error in reality for one and multi-dimensions is also considered. Based on training set and the object that we need to classify, an algorithm to determine the prior probability that can make to reduce Bayes error is proposed. This algorithm has been performed by the MATLAB procedure that can be applied well with real data. The proposed algorithm is applied in three domains: biology, medicine, and economics through specific problems. With different characteristics of applied data sets, the proposed algorithm always gives the best results in comparison to the existing ones. Furthermore, the examples show the feasibility and potential application in reality of the researched problem


Introduction
Classification problem is one of the main subdomains of discriminant analysis and closely related to many fields in statistics. Classification is to assign an element to the appropriate population in a set of known populations based on certain observed variables. It is an important development direction of multivariate statistics and has applications in many different fields [25,27]. Recently, this problem is interested by many statisticians in both theories and applied areas [14][15][16][17][18][22][23][24][25]. According to Tai [22], we have four main methods to solve the classification problem: Fisher method [6,12], logistic regression method [8], support vector machine (SVM) method [3], and Bayesian method [17]. Because Bayesian method does not require normal condition for data and can classify for two and more populations it has many advantages [22][23][24][25]. Therefore, it has been used by many scientists in their researches.
Given k populations {w i }, with probability density functions (pdfs) and the prior probabilities respectively {f i } and {q i }, i = 1, 2,…, k, where q i ∈ ð0; 1Þ, X k i¼1 q i ¼ 1: Pham-Gia et al. [17] used the maximum function of pdfs as a tool to study about Bayesian method and obtained important results. The classification principle and Bayes error were established based on the g max (x) = max{q 1 f 1 (x), q 2 f 2 (x), …, q k f k (x)}. The relationship between the upper and lower bounds of the Bayes error and the L 1 -distance of the pdfs and the overlap coefficient of the pdfs-were established. The function g max (x) played a very important role in the classification problem by Bayesian method and Pham-Gia et al. [17] continued to do research on it. Using the MATLAB software, Pham-Gia et al. [18] succeeded in identifying g max (x) for some cases of the bivariate normal distribution. With similar development, Tai [22] has proposed the L 1 -distance of the {q i f i (x)}-and established its relationship with Bayes error. This distance is also used to calculate Bayes error as well as to classify new element. This research has been applied in classifying ability to repay debt of bank customers. However, we think that the survey of two Bayesian approach relevant research was not yet completed. There are some relations between Bayes error and other statistical measures.
Bayesian method has many advantages. However, to our knowledge, the field of applications of this method in practice is narrower than other methods. We can find many applications in banking and medicine using Fisher method, SVM method, logistic method [1,3,8,12]. Recently, all statistics software can effectively and quickly process the classification of large data sets and multivariate statistics using either three of the methods mentioned above, whereas the Bayesian method does not have this advantage. The cause of this problem is the ambiguity in determining prior probability, in estimating pdfs, and the complexity in calculating Bayes error. Although all these issues have been discussed by many authors, the optimal methods have yet to be found [22,25]. In this chapter, we consider to estimate the pdf and to calculate Bayes error to apply in reality. We will present the problem on how to determine the prior probability in this chapter. In case of noninformation, we normally choose prior probabilities by uniform distribution. If we have some types of past data or training set, the prior probabilities are estimated either by Laplace method: q i = (n i + n/k)/(N + n) or by the frequencies of the sample: q i = n i /N, where n i and N are the number of elements in the ith population and training set, respectively, n is the number of dimensions, and k is the number of groups. The above-mentioned approaches have been studied and applied by many authors [14,15,22,25]. We will also propose an algorithm to determine prior probability based on the training set, classified objective, and fuzzy cluster analysis. The proposed algorithm is applied in some specific problems of biology, medicine, and economics and has advantages over existing approaches. All calculations are performed by MATLAB procedures.
The next section of this chapter is structured as follows. Section 2 presents the classification principle and Bayes error. Some results of the Bayes error are also established in this section. Section 3 resolves the related problems in real application of the Bayes method. There are estimation of pdfs and determination of Bayes error in case of one dimension and multidimension. This section also proposes an algorithm to determine prior probability. Section 4 applies the proposed algorithm in real problems and compares outcome results to those obtained using existing approaches. Section 5 concludes this chapter.

Classifying by Bayesian method
The classification problem by Bayesian method has been presented in many documents [15,16,27], where the classification principle and the Bayes error are established based on Bayes theorem. In this section, we present them via the maximum function of q i f i (x), i = 1, 2, …, k that they have advantages over existing approaches in real application [17,18,[21][22][23][24][25]. This section also establishes the upper and lower bounds of the Bayes error and the relationships of Bayes error with other measures in statistical pattern recognition.

Classification principle and Bayes error
Given k populations w 1 , w 2 , …, w k with q i ∈ (0;1) and f i (x) are the prior probability and pdf of ith population, respectively, i = 1, 2, …, k. According to Pham-Gia et al. [17], element x 0 will be assigned to w i if where Bayes error is given by the formula: From Eq. (2), we can prove the following result: The correct probability is determined by Ce  i. Pe ii. Pe iii. ðk À 1Þ À X i X j kg i , g j k 1 iv. 0 ≤ Pe where and dx is affinity of Toussaint [26].
ii. From Eq. (2), we have Since min q i f i ðxÞ, q j f j ðxÞ then min q i f i ðxÞ, q j f j ðxÞ n o ≤ q i f i À Á β q j f j 1Àβ : Integrating the above inequality, we obtain: On the other hand, We also have Replacing ð R n g max ðxÞ ¼ 1 À Pe ðqÞ 1, 2, …, k to Eqs. (12) and (14), we have Eq. (7).
iv. We have Integrating the above relation, we obtain: Above inequality is true for all i = 1,…,k, so 1, 2, …, k in above relation, we have Eq. (8).

Related problems in applying of Bayesian method
To apply Bayesian method in reality, we have to resolve three main problems: (i) Determine prior probability, (ii) compute Bayes error, and (iii) estimate pdfs. In this section, we propose an algorithm to solve for (i) based on fuzzy cluster analysis and classified objective that can reduces Bayes error in comparing with traditional approaches. For (ii), Bayes error is established by closed expression for general case and determine it by an algorithm to find maximum function of g i (x), i = 1, 2, …, k for one dimension case. The quasi-Monte Carlo method is proposed to compute Bayes error in this section. For (iii), we review the problem to estimate pdfs by kernel function method where the bandwidth parameter and kernel function are specified.

Prior probability
In the n-dimensions space, given N populations N ð0Þ ¼ W where μ ik is probability of the kth element belonging to w i . We have μ ik ∈ ½0, 1 and satisfies the following conditions: We call be fuzzy partitioning space of k populations, ik is the square of distance from the object z k to the ith representative population. This representative is computed by the following formula: where m ∈ [1,∞) is the fuzziness parameter.
Given the data set Z including c known populations w 1, w 2 , …, w c . Assume x 0 is an object that we need to classify. To identify the prior probabilities when classifying x 0 , we propose the following prior probability by fuzzy clustering (PPC) algorithm: In the above algorithm, we have: i. ε is a really small number and is chosen arbitrarily. The smaller ε is, the more iterations time is taken.
In the examples of this chapter, we choose ε = 0.001. ii.
The distance matrix D ik depends on the norm-inducing matrix A. When A = I, D ik is the matrix of Euclidean distances. Besides, there are several choices of A, such as diagonal matrix or the inverse of the covariance matrix. In this chapter, we chose the Euclidean distances in the numerical examples and applications.
iii. m is the fuzziness parameter, when m = 1, the fuzzy clustering becomes the nonfuzzy clustering. When m ! ∞, the partition becomes completely fuzzy μ ik = 1/c. The determining of this parameter, which affects the analysis result, is difficult. Even though Yu et al. [28] proposed two rules to determine the supermom of m for clustering problems, the searching of the specific m was done by meshing method (see [2,4,5,9] for more details). By this process, the best m among several of given values will be chosen. In this chapter, m is also identified by meshing method for the classification problem. The best integer m between 2 and 10 will be used.
where μ ij = 1 if the jth object belongs to the w i and μ ij = 0 for the opposite, Output: The prior probability μ iðNþ1Þ , i ¼ 1, 2, …c: Repeat: Find the representative object of Compute the matrix ½D ik cÂNþ1 (the pairwise distance between objects and representative objects). Update the new partition matrix U (new) by the following principle: The prior probability μ iðNþ1Þ , i ¼ 1, 2, …c (the final column of the matrix U); At the end of the PPC algorithm, we obtain the prior probabilities of x 0 based on the last column of the partition matrix U ðμ iðNþ1Þ , i ¼ 1, 2, …cÞ. The PPC algorithm helps us determine the prior probabilities via the closeness degree between the classified object and the populations. Each object will receive its suitable prior probabilities.
In this chapter, Bayesian method with prior probabilities calculated by the uniform distribution approach, the ratio of samples approach, the Laplace approach, and the proposed PPC algorithm approach are respectively called BayesU, BayesR, BayesL, and BayesC. Example 1. Given the studied marks (scale 10 grading system) of 20 students. Among them, nine students have marks that are lower than 5 (w 1 : fail the exam) and 11 students have marks that are higher than 5 (w 2 : pass the exam). The data are given in Table 1.
Assume that we need to classify the ninth object, x 0 = 4.3, to one in two populations. Using the PPC algorithm, we have the following final partition matrix: From the data in Table 1, we might estimate the pdfs f 1 (x) and f 2 (x) and compute the values q 1 f 1 (x) and q 2 f 2 (x), where q 1 and q 2 are the calculated prior probabilities. The results of classifying x 0 by four approaches: BayesU, BayesR, BayesL, and BayesC are given in Table 2.
Because the actual population of x 0 is w 1 , only BayesC gives the true result. The Bayes error of BayesC is also the smallest. Thus, in this example, the proposed method improves the drawback of the traditional method in determining the prior probabilities.

Determining Bayes error
Theorem 2. Let f i (x), i =1, 2, …, k, k ≥ 3 be k pdfs defined on R n , n ≥ 1 and let q i ∈ (0;1), The Bayes error is determined by Proof: To obtain Eq. (18), we need to prove two following results: From Eq. (17), we obtain Therefore, On the other hand, from antithesis style of D'Morgan, we have Similarly, In addition, from Eq. (17), we can directly find out g max ðxÞ ¼ g i ðxÞ, ∀x ∈ R n i , ð1 ≤ i ≤ kÞ: For k = 2, q 1 = q 2 = 1/2, we consider the two following special cases: i.

Maximum function in the classification problem
To classify a new element by the principle (1) and to determine Bayes error by the formula (3), we must find g max (x). Some authors, such as Pham-Gia et al. [15,17] and Tai [21,22], have surveyed relationships between g max (x) with some related quantities of classification problem. The specific expression for g max (x) in some special case has been found [18]. However, the general expression for all of cases is a complex problem that has not been still found yet.
Given k pdfs f i (x) and q i , i = 1, 2, …, k with q 1 + q 2 + …+ q k = 1 and let g i (x) = q i f i (x), g max (x) = max {g i (x)}. Now, we take interest in determining g max (x).

(a) For one dimension
In this case, we can find g max (x) by the following algorithm: and q i are the probability density function and the prior probability of w i, i = 1, 2, …, k, respectively. Output: The g max (x) function.
Find all roots of the equations g i ðxÞ À g j ðxÞ ¼ 0 Let B be the set of all roots. For x lm ∈ B (the roof of equation g l ðxÞ À g m ðxÞ ¼ 0) do For p ∈{1,2,…,k}\{l,m} do If g l ðx lm Þ < g p ðx lm Þ then B ¼ B\fx lm g

End End End
Arrange the elements of B in order from smallest to largest: In the above algorithm, ε 1 , ε 2 , ε 3 are the positive constants such that: From this algorithm, we have written a MATLAB code to find the g max (x). When g max (x) is determined, we will easily calculate Bayes error by using formula (3), as well as classify a new element by principle (1).
Example 3. Given the four bivariate normal pdfs N(μ i , Σ i ) with the following specific parameters [16]: With q 1 = 0.25, q 2 = 0.2, q 3 = 0.4, and q 4 = 0.15, we have the graphs of g i (x) = q i f i (x) and their intersection curves as shown in Figure 2.
Here, we do not find the expression of g max (x). We compute Bayes error instead by taking integration of g max (x) by quasi-Monte Carlo method [17]. An algorithm for doing calculations has been constructed, and a corresponding MATLAB procedure is used in Section 4.

Estimate the probability density function
There are many parameter and nonparameter methods to estimate pdfs.
In the examples and applications of Section 4, we use the kernel function method, the popular one in practice nowadays. It has the following formula: where x j , j = 1,2,…,n are variables, x j , i = 1,2,…,N are the ith data of the jth variable, h j is the bandwidth parameter for the jth variable, f j (.) is the kernel function of the jth variable which is usually normal, Epanechnikov, biweight, and triweight. According to this method, the choice Classifying by Bayesian Method and Some Applications http://dx.doi.org/10.5772/intechopen.70052 of smoothing parameter and the type of kernel function play an important role and affect the result. Although Silverman [20], Martinez and Martinez [10], and some other authors [7,13,27] had discussions about this problem, the optimal choice still has not been found yet. In this chapter, the smoothing parameter is from the idea of Scott [19] and the kernel function is the Gaussian one. We have also written the code by MATLAB software to estimate the pdfs in ndimensions space using this method.
We have written the complete code for the proposed algorithm by MATLAB software. It is applied effectively for the examples of Section 4.

Some applications
In this section, we will consider three applications in three domains: biology, medicine, and economics to illustrate for present theories and to test established algorithms. They also show that the proposed algorithm presents more advantages than the existing ones.
Application 1. We consider classification for well-known Iris flower data, which have been presented in many documents like in Ref. [17]. These data are often used to compare the new In this application, the cases of one, two, three and four variables are respectively considered to classify for three groups (Se), (Ve), and (Vi) by Bayesian method with different prior probabilities. The purpose of this performance is to compare the results of BayesC with BayesU, BayesR, and BayesL. Because the numbers of the three groups are equal, and the results of BayesU, BayesR, and BayesL are the same. The correct probability of methods is summarized in Table 3. Table 3 shows that in almost all cases, the results of proposed algorithm are better than those using other algorithms, and in the case using three variables X1, X2, and X3, it gives the best results.
Application 2. This application considers thyroid gland disease (TGD). Thyroid gland is an important and the largest gland in our body. It is responsible for the metabolism and work process of all cells. Some of the common diseases of gland thyroid are hypothyroidism, hyperthyroidism, thyroid nodules, and thyroid cancer. Triiodothyronine (X8), Total thyroxin (X9), T4U measured (X10), and Referral source (X11). In this application, this chapter will use random 70% of the data size (2479 elements belong to group I and 162 elements belong to group NI) as the training set to determine significant variables, to estimate pdfs, and to find suitable model. About 30% of the remaining data will be used as test set (1062 elements belong to group I and 69 elements belong to group NI). The result of Bayesian method is also compared to others.
To assess the effect of independent variables in TGD, we build the logistic regression model log (p/1Àp) with variables Xi, i = 1, 2, …, 11 (p is the probability of TGD). The analytical results are summarized in Table 4.
In Table 4, the three variables X1, X8, and X11 in bold face have statistical significance in classifying the two groups (I) and (NI) at 5% level, so we use them to classify TGD.
Applying the PPC algorithm for cases of one variable, two variables, and three variables with all prior probabilities, we obtain the results given in Table 5. Using the best results for each case of methods from Table 6, classifying for test set (1131 elements), we have the results given in Table 7.
From Table 7, we see that with the test set, BayesC also gives the best result.
Application 3. This application considers the problem of repaying bank debt (RBD) by customers. In bank credit operations, determining the repayment ability of customers is really important. If the lending is too easy, the bank may have bad debt problems. In contrast, the bank will miss a good business. Therefore, in the current years, the classification of credit application on assessing the ability to repay bank debt has been specially studied and has been a difficult problem in Vietnam. In this section, we appraise this ability of companies in Can Tho city (CTC), Vietnam by using the proposed approach. We collect a data on 214 enterprises operating in key sectors as agriculture, industry, and commerce, including 143 cases of good debt (G) and 71 cases of bad debt (B). Data are provided by responsible organizations of CTC. Each company is evaluated by 13 independent variables in the expert opinion. The specific variables are given in Table 8.
Because of sensitive problem, author has to conceal real data and use training data set. The steps to perform in this application are similar as in Application 2. Training set has 100 elements belonging to group G and 50 elements belonging to group B, and the test set has 43 elements belonging to group G and 21 elements belonging to group B. With training set, the logistic regression model shows only three variables X1, X4, and X7 have statistical significance at 5% level, so we use these three variables to perform BayesU, BayesR, BayesL, and BayesC. Their results are given in Table 9.
From Table 9, we see that BayesC gives the highest probability in all the cases. We also use logistic method, Fisher, and SVM with training set to find the best results. We have the correct probability given in Table 10. Using the best model for each case of methods from Table 10 to classify the test set (67 elements), we obtain the results given in Table 11.
Once again from Table 11, we see that with test data, BayesC also gives the best result.   Table 10. The correct probability (%) for optimal models of methods in classifying RBD.

Conclusion
This chapter presents the classification algorithm by Bayesian method in both theory and application aspect. We establish the relations of Bayes error with other measures and consider the problem to compute it in real application for one and multidimensions. An algorithm to determine the prior probabilities which may decrease Bayes error is proposed. The researched problems are applied in three different domains: biology, medicine, and economics. They show that the proposed approach has more advantages than existing ones. In addition, a complete procedure on MATLAB software is completed and is effectively used in some real applications. These examples show that our works present potential applications for research on real problems.

Author details
Tai Vovan Address all correspondence to: vvtai@ctu.edu.vn College of Natural Sciences, Can Tho University, Can Tho City, Vietnam