0
0
MLOpsdevops~10 mins

Bias detection and fairness metrics in MLOps - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate demographic parity difference using the AIF360 library.

MLOps
from aif360.metrics import BinaryLabelDatasetMetric
metric = BinaryLabelDatasetMetric(dataset, privileged_groups=[1], unprivileged_groups=unprivileged_groups)
Drag options to blanks, or click blank then click option'
A[{'sex': 1}]
B[{'race': 0}]
C[{'race': 1}]
D[{'sex': 0}]
Attempts:
3 left
💡 Hint
Common Mistakes
Using unprivileged group as privileged
Confusing attribute names
Using incorrect list format
2fill in blank
medium

Complete the code to compute equal opportunity difference metric.

MLOps
equal_opportunity_diff = metric.[1]()
Drag options to blanks, or click blank then click option'
Aequal_opportunity_difference
Bstatistical_parity_difference
Cdisparate_impact
Daverage_odds_difference
Attempts:
3 left
💡 Hint
Common Mistakes
Using statistical parity difference instead
Confusing average odds with equal opportunity
3fill in blank
hard

Fix the error in the code to calculate disparate impact.

MLOps
disparate_impact = metric.[1]()
Drag options to blanks, or click blank then click option'
AdisparateImpact
Bdisparate_impact
Cdisparate_impact_score
DdisparateImpactScore
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase method names
Adding extra suffixes to method names
4fill in blank
hard

Fill both blanks to create a fairness metric object for unprivileged and privileged groups.

MLOps
metric = BinaryLabelDatasetMetric(dataset, privileged_groups=[1], unprivileged_groups=[2])
Drag options to blanks, or click blank then click option'
A[{'gender': 1}]
B[{'gender': 0}]
C[{'age': 1}]
D[{'age': 0}]
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping privileged and unprivileged groups
Using wrong attribute names
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters dataset features by threshold.

MLOps
filtered_features = {feature: value for feature, value in dataset.features.items() if value [1] threshold and feature [2] 'age' and value [3] 0}
Drag options to blanks, or click blank then click option'
A>
B!=
C>=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators
Including 'age' feature by mistake