. Print color_homophily. Here's the code to get you started: from collections import Counter import numpy as np def marginal prob(chars): Enter code here! def chance homophily(chars): Enter code here! favorite colors= ( "ankit": "red", "xiaoyu": "blue", "mary's "blue" color_homophily chance homophily (favorite colors) print (color_homophily) What is the chance homophily of the favorite colors dictionary?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
• Print color_homophily.
Here's the code to get you started:
from collections import Counter
import numpy as np
def marginal prob(chara):
Enter code here!
def chance homophily(chars):
* Enter code here!
favorite colors = {
"ankit": "red",
"xiaoyu": "blue",
"mary" i
"blue"
>
color_homophily chance homophily favorite colors)
print (color_homophily)
What is the chance homophily of the favorite colors dictionary?
Submit You have used 0 of 10 attempts
Save
Hi
Transcribed Image Text:• Print color_homophily. Here's the code to get you started: from collections import Counter import numpy as np def marginal prob(chara): Enter code here! def chance homophily(chars): * Enter code here! favorite colors = { "ankit": "red", "xiaoyu": "blue", "mary" i "blue" > color_homophily chance homophily favorite colors) print (color_homophily) What is the chance homophily of the favorite colors dictionary? Submit You have used 0 of 10 attempts Save Hi
Homework due Sep 15, 2022 03:59 +04
Exercise 1
In Exercise 1, we will calculate the chance homophily for an arbitrary characteristic. Homophily is the
proportion of edges in the network whose constituent nodes share that characteristic.
How much homophily do we expect by chance? If characteristics are distributed completely randomly, the
probability that two nodes and y share characteristic a is the probability both nodes have characteristica.
which is the marginal probability of a squared. The total probability that nodes x and y share their
characteristic is therefore the sum of the square of the marginal probabilities of each characteristic in the
network.
Instructions
• Create a function marginal_prob that takes a dictionary chars with personal IDs as keys and
characteristics as values; it should return a dictionary with characteristics as keys and their marginal
probability (frequency of occurence of a characteristic divided by the sum of frequencies of each
characteristic) as values.
• Create a function chance_homophily(chars) that takes a dictionary chars defined as above and
computes the chance homophily (homophily due to chance alone) for that characteristic.
• A sample of three peoples' favorite colors is given in favorite colors. Use your function to compute the
chance homophily in this group, and store it as color_homophily.
• Print color_homophily.
Here's the code to get you started:
rece
Transcribed Image Text:Homework due Sep 15, 2022 03:59 +04 Exercise 1 In Exercise 1, we will calculate the chance homophily for an arbitrary characteristic. Homophily is the proportion of edges in the network whose constituent nodes share that characteristic. How much homophily do we expect by chance? If characteristics are distributed completely randomly, the probability that two nodes and y share characteristic a is the probability both nodes have characteristica. which is the marginal probability of a squared. The total probability that nodes x and y share their characteristic is therefore the sum of the square of the marginal probabilities of each characteristic in the network. Instructions • Create a function marginal_prob that takes a dictionary chars with personal IDs as keys and characteristics as values; it should return a dictionary with characteristics as keys and their marginal probability (frequency of occurence of a characteristic divided by the sum of frequencies of each characteristic) as values. • Create a function chance_homophily(chars) that takes a dictionary chars defined as above and computes the chance homophily (homophily due to chance alone) for that characteristic. • A sample of three peoples' favorite colors is given in favorite colors. Use your function to compute the chance homophily in this group, and store it as color_homophily. • Print color_homophily. Here's the code to get you started: rece
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY