Professional Integrity and Ethics Questions
How the candidate demonstrates honesty, ethical judgment, and integrity in their work and decisions. Covers acting with candor when it is costly, making principled decisions in ethically gray situations, owning mistakes truthfully, and upholding professional and interview integrity. Distinct from self-awareness: this is about values and ethical conduct rather than calibrated self-knowledge.
Design an audit logging and provenance system to track datasets, transformation steps, model training hyperparameters, model versions, and per-decision metadata for compliance and investigations. Assume 100M users and hundreds of models; describe storage choices, indexing/query patterns, retention policies, privacy protections, and how auditors would query the system.
Sample Answer
Requirements (clarify): immutably record dataset versions, transformation steps, model training hyperparameters & versions, and per-decision metadata for 100M users and hundreds of models. Support fast auditor queries for investigations and compliance; enforce privacy, retention and access controls.
High-level architecture:
- Append-only event stream (Kafka) for real-time ingestion of provenance events (dataset ingest, transformation run, model train start/finish, prediction decision).
- Long-term object store (S3 with versioning & object lock) to persist raw artifacts (datasets, model binaries, logs) referenced by event IDs.
- Metadata & indices: primary metadata store in a strongly consistent DB (Postgres or DynamoDB) for transactional metadata (version ids, hashes, timestamps, actor). A graph DB (Amazon Neptune / Neo4j) for lineage relationships (dataset -> transform -> model -> decision).
- Search index (Elasticsearch / OpenSearch) for full-text and ad-hoc querying (e.g., find all decisions affecting user X in date range).
- Audit UI + query layer: REST API that composes results from metadata DB, graph DB, and search.
Storage choices & rationale:
- Kafka: durable ingestion, replay for reprocessing.
- S3: cheap, durable, supports immutability and legal hold.
- Postgres/DynamoDB: low-latency point lookups and ACID for metadata.
- Graph DB: natural fit for lineage traversal queries.
- Elasticsearch: supports faceted search, aggregations for auditors.
Indexing & query patterns:
- Write each event with keys: event_id, type, timestamp, actor, artifact_id, dataset_version, model_version, user_id_hash, pointers to S3, parent_ids.
- Partition indices by time + tenant (month + model) to support range scans.
- Precompute and cache common joins: model_version -> training hyperparams, dataset_version -> checksum, decision -> model_version.
- Lineage/traversal queries use graph DB (e.g., find all data sources influencing model V).
- Ad-hoc and per-decision queries use Elastic + metadata DB (e.g., all decisions for user U between dates -> fetch decision events, then join to model_version and hyperparams).
Retention and compliance:
- Retention tiers:
- Short-term (0–1 year): full detail in hot stores (ES, Postgres).
- Mid-term (1–7 years): metadata + pointers in cold store; raw artifacts archived in S3 Glacier Deep Archive.
- Legal hold: mark object lock on S3 to prevent deletion.
- Automatic roll-up: after policy age, collapse per-decision raw logs into summarized records (counts, aggregates) if allowed.
- Retention policies enforced by lifecycle jobs and IAM guards.
Privacy & protections:
- PII minimization at ingestion: store user identifiers as salted cryptographic hashes; keep reversible mapping in restricted KMS-protected vault only for legal-approved investigators.
- Encrypt data at rest (SSE-S3 or KMS) and in transit (TLS).
- Differential privacy / noise injection for aggregate reporting endpoints.
- Role-based access control + attribute-based policies (RBAC/ABAC) for auditors vs developers; all accesses logged to immutable audit trail.
- Field-level masking and query-time filtering for sensitive fields; ephemeral decryption keys for approved sessions.
How auditors query:
- Use an auditor UI or CLI that authenticates via strong MFA and uses scoped temporary credentials.
- Examples:
- "Give me all decisions affecting user H from 2025-01-01 to 2025-02-01": Query ES for decision events by user_hash and time, return decision ids -> metadata DB join to model_version -> fetch hyperparams and model artifact S3 pointers; show lineage via graph DB to datasets.
- "Show provenance for model v12": Graph DB traversal: model v12 -> training run -> dataset_version(s) -> transformation steps; return artifact checksums and S3 URIs.
- "List changes to training hyperparameters for models owned by team X": SQL on metadata DB with time + team filter, plus diffs between hyperparam blobs.
Scalability & perf considerations:
- Shard Kafka topics by model/tenant; use compaction for latest state topics (e.g., model current version).
- Postgres for transactional metadata can be scaled via read replicas; heavy-scale use DynamoDB with GSIs (partition by model_id, sort by timestamp).
- Graph DB sizing: keep only lineage edges/ids; heavy artifacts stay in S3 to limit graph size.
- Bulk indexes and streaming ETL (Kafka Connect) to ES and graph DB; backpressure & throttling for bursts.
- Sampling + summarization for extremely high-volume per-decision logs; allow full retention only when mandated.
Trade-offs:
- Keeping full per-decision raw payloads is expensive; prefer hashed/pointered approach and legal hold for full retention.
- Graph DB gives expressive lineage queries but adds operational complexity; acceptable because provenance queries are central.
This design provides an immutable, queryable provenance trail linking datasets, transforms, training hyperparameters, model versions and per-decision metadata while balancing cost, scalability, privacy and auditability.
An A/B test shows an overall lift in conversions but disproportionately reduces conversions for a marginalized segment. As the data scientist, describe the analyses you would run to confirm that effect (causal checks, segmentation, confounder control), how you'd quantify harm, and what recommendations you would present to product and leadership.
Sample Answer
Framework / approach:
- Clarify definitions: identify the marginalized segment (demographics/behavior), primary conversion metric, and business & ethical stakes.
- Goal: validate the subgroup harm is real and causal, quantify its magnitude, and recommend mitigation.
Analyses to confirm effect
- Randomization & balance checks
- Verify random assignment within subgroup (treatment/control proportions, baseline covariates). Test with chi-square / standardized mean differences.
- Causal checks
- Intention-to-treat vs. per-protocol; check SUTVA violations.
- Run adjusted regression: outcome ~ treatment + subgroup + treatment*subgroup + covariates to estimate interaction (heterogeneous treatment effect).
- Use doubly robust methods (IPW + outcome regression) and causal forest / uplift models to estimate individual treatment effects and confidence intervals.
- Confounder control / sensitivity
- Include known confounders (device, region, prior behavior). Do placebo outcomes and pre-period trends tests.
- Conduct robustness: trimming, propensity-score matching, and an E-value / Rosenbaum sensitivity analysis for unobserved confounding.
- Segmentation & heterogeneity
- Break down by intersecting attributes (age x income x region). Visualize CATE distribution and bootstrap CIs.
How to quantify harm
- Report absolute and relative change in conversion for subgroup (Δ conversion % and conversion rate ratio), and number of conversions lost = Δ% * subgroup population.
- Equity metrics: disparate impact ratio (subgroup lift / overall lift), proportion of negative ITEs in subgroup.
- Business/ethical impact: revenue loss, conversion-days delayed, and exposure count (users affected).
- Uncertainty: present CIs and p-values; emphasize practical significance (min detectable effect).
Recommendations to product & leadership
- Short term: pause or roll back treatment for the affected subgroup or enable targeted opt-out until resolved.
- Modify: redesign the variant to address subgroup-specific issues (UX, language, accessibility) and run follow-up experiments focused on the subgroup (stratified or blocked randomization).
- Monitoring: add real-time cohort-level dashboards, alerting on subgroup metrics, and include fairness-safety gate in experimentation pipeline.
- Governance: present clear summary (what we tested, evidence, magnitude, uncertainty), propose remediation plan and timeline, involve legal/ethics/UX teams, and schedule a re-test with preregistered hypotheses.
- Long term: incorporate subgroup-aware experimentation (power calculations for subgroups), continuous A/B safety checks, and document lessons for inclusive product design.
This combination demonstrates causality, quantifies the harm with uncertainty, and gives concrete, risk-managed next steps.
Ethics/Case: A revenue-focused stakeholder presses you to produce a model that would likely increase short-term revenue but systemically disadvantage a vulnerable customer group. Describe step-by-step how you would respond, escalate, propose alternatives, and protect both the product and your professional ethics while remaining aligned with long-term company interests.
Sample Answer
Situation: A revenue stakeholder asks me to deploy a model that boosts short-term revenue but will likely harm a vulnerable customer group (e.g., higher prices or redlining).
Step-by-step response:
- Rapid fact-finding (I): Stop the deployment timeline briefly. Request the exact objective, data used, and the proposed decision rule. Quantify the harm and who’s affected.
- Measurement & analysis (I): Run fairness and impact analyses—disparate impact ratios, group calibration, uplift by segment, and counterfactual simulations. Produce clear visuals and a one-page executive summary with numbers (revenue uplift vs. affected population, projected churn, regulatory risk).
- Propose alternatives (I):
- Constrain the objective with fairness-aware methods (e.g., reweighting, demographic parity / equalized odds constraints, or cost-sensitive regularization).
- Use a hybrid policy: revenue-optimized model plus rule-based safeguards for vulnerable groups.
- Pilot with guardrails: A/B test with limits, manual reviews, and close monitoring.
- Offer mitigations: targeted discounts, hardship flags, or financial literacy interventions.
- Risk framing (I): Present long-term trade-offs—brand/reputation damage, regulatory fines, lifetime value loss, and employee morale. Use scenario analysis (best/worst case).
- Escalation (I -> Team/Org): If stakeholder insists, escalate:
- First to my manager and product lead with documentation.
- Then to Legal/Compliance and Ethics or Risk Committee.
- If cultural or legal breach persists, escalate to senior leadership or use formal channels (whistleblower or compliance hotline).
- Protecting product & myself (I): Keep written records (emails, presentations), log model versions and experiments in repo/MLflow, require approvals, and refuse to deploy if it violates company policy or law.
- Monitoring & remediation (I): If a constrained approach is approved, deploy with post-launch monitoring, automated alerts for fairness drift, and a rollback plan.
Why this preserves long-term interests: it balances revenue with trust and regulatory exposure, reduces churn and reputational risk, and creates defensible decisions backed by data and governance—protecting customers, the product, and my professional ethics.
List the most common sources of bias in training datasets (for example: sampling bias, label bias, survivorship bias, measurement error). For each source give one concrete method you would use to detect it during exploratory data analysis and one simple mitigation you might try.
Sample Answer
Sampling bias
- Detect: Compare feature distributions vs known population baselines (histograms, KDEs, demographic pivot tables). In pandas: df.groupby('region').size()/len(df) vs census proportions.
- Mitigation: Reweight or stratified resampling during training (inverse-propensity weights) or collect additional data from underrepresented strata.
Label bias (systematic/annotator bias)
- Detect: Measure inter-annotator agreement (Cohen’s kappa), confusion matrix vs trusted gold labels, or inspect label distribution by annotator/time/source.
- Mitigation: Relabel a stratified sample with expert annotators, then use label correction (probabilistic labels) or train with noise-robust loss.
Survivorship bias
- Detect: Check for missing cohorts over time (e.g., only active users present). Compare historical snapshots; plot dropout rates by cohort.
- Mitigation: Reconstruct censored records if possible, use survival analysis techniques or restrict analysis to cohorts with full observation windows.
Measurement error / sensor noise
- Detect: Identify implausible values/outliers, inconsistent duplicates, high variance across repeated measures; plot time series residuals.
- Mitigation: Apply smoothing, calibration using reference measurements, or model measurement noise explicitly (errors-in-variables).
Class imbalance (performance bias)
- Detect: Check label class frequencies and per-class metrics (precision/recall) via cross-validation.
- Mitigation: Use stratified sampling, class-weighted loss, or generate synthetic minority examples (SMOTE) carefully.
Confounding / omitted variable bias
- Detect: Correlation/partial-correlation matrices, causal graphs, and check performance shifts when conditioning on candidate confounders.
- Mitigation: Include confounders in models, use propensity-score matching or instrumental variables.
Reporting / selection bias (self-selection)
- Detect: Compare responders vs non-responders on observable features; test for systematic differences.
- Mitigation: Propensity-score weighting or design targeted data collection to reduce self-selection.
These EDA checks (distributions, cohort plots, agreement stats, correlation matrices) plus simple mitigations (reweighting, relabeling, collecting additional data) are practical first steps to reduce bias before modeling.
You need to reduce disparate impact for a target outcome but are not permitted to use the protected attribute directly in training. Outline algorithmic and non-algorithmic approaches you would explore (for example proxy-aware adjustments, fairness-constrained post-processing, targeted data collection, or policy changes), discuss pros/cons, and describe validation strategies.
Sample Answer
Approach overview: since the protected attribute (A) cannot be used, combine proxy-aware algorithmic methods, targeted data actions, and organizational/policy changes. For each I list what I’d try, pros/cons, and how I’d validate.
Algorithmic options
- Proxy-aware adjustments (use proxies Z correlated with A, e.g., ZIP+occup): build models that explicitly model P(A|Z) and adjust predictions via reweighting or thresholding.
- Pros: uses available signal to reduce disparity; interpretable adjustments.
- Cons: risk of proxy leakage, legal/privacy concerns, imperfect proxies introduce noise.
- Pre-processing: reweighing / optimal transport / synthetic balancing (generate balanced training distribution).
- Pros: model-agnostic, simple to implement.
- Cons: may distort joint distribution, hurt overall accuracy.
- In-processing fairness constraints: add constraints or regularizers (e.g., demographic parity gap, equalized odds or group-specific loss penalties) to training objective without using A directly by using proxy-estimates P(A|Z).
- Pros: principled trade-off control.
- Cons: requires careful tuning; optimization may be harder.
- Adversarial debiasing using proxy labels: train predictor while adversary predicts proxy-estimated A; minimize predictor utility and adversary performance.
- Pros: can remove information useful for predicting protected class.
- Cons: unstable training; may remove useful signal for legitimacy.
- Post-processing: fairness-constrained calibration (e.g., reject-option, group-specific thresholds determined via proxy-based grouping).
- Pros: no retraining; easy to deploy.
- Cons: relies on proxy grouping; can be seen as disparate treatment if misapplied.
Non-algorithmic / operational options
- Targeted data collection: collect richer features or voluntary self-identified A (with consent) to accurately measure disparity and improve fairness interventions.
- Pros: better measurement; reduces reliance on proxies.
- Cons: privacy/regulatory hurdles; response bias.
- Policy/process changes: redesign decision rules to reduce reliance on model outputs (human-in-loop, constraints on automated denials), introduce appeal processes, or change business rules that disproportionately affect groups.
- Pros: immediate, transparent, aligns with legal/regulatory goals.
- Cons: may increase operational cost; slower to scale.
- Outcome remediation: offer alternative interventions to groups showing higher negative outcomes (e.g., targeted support programs).
- Pros: directly reduces harm.
- Cons: resource intensive; requires careful targeting to avoid stigma.
Trade-offs and practical concerns
- Accuracy vs fairness: many methods trade some predictive performance for lower disparity. Quantify acceptable trade-off with stakeholders.
- Proxy risks: proxies may imperfectly capture A and create residual unfairness or legal exposure.
- Privacy & consent: collecting A requires clear consent and secure handling.
- Legal/regulatory: some jurisdictions forbid proxy use; coordinate with legal/compliance.
Validation strategies
- Metrics: track multiple fairness metrics—demographic parity difference/ratio, equalized odds (TPR/FPR gaps), calibration within groups, and subgroup utility metrics. Report confidence intervals via bootstrap.
- Proxy robustness: evaluate fairness using multiple proxy definitions and sensitivity analysis for P(A|Z) estimation error.
- Holdout and cross-validation: compute metrics on a reserved test set and on temporal and geographic slices to detect distributional shifts.
- Counterfactual / causal checks: where feasible, run causal analyses (e.g., matching, uplift) to ensure observed disparities aren’t due to legitimate covariates.
- Human review & A/B tests: small-scale randomized trials or shadow deployments comparing baseline vs mitigation, measuring business and fairness outcomes plus user experience.
- Monitoring: set production alerts for metric drift (accuracy and fairness gaps), log decisions for audits, and periodically retrain with updated data.
- Stakeholder validation: legal, product, and affected-community reviews; perform blameless postmortems after issues.
Concrete example (brief): estimate P(A|Z) with a calibrated classifier on historical voluntary A; use reweighing in training to equalize expected positive rates, then post-process thresholds per proxy-group and validate via held-out bootstrapped TPR/FPR gaps and an A/B test measuring downstream business KPIs and complaint rates.
Final note: combine methods—start with policy/process changes and targeted data collection for measurement, then apply conservative algorithmic adjustments with robust validation and ongoing monitoring.
Unlock Full Question Bank
Get access to all 47 Professional Integrity and Ethics interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.