Question
(Problem 2.1) Use Bayes rule to solve the following problem: At a party you meet a person who claims to have been to the same
(Problem 2.1) Use Bayes rule to solve the following problem: At a party you meet a person who claims to have been to the same school as you. You vaguely recognize them, but cant remember properly, so decide to work out the probability that it is the case, given that: a. you vaguely recognize 1 in 2 of the people who went to school with you; b. 1 in 10 of the people at the party went to school with you; c. 1 in 5 people at the party you vaguely recognize. 2. An economics consulting firm has created a model to predict recessions. The model predicts a recession with probability 80% when a recession is indeed coming and with probability 10% when no recession is coming. In general, recession occurs with an overall chance of 20%. If the model predicts a recession, what is the probability that a recession will indeed come? 3. In some cases of probability-based classification, one wants to classify on minimizing the risk of misclassification. For example, the misclassification of someone sick being healthy should always be avoided, while sometimes, the risk of misclassifying some healthy persons as sick is also high, as the treatment may have significant side effect. The risk of misclassification can be represented by a loss matrix that specifies the risk of misclassifying class Ci as class Cj. Typically, the leading diagonal of loss matrix contains zeros, since there should be no risk for correct prediction. Once the risk matrix is given, we can just extend our classier to output the result with the minimal risk, which multiplies the probability of each outcome by their respective loss number. Given the loss matrix for a classification of a putative liver disease in three classes: {Healthy, Cirrhosis, Liver Cancer} as below: Prediction
For one patient, the prediction probabilities are P(H) = 0.5, P(C)=0.2, P(LC)=0.3. What should be output of the prediction with the minimum risk? Explain your answer. 4. (Car theft problem) The police department at Bayesville have a theory that the probability of a car is stolen is dependent on three attributes of the car: color (red, yellow or blue), type (sports or family) and origin (domestic or imported). The police department has observed the following ten cases with the car stolen or not. No. Color Type Origin Stolen?
Derive a Nave Bayes model to predict the probability of any car being stolen from its attributes, and use the model to compute the probability of a car of the attributes {Red, Family, Domestic}. 5. Modify the EM implementation (to allow for three classes (each following a Gaussian distribution with different mean and standard deviation) in the data. You should modify the code to generate three classes of the data and use the EM algorithm to learn the parameters for the three Gaussian distribution. which should include the implementation as well as a short description of your simulation result.
CODE BELOW
______________________________
{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Copy of EM algorthm.ipynb", "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "code", "metadata": { "id": "pLDEgi3wBBzO", "colab_type": "code", "outputId": "712959d3-e5fe-4462-de39-6c63b52682c5", "colab": { "base_uri": "https://localhost:8080/", "height": 392 } }, "source": [ "import numpy as np ", "import matplotlib.pyplot as plt ", " ", "# set random seed so that everytime we get the same result ", "np.random.seed(1) ", " ", "# prepare simulation data ", "N1 = 1000 ", "N2 = 1000 ", "N = N1 + N2 ", "real_mu1 = 0.2 ", "real_std1 = 1 ", "real_mu2 = 0.8 ", "real_std2 = 1 ", "y = np.concatenate((np.random.normal(real_mu1, real_std1, N1), np.random.normal(real_mu2, real_std2, N2))) ", " ", " ", "# EM algorithm ", " ", "# Initialization ", "nits = 1000 ", "count = 0 # should be initialized as 0 ", "p1 = 0.5 ", "p2 = 0.5 ", "mu1 = np.random.random() ", "mu2 = np.random.random() ", "s1 = np.std(y) ", "s2 = s1 ", "ll = np.zeros(nits) ", "gamma1 = np.zeros(N) ", "gamma2 = np.zeros(N) ", " ", "while count ]" ] }, "metadata": { "tags": [] }, "execution_count": 18 }, { "output_type": "display_data", "data": { "image/png": "EXAMPLEPHOTOHERE ", "text/plain": [ "
\begin{tabular}{|l|l|l|l|l|} \hline \multicolumn{2}{|c|}{} & Prediction \\ \cline { 3 - 5 } \multicolumn{2}{|c|}{} & H & C & LC \\ \hline \multirow{3}{*}{ Real } & H & 0 & 1 & 5 \\ \cline { 2 - 5 } & C & 5 & 0 & 3 \\ \cline { 2 - 5 } & LC & 20 & 10 & 0 \\ \hline \end{tabular} \begin{tabular}{|l|l|l|l|l|} \hline No. & Color & Type & Origin & Stolen? \\ \hline 1 & Red & Sports & Domestic & Yes \\ \hline 2 & Red & Sports & Domestic & No \\ \hline 3 & Red & Sports & Domestic & Yes \\ \hline 4 & Yellow & Sports & Domestic & No \\ \hline 5 & Yellow & Sports & Imported & Yes \\ \hline 6 & Yellow & Family & Imported & No \\ \hline 7 & Yellow & Family & Imported & Yes \\ \hline 8 & Yellow & Family & Domestic & No \\ \hline 9 & Red & Family & Imported & No \\ \hline 10 & Red & Sports & Imported & Yes \\ \hline \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started