Calculating the Parameters
Learn how we can calculate the parameters of norm and survival and run the QBN.
We'll cover the following...
Calculating the parameters of the norm
The function calculate_norm_params takes the Pandas dataframe of the passengers and returns the norm_params dictionary. From lines 2 to 10, we’ll specify different populations (groups) of passengers. Then, from lines 12 to 17, we’ll calculate the probabilities of a passenger being favored by a norm (Norm), given that the passenger belongs to a group.
In lines 3 and 4, we’ll separate the children from the adults in the data by evaluating whether the value of the column IsChild is 1 (children) or 0 (adults). In lines 7 to 10, we’ll further split these two groups into four based on whether the sex (Sex) is female or male.
Let’s pay some attention to how we calculate the probabilities of a passenger being favored by a norm in lines 13 to 16. We’ll sum the Norm of all passengers of a group and divide it by the number of passengers in the group. The Norm is the hidden variable. Similar to the example of a missing value, we’ll fill this column with a number between 0 and 1 that represents the probability of the respective passenger to be favored by a norm.
For example, if we have ten passengers and five have a value of , and five have a value of , we’ll get a resulting probability of ...