Please use Google Collab to open the zipped file and follow the instructions.
Answer the questions by using Python.
With what information does Bayes Theorem update our previous knowledge about the data parameters?
What does the prior probability represent?
For the following exercises, work with the wine_flag_training and wine_flag_test data sets. Use either Python to solve each problem. Here are the links to the datasets:
https://raw.githubusercontent.com/ArashVafa/DESC624/master/wine_flag_training.csv
https://raw.githubusercontent.com/ArashVafa/DESC624/master/wine_flag_test.csv
Create two contingency tables, one with Type and Alcohol_flag and another with Type and Sugar_flag. Use the tables in the previous exercise to calculate:
- The prior probability of Type = Red and Type = White.
- The probability of high and low alcohol content.
- The probability of high and low sugar content.
- The conditional probabilities p(Alcohol_flag = High ∣ Type = Red) and p(Alcohol_flag = Low ∣ Type = Red).
- The conditional probabilities p(Alcohol_flag = High ∣ Type = White) and p(Alcohol_flag = Low ∣ Type = White).
- The conditional probabilities p(Sugar_flag = High ∣ Type = Red) and p(Sugar_flag = Low ∣ Type = Red).
- The conditional probabilities p(Sugar_flag = High ∣ Type = White) and p(Sugar_flag = Low ∣ Type = White).
Use the probabilities in the previous exercise to discuss
- How likely it is that a randomly selected wine is red.
- How likely it is that a randomly selected wine has a high alcohol content.
- How likely it is that a randomly selected wine has a low sugar content.
Use the conditional probabilities found earlier to discuss
- What a typical white wine might have as its alcohol and sugar content.
- What a typical red wine might have as its alcohol and sugar content.
Create side‐by‐side bar graphs for Type, one with an overlay of Alcohol_flag and the other with an overlay of Sugar_flag. Compare the graphs to the conditional probabilities you calculated.
Compute the posterior probability of Type = Red for a wine that is low in alcohol content and high in sugar content. Compute the posterior probability of Type = White for the same wine.
Use your answers to the previous exercise to determine which type, red or white, is more probable for a wine with low alcohol and high sugar content. What would the Naïve Bayes classifier classify this wine as?
Compute the posterior probability of Type = Red for a wine that is high in alcohol content and low in sugar content. Compute the posterior probability of Type = White for the same wine.
Use your answers to the previous exercise to determine which type, red or white, is more probable for a wine with high alcohol and low sugar content. What would the Naïve Bayes classifier classify this wine as?
Run the Naïve Bayes classifier to classify wines as white or red based on alcohol and sugar content.
Evaluate the Naïve Bayes model on the wines_test data set. Display the results in a contingency table. Edit the row and column names of the table to make the table more readable. Include a total row and column.
According to your table in the previous exercise, find the following values for the Naïve Bayes model:
- Accuracy
- Error rate
According to your contingency table, find the following values for the Naïve Bayes model:
- How often it correctly classifies red wines.
- How often it correctly classifies white wines.
Name a few classification algorithm, choose one and use it on a dataset of your choosing.
Apply ANN and decision tree algorithm on the wine dataset and compare the result? which one is better and why?
CodeText