Full explanations on Bayes Probability and Naive Bayes Probability are in the
Classification by Bayes Probability Explained Page
. This panel presents help and advice on how to use the program in the previous panel on this page.
Definitions and Conventions
Attributes (a) are mutually exclusive alternatives in a predictor. When there are multiple predictors, combinations of attributes form a
pattern. Patterns for the program on this page (Basic Bayes) can be any string of characters with no spaces or tabs. The patterns in the default example of this page are strings of +s and -s because it uses the same data as that in
Classification by Bayes Probability Explained Page
and
Classification by Naive Bayes Probability Program Page
. However, users can use any other text string to represent attributes, such as Dark_hair_Blue_eye or DhBy.
Input Data are placed in the first text area labeled "Data" in Program 1, and can be in one or two formats
- For Program 1 in the previous panel, for building and testing a model, both the patterns and the outcome names are required. These are in two columns separated by spaces of tabs. The first the pattern, the second the outcome names. Each row consists of the combination of attributes and outcomes in a case.
- For all other programs in the previous panel, data is optional, and when present is interpretted by the model. Only the first column of patterns are read and interpreted.
a priori Probability is a believe in the probability of belonging to a outcome prior to executing the Baysian model. In data entry, any set of number representing relative proportions (sample size, ratios, percents) can be used, and the program will normalize them by dividing each by the total. The default setting is to have the same apriori probability for all outcomes. User should change this when calculating Bayesian probability P(o|p,π).
Cost Coefficients is an array of number representing the relative lost to the model if an outcome is misidentified, so represents the importance of each outcome. Any set of numbers representing relative values can be used (dollar, quality of life, death rate), as the program normalizes the numbers to proportions of the total. The default setting is for all outcomes to have the same cost, and in most cases no change to this is required. Changes are only required if the user wishes to insert a calibrated bias into the model
Probabilities
The program produces 2 type of probabilities during model development
- P(pattern|outcome) or P(p|o) is the probability of having the pattern when the outcome is known. This represents the coefficients for calculating Bayesian Probability from patterns.
- P(outcome|pattern) or P(o|p) is the probability of having an outcome when the attribute pattern is observed, without any other considerations. This is called Maximum Likelihood, representing how the coefficients function.
The model produces
P(outcome|pattern,π,c) or P(o|p,π,c), the final Bayes Probability, taken differences in a priori probabilities and cost coefficients into consideration. Using default setting, the results are the same as P(o|p), as the sample size from all outcomes are the same, and cost coefficients are the same by default.
Programs
The programs on this page consists of a single program with 3 points of entry (Program 1-3), and a supplementary program (program 4) to create a Javascript interpreter. The Example buttons triggers the loading of the default example data for each entry, and runs the program using that data. Users can enter his/her own data and runs the program with the program buttons
Program 1 models and interprets the same data
- The data is in two columns separated by tabs or spaces. The first column contains the pattern strings, the second column the Outcome names
- The program first counts the number in each outcome, and the number of patterns for each outcome, forming the table of counts. It deposits the two counts as entry data for Program 2
outcome
- The program also deposits the sample size for the 3 outcomes as apriori probabilities for Program 3. By default, the program produces the same cost coefficients (1), and deposits as costs for program 3
- The program then converts the apriori and cost coefficients to proportion of the total, by dividing each value by the total of all outcomes
- Using the array of patterns, the program calculates the probability of the pattern for each case (P(p|o). The is presented for error checking only, and is not interpreted.
- The program then converts P(p|o) to probability of each outcome for each pattern (P(o|p)). This is the first a posteriori Probability, assuming apriori probabilities and cost coefficients from all outcomes to be the same. This results provide an estimate of how well the model separates the outcomes using the reference data that creates the model.
- The program then modifies the initial a posteriori Probability using the apriori and cost arrays to produce the final a posteriori Probability (P(o|p,π,c)), by multiplying each probabiliy by the two coefficients, then recalibrate the coefficients as fractions of their total.
- All results are presented to the maximum precision of 4 decimal places in this program
Program 2 begins with the table of counts, and is used to avoid the entry of large volumn of data when the counting has been previously done already.
- The number of columns in the table of counts is the number of outcomes
- The first row contains the outcome numes
- All sunsequent rows are the counts in each attribute for the outcomes
- The sample size for the outcomes are entered separately as an array separated by spaces
- The program reads in the data, and executes steps 3-5 of program 1
- If the data text area is empty, the program terminates
- If there is data, the program reads the first column as attributes, and executes steps 6-9 of Program 1
Program 3 begins with the table of probabilities of each pattern for each outcome (P(p|o)), the two arrays of apriori probability and the cost coefficients, and the patterns. It can be used to interpret any pattern when the table of P(p|o) is already available, and allows the apriori probabilities and cost coefficients to be adjusted.
- The table of probabilities has the same format as the table of counts, except that the numbers are probabilities
- The arrays of apriori and costs can be numbers in any format, as the program will normalize each value as a fraction of the total before they are used.
- The attributes must be in the first or only column in the data text area.
- The program reads in the data, and executes steps 6-9 of program 1
Program 4 is supplementary, and can be executed when the table of probabilities of each pattern for each outcome (P(p|o)), and the two arrays of apriori probability and the cost coefficients and available and adjusted the the user's requirements
- It produces a Javascript subroutine which accepts a pattern text string, and return an array of probabilities
- It is intended for the user to edit, change, or append this program, and incorporate it is his/her own program to interpret future data.
- The user will need to program to handle the array of numbers returned.