Question: Python3 Files can be found here https://github.com/franzip/coursera/tree/master/coding-the-matrix/week3 Dot products via matrix-matrix multiplication Problem 4.17.19: Let A be a matrix whose column labels are countries and

Python3

Python3 Files can be found here https://github.com/franzip/coursera/tree/master/coding-the-matrix/week3 Dot products via matrix-matrix multiplication

Files can be found here

https://github.com/franzip/coursera/tree/master/coding-the-matrix/week3

Dot products via matrix-matrix multiplication Problem 4.17.19: Let A be a matrix whose column labels are countries and whose row labels are votes taken in the United Nations (UN), where Ali,j]is +1 or -1 or 0 depending on whether country j votes in favor of or against or neither in vote i. As in the politics lab, we can compare countries by comparing their voting records. Let M ATA. Then M's row and column labels are countries, and Mi, j] is the dot-product of country i's voting record with country j's voting record. The provided file UN.voting-data.txt has one line per country. The line consists of the country name, followed by +1's, -1's, and zeroes, separated by spaces. Read in the data and form the matrix A. Then form the matrix MATA. (Note: this will take quite a while-from fifteen minutes to an hour, depending on your computer.) Use M to answer the following questions. 1. Which pair of countries are most opposed? (They have the most negative dot-product.) 2. What are the ten most opposed pairs of countries? . Which pair of distinct countries are in the greatest agreement (have the most positive dot-product)? Hint: the items in M.f are key-value pairs where the value is the dot-product. You can use a comprehension to obtain a list of value-key pairs, and then sort by the value, using the expression sorted C[(value,key) for key,value in M.f.items O1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!