联系方式

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

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

日期:2021-04-17 11:26

CS165B Machine Learning

Spring 2021

Machine Problem 1

Due: Thursday, April 22 by 5:00pm PST 2021-04-13

1 Programming Assignment

Write a Python 3 program called pa1.py that implements a three-class linear classifier using the following

method:

Training (using the training data set):

1. Compute the centroid of each class (e.g. A, B, and C).

2. Construct a discriminant function between each pair of classes (e.g. A/B, B/C, and A/C), halfway

between the two centroids and orthogonal to the line connecting the two centroids. This is the “basic

linear classifier” that we have discussed.

Testing (using the testing data set):

1. For each instance, use the discriminant function to decide “A or B” and then (depending on that answer)

to decide “A or C” or “B or C.” (Ties should give priority to class A, then B, then C)

2. Keep track of true positives, true negatives, false positives, and false negatives.

The training and testing data sets are available in this starter package, along with a description of their formats

(PA1-5data.html), hints in PA1-5extra.pdf. You are also given a starter code file called pa1.py. In the pa1.py file

you will find the function

% def run train test(training input, testing input)

This function is where you implement the assignment. Feel free to define additional functions, but DO NOT

change this function signature and DO NOT change the pa1.py module name. We will call this as the entry

point to your code.

As output, the program should return a dictionary of averages over all three classes of the true positive rate,

the false positive rate, the error rate, the accuracy, and the precision:

% print(run train test(training input, testing input))

{ “tpr”: 0.80, # true positive rate

“fpr”: 0.27, # false positive rate

“error rate”: 0.44,

“accuracy”: 0.60,

“precision”: 0.90 }

(Note: These numbers are made up, for purposes of illustration only.) The run train test function should

return results using the same keys as shown.

Information on computing these averages is included in the pa1 starter package.

1.1 Evaluation Instructions

% python evaluate.py

1.2 Submission Instructions

Submit your file pa1.py to Gradescope for assignment MP1.

1


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