Question: 2.12 Python Lab: Comparing voting records using dot-product In this lab, we will represent a US senators voting record as a vector over R, and
2.12 Python Lab: Comparing voting records using dot-product In this lab, we will represent a US senators voting record as a vector over R, and will use dot-products to compare voting records. For this lab, we will just use a list to represent a vector.
Task 2.12.7: Write a procedure find average similarity(sen, sen set, voting dict) that, given the name sen of a senator, compares that senators voting record to the voting records of all senators whose names are in sen set, computing a dot-product for each, and then returns the average dot-product. Use your procedure to compute which senator has the greatest average similarity with the set of Democrats (you can extract this set from the input file).
Task 2.12.8: Write a procedure find average record(sen set, voting dict) that, given a set of names of senators, finds the average voting record. That is, perform vector addition on the lists representing their voting records, and then divide the sum by the number of vectors. The result should be a vector.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
