01 Apr This project will expose you to inference using Bayesian networks. Bayesian networks capture causal relationships and are widely used in fault diagnosis across a wide variety of ap
Purpose:
This project will expose you to inference using Bayesian networks. Bayesian networks capture causal relationships and are widely used in fault diagnosis across a wide variety of applications. A Bayesian network can be represented by a directed graph which will model causal relationships between variables. A useful tool to represent and traverse a graph is NetworkX (NetworkX — NetworkX documentation) which contains a comprehensive library of graph types and graph algorithms written in Python. The application that we will be targeting is Car fault diagnosis which was introduced in class. The fundamental issue in such diagnosis applications is to discover the causes or underlying reasons for the fault to occur and to rank these reasons in terms of their importance.
In this application we will be exploring the reasons behind: a) the car not starting and the probability that this event takes place; and b) under what conditions the car battery becomes flat and the likelihood of this occurring.
Project Requirements:
R1
Use Networkx in Google Colab and represent the network as shown below:
Attach probability tables to each node as specified in the Project 3 discussion document. Visualize the network using Networkx and show the nodes and edges. You do not have to show the probability tables you created but this of course will be embedded in your code. The coloring used in the figure above does not need to be reproduced. Instead, use a neutral color of blue to shade the nodes. Make sure that your edges show directionality.
R2
Compute the probability P (-cs, +ab, +fb)
R3
Compute the probability P (-cs, +ab)
R4
Compute the probability P(-cs, +fb)
R5
For the battery going flat, which of the factors is more important, battery dead or not charging?
Note:
- Use the starter code provided for this project. This is essential as many of you will not be familiar with NetworkX.
- I strongly recommend that you read the Project 3 Discussion Document as it covers not just the probability table creation but also what formulae needs to be used to compute the answers to requirements R2 to R5.
This document will cover two aspects:
1. The values to be attached to the probability tables, and
2. The formulae to be used to compute the probabilities that are required.
Probability table specification In total there are 16 nodes for the Car diagnosis Bayesian network. This means that 16 probability tables are
required. These tables must be assigned values according to the specifications below.
1. Battery age table
ba _y 0.2 ba_n 0.8
2. Alternator broken table
ab_y 0.1 ab_n 0.9
3. Fanbelt broken table
fb_y 0.3 fb_n 0.7
4. Battery dead table
ba_y_bd_y 0.7 ba_y_bd_n 0.3 ba_n_bd_y 0.3 ba_n_bd_n 0.7
Note that this table represents conditional probabilities. Thus for example, the row ba_y_bd_y=0.2 should be
interpreted as the Pr(battery being dead|battery is aged) is 0.2. All other tables below which have more than two
rows also happen to represent conditional probabilities.
5. No charging table
ab_y_fb_y_nc_y 0.75
ab_y_fb_n_nc_y 0.4
ab_n_fb_y_nc_y 0.6 ab_n_fb_n_nc_y 0.1 ab_y_fb_y_nc=n 0.25 ab_y_fb_n_nc=n 0.6 ab_n_fb_y_nc=n 0.4 ab_n_fb_n_nc=n 0.9
6. Battery meter table
bd_y_bm_y 0.9 bd_y_bm_n 0.1 bd_n_bm_y 0.1 bd_n_bm_n 0.9
7. Battery flat table
bd_y_nc_y_bf_y 0.95
bd_y_nc_n_bf_y 0.85
bd_n_nc_y_bf_y 0.8 bd_n_nc_n_bf_y 0.1 bd_y_nc_y_bf_n 0.05 bd_y_nc_n_bf_n 0.15 bd_n_nc_y_bf_n 0.2 bd_n_nc_n_bf_n 0.9
8. No oil table
no _y 0.05 no_n 0.95
9. No gas table
ng _y 0.05 ng_n 0.95
10. Fuel line blocked table
fb _y 0.1 fb_n 0.9
11. Starter broken table
sb _y 0.1 sb_n 0.9
12. Lights table
l_y_bf_y 0.9 l_n_bf_y 0.3 l_y_bf_n 0.1 l_n_bf_n 0.7
13. Oil lights table
bf_y_no_y_ol_y 0.9
bf_y_no_n_ol_y 0.7
bf_n_no_y_ol_y 0.8 bf_n_no_n_ol_y 0.1 bf_y_no_y_ol_n 0.1 bf_y_no_n_ol_n 0.3 bf_n_no_y_ol_n 0.2 bf_n_no_n_ol_n 0.9
14. Gas gauge table
bf_y_ng_y_gg_y 0.95
bf_y_ng_n_gg_y 0.4
bf_n_ng_y_gg_y 0.7 bf_n_ng_n_gg_y 0.1 bf_y_ng_y_gg_n 0.05 bf_y_ng_n_gg_n 0.6 bf_n_ng_y_gg_n 0.3 bf_n_ng_n_gg_n 0.9
15. Car won’t start table
This table has 64 rows. There are 3 cases to consider:
1. For every combination of bf, no, ng, fb, sb with at least one of these variables taking the value y, the
probability is 0.9 for the cs_n outcome.
2. For the case when all 5 variables bf, no, ng, fb, sb take the value n with cs_n. In this case the probability is 0.1
3. The remaining case is when cs_N. The probabilities are now defined as the complement of the probabilities
of the first 32 rows. That is if the probability is p for the first row then it is (1-p) for the 33rd row, if it is q for
row 2 then it is (1-q) for row 34 and so on.
Note this table must be encoded in the graph with 64 rows and each row should have a probability as specified
above.
16. Dipstick low table
no_y_dl_y 0.95 no_n_dl_y 0.3 no_y_dl_n 0.05 no_n_d_n 0.7
Formulae for computation of probabilities In addition to the discussion below you are strongly advised to refer to the class notes on Bayesian learning.
Let us illustrate the computation of the probabilities by taking R2 as an example.
For R2 you are asked to compute P(-cs, +ab, +fb) – this is the joint probability that the car does not start whenever
both the alternator and fan belt are not functioning at the same time.
To understand how this is done, let us first look at a simpler situation.
P(+c, +a, +b) = P(+c|+a, +b)*P(+a)*P(+b)
Using this as a guide we can now work out P(-cs, +ab, +fb)
,
Purpose: This project will expose you to inference using Bayesian networks. Bayesian networks capture causal
relationships and are widely used in fault diagnosis across a wide variety of applications. A Bayesian
network can be represented by a directed graph which will model causal relationships between
variables. A useful tool to represent and traverse a graph is NetworkX (NetworkX — NetworkX
documentation) which contains a comprehensive library of graph types and graph algorithms written
in Python. The application that we will be targeting is Car fault diagnosis which was introduced in
class. The fundamental issue in such diagnosis applications is to discover the causes or underlying
reasons for the fault to occur and to rank these reasons in terms of their importance.
In this application we will be exploring the reasons behind: a) the car not starting and the probability
that this event takes place; and b) under what conditions the car battery becomes flat and the
likelihood of this occurring.
Project Requirements: R1
Use Networkx in Google Colab and represent the network as shown below:
Attach probability tables to each node as specified in the Project 3 discussion document. Visualize
the network using Networkx and show the nodes and edges. You do not have to show the probability
tables you created but this of course will be embedded in your code. The coloring used in the figure
above does not need to be reproduced. Instead, use a neutral color of blue to shade the nodes.
Make sure that your edges show directionality.
R2
Compute the probability P (-cs, +ab, +fb)
R3
Compute the probability P (-cs, +ab)
R4
Compute the probability P(-cs, +fb)
R5
For the battery going flat, which of the factors is more important, battery dead or not charging?
Note:
1. Use the starter code provided for this project. This is essential as many of you will not be
familiar with NetworkX.
2. I strongly recommend that you read the Project 3 Discussion Document as it covers not just
the probability table creation but also what formulae needs to be used to compute the
answers to requirements R2 to R5.
,
# -*- coding: utf-8 -*- """directed_graph.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1i5mT15-UVwTbi5J21cbh6WmeWahDZDTb """ import networkx as nx G = nx.DiGraph() # create a directed graph G.add_node("ab") # label nodes print(G.nodes) G.add_edges_from([("ab", "nc"), ("fb", "nc")]) # add edges print(G.nodes) print(G.edges) G.add_node("ab", ab_y=0.1, ab_n=0.9) # add node attributes – useful for attaching probabiity tables to nodes G.add_node("fb", fb_y=0.2, fb_n=0.8) # let's go down one level and attach a table to the "no charging node" G.add_node("nc", ab_y_fb_y_nc=y= 0.75, ab_y_fb_n_nc=y= 0.4, ab_n_fb_y_nc=y= 0.6, ab_n_fb_n_nc=y= 0.1,ab_y_fb_y_nc_n= 0.25, ab_y_fb_n_nc_n= 0.6, ab_n_fb_y_nc_n= 0.4, ab_n_fb_n_nc_n= 0.9) # probabiluity table for "no charging" node """Add nodes, edges and probability tables for the rest of the network. After your network is fully defined you can begin the inference process. One useful tool to use in inferencing is the depth first search procedure that will return all paths leading to a given node from all root nodes in the graph. This is implemented via the all_simple_paths method in Networkx """ roots = (v for v, d in G.in_degree() if d == 0) all_paths = [] for root in roots: paths = nx.all_simple_paths(G, root, "nc") all_paths.extend(paths) all_paths
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.