CommencerCommencer gratuitement

Effect size for categorical variables

You saw in the City of Austin employee data that job titles have an unequal distribution of genders. But does the same thing hold for ethnicities? And to what extent does ethnicity relate to the job title chosen? In this exercise you'll dig in and answer that question.

A DataFrame of comparing job titles and ethnicities (employees_df) has been loaded for you, as have the packages pandas as pd, NumPy as np, and stats from SciPy.

Cet exercice fait partie du cours

Foundations of Inference in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Compute the chi-squared statistic
chi2, p, d, expected = stats.____(____)

# Compute the DOF using the number of rows and columns
dof = min(____.shape[0] - 1, ____.shape[1] - 1)

# Compute the total number of people
n = np.sum(____.values)

# Compute Cramer's V
v = np.____((____ / ____) / ____)

print("Cramer's V:", v, "\nDegrees of freedom:", dof)
Modifier et exécuter le code