联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2021-04-03 11:12

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)


版权所有:编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。