辅导INT104编程设计、Python,CSS。Java语言程序讲解
- 首页 >> Java编程 INT104: Artificial Intelligence Spring 2021
Lab 4: Linear Algebra and Probability
Disclaimer: 1. Lab reports deadlines are strict. University late submission policy will be applied.
2. Collusion and plagiarism are absolutely forbidden (University policy will be applied).
3. Report is due 14 days from the date of running this lab
4.1 Objectives
• Solve the general problems on linear algebra and probability knowledge.
4.2 Problem Statement
Given a two-dimensional array, where each row represents an instance (or object). For each row, the first 5
columns are the attributes of the instance and the final column is the label of the instance such as
a0, a1, a2, a3, a4, l
As you’ve seen, all attributes can take two values 0 or 1.
4-1
4-2 Lab 4: Linear Algebra and Probability
Now you’re required to compute the following estimated probabilities: p(l = 0), p(l = 1), p(ai = 0|l =
0), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 0), i = 0, 1, 2, 3, 4, p(ai = 0|l = 1), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 1), i =
0, 1, 2, 3, 4.
4.3 Lab Report
• Write a short report which should contain a concise explanation of your implementation, results and
observations (see the coursework template).
• Please insert the clipped running image into your report for each step with the mark.
• Submit the report and the python source code electronically into ICE.
• The report in pdf format and python source code of your implementation should be zipped into a single
file. The naming of report is as follows:
e.g. StudentID LastName FirstName LabNumber.zip (123456789 Einstein Albert 1.zip)
Hints: 1) use the fraction of the given events in all instances to estimate the probabilities (N is the total
number of the instances and # is the size of the set).
Lab 4: Linear Algebra and Probability 4-3
p(l = 0) = #{l = 0}
N
(4.1)
p(ai = 0|l = 0) = #{ai = 0, l = 0}
#{l = 0}
(4.2)
p(l = 1) = #{l = 1}
N
(4.3)
p(ai = 0|l = 1) = #{ai = 0, l = 1}
#{l = 1}
(4.4)
2) read the data from the file.
import csv
csv_file = open(’binary_data.csv’)
csv_reader = csv.reader(csv_file, delimiter=’,’)
Marking scheme:
• Read the text file and parse its content into a matrix. (20 scores)
• Compute the prior probabilities p(l = 0) and p(l = 1) (20 scores)
• Compute the conditional probabilities p(ai = 0|l = 0), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 0), i = 0, 1, 2, 3, 4,
p(ai = 0|l = 1), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 1), i = 0, 1, 2, 3, 4 (60 scores)
Lab 4: Linear Algebra and Probability
Disclaimer: 1. Lab reports deadlines are strict. University late submission policy will be applied.
2. Collusion and plagiarism are absolutely forbidden (University policy will be applied).
3. Report is due 14 days from the date of running this lab
4.1 Objectives
• Solve the general problems on linear algebra and probability knowledge.
4.2 Problem Statement
Given a two-dimensional array, where each row represents an instance (or object). For each row, the first 5
columns are the attributes of the instance and the final column is the label of the instance such as
a0, a1, a2, a3, a4, l
As you’ve seen, all attributes can take two values 0 or 1.
4-1
4-2 Lab 4: Linear Algebra and Probability
Now you’re required to compute the following estimated probabilities: p(l = 0), p(l = 1), p(ai = 0|l =
0), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 0), i = 0, 1, 2, 3, 4, p(ai = 0|l = 1), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 1), i =
0, 1, 2, 3, 4.
4.3 Lab Report
• Write a short report which should contain a concise explanation of your implementation, results and
observations (see the coursework template).
• Please insert the clipped running image into your report for each step with the mark.
• Submit the report and the python source code electronically into ICE.
• The report in pdf format and python source code of your implementation should be zipped into a single
file. The naming of report is as follows:
e.g. StudentID LastName FirstName LabNumber.zip (123456789 Einstein Albert 1.zip)
Hints: 1) use the fraction of the given events in all instances to estimate the probabilities (N is the total
number of the instances and # is the size of the set).
Lab 4: Linear Algebra and Probability 4-3
p(l = 0) = #{l = 0}
N
(4.1)
p(ai = 0|l = 0) = #{ai = 0, l = 0}
#{l = 0}
(4.2)
p(l = 1) = #{l = 1}
N
(4.3)
p(ai = 0|l = 1) = #{ai = 0, l = 1}
#{l = 1}
(4.4)
2) read the data from the file.
import csv
csv_file = open(’binary_data.csv’)
csv_reader = csv.reader(csv_file, delimiter=’,’)
Marking scheme:
• Read the text file and parse its content into a matrix. (20 scores)
• Compute the prior probabilities p(l = 0) and p(l = 1) (20 scores)
• Compute the conditional probabilities p(ai = 0|l = 0), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 0), i = 0, 1, 2, 3, 4,
p(ai = 0|l = 1), i = 0, 1, 2, 3, 4 and p(ai = 1|l = 1), i = 0, 1, 2, 3, 4 (60 scores)