Research on Application of Naive Bayes Algorithm Based on Attribute Correlation to Unmanned Driving Ethical Dilemma

At present, unmanned driving technology has made great progress, while those research on its related ethical issues, laws, and tra c regulations are relatively lagging. In particular, it is still a problem how unmanned vehicles make a decision when they encounter ethical dilemmas where tra c collision is inevitable. So it must hinder the application and development of unmanned driving technology. Firstly, 1048575 survey data collected by Moral Machine online experiment platform is analyzed to calculate the prior probability that the straight being protector or sacricer in ethical dilemmas with single feature. en, 116 multifeature ethical dilemmas are designed and surveyed.e collected survey data are analyzed to determine decision-making for these ethical dilemmas by adopting the majority principle and to calculate correlation coe cient between attributes, then an improved Naive Bayes algorithm based on attribute correlation (ACNB) is established to solve the problem of unmanned driving decision in multifeature ethical dilemmas. Furthermore, these ethical dilemmas are used to test and verify traditional NB, ADOE, WADOE, CFWNB, and ACNB, respectively. According to the posterior probability that the straight being protector or sacricer in those ethical dilemmas, classication and decision are made in these ethical dilemmas.en, the decisions based on these algorithms are compared with human decisions to judge whether these decisions are right. e test results show that ACNB and CFWNB are more consistent with human decisions than other algorithms, and ACNB is more conductive to improve unmanned vehicle’s decision robustness than NB.erefore, applying ACNB to unmanned vehicles has a good role, which will provide a new research point for unmanned driving ethical decision and a few references for formulating and updating tra c laws and regulations related to unmanned driving technology for tra c regulation authorities.


Introduction
At present, unmanned driving technology has achieved good development and application. Many automobile manufacturers, such as Tesla, Uber, and NIO in China, have produced L2 or L3-level autonomous vehicles. However, these researches on unmanned driving ethical decisions and formulation of laws or regulations related to unmanned driving technology are still lagging. In particular, how unmanned vehicles make decisions facing inevitable collisions is still a di cult problem. e reasons may be due to two aspects: First, the pre-allocation scheme of accident risk lacks necessary social consensus. Unlike a traditional driver, who can decide on the spot, unmanned vehicles need to make arrangements before an accident. Second, the relationship between unmanned driving and traditional tra c laws, and regulations needs to be coordinated [1,2]. For example, whether unmanned vehicle can violate tra c laws and regulations to avoid collision in an emergency, traditional tra c laws and regulations need to be updated and improved. erefore, the China development research foundation released the report "Future Cornerstone--the Social Role and Ethics of Arti cial Intelligence" in 2018, which argued that, "From a humanistic perspective, arti cial intelligence(AI) has brought about some fundamental problems that have already happened or will happen to shake the foundation of our society". "AI is also challenging traditional laws, regulations and social norms". "Considering the far-reaching impact of AI, the whole society needs to make joint e orts to formulate ethical guidelines and policies for application" [3]. In addition, it is also hard to determine who will be responsible for an accident for unmanned vehicles. us, Tesla's rights protection event at the 2021 Shanghai Auto Show has impacted on application and market promotion of unmanned driving technology. erefore, it is urgent to study the unmanned driving ethical decision and formulate laws and regulations related to unmanned driving technology. e current researches on unmanned driving ethical decision are still in the stage of theoretical exploration, in which influencing factors, implementation principles, and framework of unmanned driving ethical decisions are considered by philosophy, sociology, and law et al. e result shows that users or owners of unmanned vehicles are more willing to protect passengers than pedestrians [4], which may violate the utilitarian principle of protecting more people. While Anja K. Faulhaber et al. also demonstrated that human beings tend to make decisions based on the utilitarian principle in an ethical dilemma by VR. In order to protect more pedestrians on the road, the users of unmanned vehicles would rather sacrifice themselves. Especially, when there are 4-5 pedestrians on the road, more users or owners choose to sacrifice themselves to protect pedestrians [5]. However, it is hard to quantify the utility and consequence of various decision-making. e Massachusetts Institute of Technology(MIT) aims to get a comprehensive understanding of mankind would like unmanned vehicles to make decisions in ethical dilemmas, Moral Machine, an online experimental platform, was set up to carry out questionnaires around the world in 2016. e Moral Machine is designed as a multilingual online "serious game" to gather as much data as possible from all over the world to assess moral preferences by learning how respondents would want autonomous vehicles to solve moral dilemmas in the event of an unavoidable accident. So far, too much decision data in 10 languages have been collected from millions of people in 233 countries and territories, and all survey data in the Moral Machine can be accessed and downloaded at https://goo.gl/JXRrBP. According to the survey result, there are three strong preferences: to protect human beings, to protect more lives, and to protect the younger [6]. However, human unilateral preference cannot solve the problem of ethical decision in moral dilemmas with multi-feature. In addition, Kochupillai et al. thought that applying survey data of Moral Machine directly to unmanned driving ethical decision leads to infringement of some people's right to life, so it is unfair to discriminate against some people with some external attributes [7]. Each user or owner of the unmanned vehicle has a different requirement for unmanned driving ethical decision, a few designers of unmanned vehicles change the right of choosing unmanned driving ethical decision mode from manufacturers and designers to users or owners, a "moral knob" architecture was proposed for unmanned vehicles, which allowed users or owners to choose ethical decision principle or algorithm according to their requirements [8]. However, the "moral knob" architecture makes some users or owners violate the overall interests of mankind for maximizing personal interest, which can bring up a prisoner's dilemma. Menon et al. proposed an implementation method of unmanned driving ethical decision, which integrated unmanned driving ethical decision function into safety requirements. So that the ethical requirements can be taken into account in the safety design of unmanned vehicles [9]. However, there is nothing to specify a few mechanisms to implement how unmanned vehicles make ethical decisions. Millar et al. proposed to apply machine ethical decision mechanism to unmanned vehicles and design a general ethical evaluation tool to verify and evaluate the effect of unmanned driving ethical decisions [10]. Pickering et al. also proposed an M2D(Module to Decision) mechanism to predict injury to passengers or pedestrians, then unmanned vehicles can choose decision with injury minimization in an ethical dilemma [11]. However, the mechanism only considers the impact of velocity on injury to passengers or pedestrians but does not consider collision direction and location, which is not perfect and comprehensive. Yueh-hua Wu et al. provided a method of ethical decision optimization based on reverse reinforcement learning. When a decision made by a machine is an action that mankind thinks should not be done, the machine is punished to minimize the occurrence of such action. Otherwise, the action taken by the machine is encouraged to increase occurrence of such action [12]. Maximilian Geisslinger et al. studied how unmanned vehicles make router planning and control decisions in ethical dilemmas from risk ethics theory. e ethical decision is implemented by Bayes theory principle, equality principle, and maximum and minimum principle [13]. However, this method does not specify the weight of each principle in the ethical decisions, how to implement is not clear. Evants et al. proposed an Ethical Valence eory(EVT). When autonomous vehicles are faced with a moral dilemma, a reinforcement learning algorithm is used to strengthen influencing factors in ethical decisions based on public acceptability and opinions, such as age, social relation, occupation and injury. which will be conducive to maximization of public acceptability as its goal to make decision in moral dilemmas [14]. However, the ethical decision mechanism is only in the theoretical stage, how to evaluate ethical valence is also difficult during implementation. Dietmar and Lucie studied the ethical decision of unmanned vehicles from the perspective of social contract. Contract doctrine is explicitly designed to derive standards acceptable to all rational subjects to eliminate disagreement on thorny ethical issues [15]. However, it is a hard task for unmanned vehicles to distinguish between accident stakeholders and non-stakeholders in moral dilemmas, so as to avoid sacrificing negative rights of nonstakeholders to protect positive rights of stakeholders.
In all, the current research on unmanned driving ethical decision have made some progress and developments, but there have been only a few types of research on influence factor, implementation principle, and theoretical method from philosophy, law, and sociology. e consideration is less on human acceptability and technical feasibility, for which it is hard for unmanned vehicles to make a satisfied ethical decision. So unmanned driving ethical decisions should be considered and studied from aspects of human acceptability and technical feasibility.

Naive Bayes Theory
Naive Bayes algorithm is a classification based on probability density analysis, which predicts the probability of unknown events by known events [14,15], which is very suitable for classification in the case of a small amount of training set data, simple and has good performance. However, the traditional Naive Bayes algorithm(NB) requires an assumption of independence among all attributes. e classification principle lies in solving the probability (p 1 , p 2 , ..., p n ) of attribute vector X(x 1 , x 2 , ..., x n ) being any classes (C 1 , C 2 , ..., C j ), where p j represents the probability of the attribute vector X being class C j , then Max(p 1 , p 2 , ..., p n ) is the class which X is. erefore, the classification problem can be transformed into solving the posterior probability by using known prior probability [16], as shown in formula.
where p(C j ) represents the probability that an attribute vector X is class C j in all training sets. p(x 1 , x 2 , ..., x n | Cj) represents the prior probability of having joint attributes x 1 , represents the probability of having joint attributes x1, x2, ..., x n in the training set. Since classification is judged by the maximum posterior probability, the denominator p(x1, x2, ..., x n ) is the same during calculating all posterior probabilities. So the probability is only a comparison between both molecular values. erefore, the solving process of formula 1 is simplified to the process of seeking maximum molecular value, as shown in formula.
Because each attribute is required to be independent of each other in NB, there is no dependence among these attributes x 1 , x 2 , ..., x n under the same class C j . erefore, the solving p(x1, x2, ..., x n |C j ) is transformed into the product of each attribute under the condition C j , as shown in formula.
However, there is an assumption of independence among all attributes in NB, which affects the accuracy and precision of classification and application in reality. So many experts have provided a few improvements and optimizations for the traditional NB. For example, the TAN algorithm, reduces the dependence of arbitrary attributes in NB by discovering the dependencies between attributes, which is realized by adding the association between attribute pairs [17]. Kononenko proposed a semi-naive Bayes classifier, which combines a few related attributes to form so-called combined attributed nodes [18]. Zhang provided a weighted naive Bayes(WNB) model that assigns different weights to each attribute based on the importance of each attribute [19]. However, each attribute weight is the same for all classes. So Jiang proposed a class-specific attribute weighting naive Bayes(CAWNB), which discriminatively assigned each attribute a specific weight for each class [20]. Moreover, Zhang also provided a class-specific attribute value weighting for naive Bayes. e approach assigned a specific weight to each attribute value, in which the classspecific attribute value weight matrix is learned by either maximizing the conditional log-likelihood or minimizing the mean squared error [21]. Kohavi combined a naive Bayes classifier with a decision tree, then the instance space was divided by a decision tree, by which a local naive Bayes classifier was established on each leaf node [22]. Zheng and Webb proposed a lazy Bayesian rule(LBR) learning technique by using a lazy learning strategy, which applies the lazy technique to the induction of local naive Bayesian rules [23]. Although the algorithm may improve the classification accuracy, its efficiency is very low. So Yu and Bain [24] proposed an optimized weighted lazy learning naive Bayes classification to improve its efficiency. Furthermore, Webb, et al. [25] proposed the average first-order dependent Bayesian model(AODE), which adopted an average strategy. Each of its sub-model is a SPODE model. All the attributes in the network constructed by the SPODE model depend on the same attribute node, which is also called super-parent node. e posterior probability in AODE is calculated by formula.
Experimental results show that AODE has better classification accuracy and stability than TAN in most data sets. Especially when data distribution in the training set and testing set is inconsistent, the advantage of AODE is more prominent. However, AODE assumes that all attributes contribute equally to class variables, which is unscientific. So some experts propose a weighted strategy based on attributes(WAODE) for the problem [26]. When calculating the joint probability of attribute node and class variables, a weight is assigned to each attribute to increase the influence on the classification decisions for these important attributes and weaken those unimportant attributes. Weighting strategies have two methods in general, one is weighting based on information gain ratio, and another is weighting based on mutual information. Experiments show that WAODE has a better classification effect, which takes weighting based on mutual information between attributes and class variables [27]. Furthermore, the posterior probability in WAODE is calculated by the following formula.
where w i represents the weight coefficient of each attribute, which may be calculated by formula.
Mathematical Problems in Engineering 3 However, AODE and WAODE both have a mandatory constraint that each attribute is super-parent in turn, which amplifies dependencies between attributes and ignores whether there is a real correlation between super-parent node and child node. So Zhong [28] proposed AODF and WAODF models. Firstly, the attribute node with a weak correlation with the super-parent node is selected based on the AODE model, which is called mutation node. en a parent node is selected for the mutated node once more, so multiple sub-networks will be established to form a firstorder dependent Bayesian forest model(AODF) and weighting model(WAODF). Furthermore, Jiang et al. [29] proposed a correlation-based feature weighting(CFWNB) filter for Naive Bayes, in which a feature-weighted naive Bayesian classifier is constructed by formula.
the weight for each feature is a sigmoid transformation of the difference between the feature-class correlation(mutual relevance) and the average feature-feature inter-correlation (average mutual redundancy), the difference may be calculated in formula.
where NI(A i ; C) is the normalized I(A i ; C) representing mutual relevance between attribute A i and class variable C. NI(A i ; A j ) is the normalized I(A i ; A j ) representing mutual redundancy between attribute A i and A j . ey are shown in formulas (9) and (10).
Since D i may be negative and the weights required by feature weighted naive Bayes should be positive, a standard logistic sigmoid function can be used to transform w i into the range (0,1) by formula.
In addition, considering attribute order and the causal relationship between parent and child attributes, hidden naive Bayes(HNB) was proposed by Jiang, in which a hidden parent is created for each attribute that combines these influences from all other attributes [30]. In HBN, the training data set is firstly divided into m training subsets by different attribute values of the class. For each training subset, the causal relationships between parent and child attributes and attribute order are determined based on the principle of minimum conditional entropy, and sub-modules are constructed. en a test instance is preassigned with class labels and a pseudo training set is constructed. e causal correlation between attributes is determined by the principle of minimum local conditional entropy. Furthermore, a sub-model is constructed. So classification is realized by the m + 1 sub-modes [31]. However, this model is constructed by conditional entropy among many attributes, which means only the training set is large enough, that the correlation between attributes can be better determined. Moreover, Jiang et al. proposed a simple, efficient deep feature weighting(DFW), which estimated the conditional probability of naive Bayes by deeply computing featureweighted frequencies from training data [32]. Considering when the number of the training sets is small and attributes are larger, the training samples are not enough to cover all attributes, the category conditional probability will be equal to 0, and it is impossible to achieve accurate classification. So a few experts proposed a way to solve the problem, in which Laplacian calibration is used [33]. However, the correlation between both attributes needs to be taken into account in ACNB, the p(x 1 , x 2 , ..., x n | C j ) is that the original product is multiplied by the maximum correlation coefficient corr(x l , x k ) between two attributes(x l ,x k ) [34,35], as shown in formula.
Since p(C j ) and p(x i | C j ) are both known prior probabilities, the maximum posterior probability that the feature X is class C j is calculated to determine which class the feature X belongs to.

Prior Probability and Attribute Correlation.
In order to get the prior probability that the straight is a protector or sacrificer in an ethical dilemma with single feature, 1048575 data on Moral Machine have been analyzed and studied to calculate prior probabilities of being protector and sacrificer in these ethical dilemmas with single feature, which is shown in Table 1.
Considering fitness, which is difficult to be recognized and distinguished by machines, the attribute is not considered in this paper. Only six attributes of gender, number, age, social status, traffic rule, and species areregarded as influencing factors of unmanned driving ethical decisions.
In addition, 116 multi-feature ethical dilemmas are designed and surveyed to achieve human decision data through the online and offline survey. 1006 people were surveyed to collect 18168 data items. According to the survey results, correlation coefficients between attributes are calculated. e decision in ethical dilemmas will be determined by the majority principle, which is determined on the basis of the probability of choosing as protector and sacrificer. For example, an ethical dilemma in Figure 1 An old man is crossing the road on a green light on the straight road. At the same time, a man is also crossing the road on a red light in the turning. When an unmanned vehicle cannot stop immediately, it must choose a pedestrian on one road to collide. According to survey data, 51.6% of respondents choose to turn and 48.4% choose to go straight in the ethical dilemma. So the old man in the straight is considered a protector, the unmanned vehicle should choose to turn to be consistent with human choice. e decision in other ethical dilemmas will also be determined in the same way. e correlation coefficient between both attributes can be calculated by the following formula.
C i is divided into two classes, C1 is protector, and C2 is sacrificer. erefore, attribute correlation should also be considered from two classes respectively. According to attribute values and decision data in 116 ethical dilemmas, the correlation coefficient between attributes may be calculated for protector as shown in Table 2. On the other hand, correlation coefficient may be calculated for sacrificer as shown in Table 3.
Since all respondents choose to protect mankind than others in 116 ethical dilemmas, the correlation between species and other attributes may be ignored.

Attribute Value and Attribute
Vector. In order to study unmanned driving ethical decisions in moral dilemmas, it is necessary to quantify attributes in all ethical dilemmas to get attribute values and attribute vectors in all ethical dilemmas. According to six features (gender, number, age, social status, traffic rule, and species), these attributes in each moral dilemma need to be quantified, and each attribute value is calculated by comparing the attributes of the straight road with that of the turning. For example, when the pedestrian in the straight is female and that in the turning is male, the attribute value is 1 for gender in the straight. Otherwise, when pedestrian in the straight is male and that in the turning is female, the attribute value is 2. When gender is the same, the attribute value is 0. For number, when road users in the straight are more than that in the turning, the attribute value is 1 for the number in the straight. When they are less, the attribute value is 2, otherwise, when they are the same, the attribute value is 0. When a pedestrian in the straight is younger than that in the turning, the attribute value is 1 for age. When pedestrian in the straight is older, the attribute value is 2. Otherwise, the attribute value is 0 for the same age. In the same way, when the pedestrian's social status in the straight is higher than that in the turning, the attribute value is 1. Otherwise, the attribute value is 2 for a lower social status. If their social status is the same or unclear, the    attribute value is 0. When pedestrians in the straight obey traffic rules and those in the turning violate traffic rules, the attribute value is 1 for traffic rule. If both obey or do not obey traffic rules, the attribute value is 0. Otherwise, the attribute value is 2. Lastly, when the species in the straight is mankind and that in the turning is pet or inanimate, the attribute value is 1 for species. On the contrary, the attribute value is 2.
If the species in the straight and the turning is the same, the attribute value is 0. However, an attribute vector is a combination of all attribute values in an ethical dilemma. For the ethical dilemma in Figure 1, Since the differences between the elderly in the straight and the man in the turning are to obey the traffic rule and be older, the corresponding attribute values in the straight are 1 for traffic rule and 2 for age. erefore, the attribute vector in the straight is [0,0,2,0,1,0] in the ethical dilemma. e attribute values and attribute vectors in other ethical dilemmas are determined in the same way.

Decision Mechanism
According to the above prior probability that the straight being protector or sacrificer, and attribute correlation between attributes, the posterior probability of being protector and sacrificer is calculated in an ethical dilemma by ACNB, which decides the straight will be a protector or sacrificer in an ethical dilemma. e algorithm implementation steps are shown in Table 4.
For example, there is an ethical dilemma in Figure 2. ere are a male doctor and a female doctor in the straight, who obey traffic rules to cross the road. At the same time, a fat lady, two fat men and a thief are crossing the road at a red light. erefore, the attribute differences between the straight and the turning are number, social status and traffic rule, so the corresponding attribute values are respectively 2, 1, and 1 in the straight. e attribute vector is [0 2 0 1 1 0] in the ethical dilemma. Furthermore, According to survey data on Moral Machine, there are 451304 respondents to survey the straight in all moral dilemmas, 289386 respondents choose the straight as protector, and 161918 respondents choose the straight as sacrificer, so p(C1) � 0.64 and p(C2) � 0.36 in formula (1). In addition, there are two attributes: social status and traffic rule, which are conducive to choosing the straight as a protector in the ethical dilemma, so the attribute correlation between social status and traffic rule should be considered during calculating probability. According to Table 2, the correlation coefficient is 1.60. Firstly, the probability of the straight being protector is calculated by formula (12).
On the other hand, the probability of the straight being sacrificer is calculated by formula (1).
erefore, the straight is chosen as a protector in the ethical dilemma by ACNB, unmanned vehicles will choose to turn to protect the pedestrians in the straight. For the human survey on the ethical dilemma, 50.7% of the respondents choose to turn and 40.3% choose to go straight. So the decision of ACNB is consistent with the human decision.

Test.
In order to test and verify the effect of ACNB in the unmanned driving ethical decisions, the 116 ethical dilemmas are chosen as test instances. en NB, ADOE, WADOE, CFWNB, and ACNB are respectively used to verify these test instances. e weight coefficient wi of each attribute is calculated by formulas (6) and (11) in WADOE and CFWNB, which are shown in Table 5.
e test results of all algorithms are shown in Table 6. erefore, ACNB and CFWNB are more suitable for human decision than other algorithms. In addition, probability deviations between being protector and sacrificer in 32 test instances are analyzed, as shown in Figure 3 e absolute probability deviations calculated by ACNB are more than those by NB, and their amplitude is larger, which will be conducive to robustness of unmanned driving ethical decision.    ACNB algorithm Input: Training set data D Output: ACNB network G (1) calculating the prior probability p(xi|Cj) between attribute xi and class cj (2) calculating correlation coefficient between attributes and constructing correlation coefficient matrix.
(3) solving maximum correlation coefficient between attributes in a test dilemma.
(4) solving the posterior probability of the straight being protector or sacrificer by NB and multiplied by the maximum correlation coefficient in the test dilemma (5) making a decision by comparing the products of posterior probability and correlation coefficient.

Conclusions
According to the current situation and existing problems in unmanned driving ethical decision, it is necessary to study unmanned driving ethical decision model and algorithm from the perspective of natural science, which may increase computability and feasibility of ethical decision. en correlation coefficient between attributes is calculated to establish the ACNB model for autonomous driving ethical decision, which is tested by 116 multi-feature dilemmas. e test results show that ACNB and CFWNB have a better effects than other algorithms and models. In addition, ACNB has stronger robustness than NB. However, the unmanned driving ethical decision is an important issue related to human life, so the accuracy is still far from practical application, for which further research on other influencing factors and algorithms are required in the future. But research and exploration is important to apply a few improved algorithms based on NB theory to unmanned driving ethical decision, which will increase the computability and feasibility of decision-making in an ethical dilemma for unmanned vehicles. So unmanned vehicle manufacturers may set up some algorithms based on human decision data in unmanned vehicles to realize self-decision in an ethical dilemma. However, these algorithms and models may have some discrimination in some external attributes, just like mankind, resulting in unfair decision of unmanned vehicles. erefore, when unmanned vehicle manufacturers embed these algorithms into unmanned vehicles, they should set ethical principles in unmanned vehicles in order to not violate human ethics. On the other hand, traffic laws and regulations related to unmanned driving can be formulated and designed by referring to the weight of each attribute, which is conducive to the formulation and improvement of traffic laws and regulations for traffic regulation authorities.

Data Availability
e data used to support the findings of this study are available from the corresponding open platform and previously reported studies and datasets.

Conflicts of Interest
e authors declare no conflicts of interest.