Question: This assignment needs the file karate _ club _ interactions.txt on the D 2 L . Load this file into a Python variable through command

This assignment needs the file karate_club_interactions.txt on the D2L.
Load this file into a Python variable through command np.loadtxt seen in class. This will result in a binary-valued Numpy 2D array, which shows the interactions among members of a Karate club, such that if the (i,j)-th element of the 2D array is one, the the i-th and j-th members had an interaction (e.g., a fight), otherwise they did not. Note that such relationship is symmetric (the fact that the i-th member had an interaction with the j-th member readily implies that the j-th member also had an interaction with the i-th member). Verify this symmetry by means of Numpy tools (i.e., its transpose is the same as itself).
Write a function that takes an interaction matrix, extracts some information from it and prints them out. The function should first verifies symmetry of the input 2D array, and then answer the following questions. Note that the analysis should be fully based on Numpy methods and functions; no point will be given if a question is answered by any other means.
How many members did the Karate club have?
Print how many interactions each member of the club had. Interactions of the i-th member could be retrieved by means of either the i-th row or the i-th column of the loaded array. Either way would be fine for the purpose of this assignment.
What are indices of the least and most active members of the club? Did they have any interaction with them?
What is the average and STD of the number of interactions across all the members?
Text file data format:
0.000000000000000000e+001.000000000000000000e+001.000000000000000000e+000.000000000000000000e+000.000000000000000000e+000.000000000000000000e+001.000000000000000000e+001.000000000000000000e+001.000000000000000000e+000.000000000000000000e+00
1.000000000000000000e+000.000000000000000000e+001.000000000000000000e+000.000000000000000000e+000.000000000000000000e+000.000000000000000000e+001.000000000000000000e+000.000000000000000000e+000.000000000000000000e+000.000000000000000000e+00

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!