PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Freddie Mac

Implement blocked time-series cross-validation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competence in designing panel-aware time-series cross-validation with embargo handling, grouped blocking, deterministic splitting, scalability analysis, and adversarial unit-test design for issues like duplicate timestamps and entity migration.

  • Medium
  • Freddie Mac
  • Coding & Algorithms
  • Data Scientist

Implement blocked time-series cross-validation

Company: Freddie Mac

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Implement a panel-aware blocked time-series cross-validation splitter with an embargo. Input: DataFrame columns [loan_id, msa, month]. Requirements: (1) K=5 expanding-window folds with cutoffs t1<...<t5; for fold k, train on months <= tk−embargo and test on (tk−embargo, tk+1]; embargo = 90 days prevents any loan_id from appearing in both sets within the window. (2) Support grouped blocking so that in at least one fold, an entire MSA's months are held out as test while preserving temporal order within each MSA. (3) Ensure determinism and stability under shuffled input. (4) Output precise algorithm steps or pseudocode plus time complexity in N rows, G MSAs, and K folds; discuss memory characteristics. (5) Describe unit tests for adversarial cases: duplicate timestamps, missing months, loan migration across MSAs, and highly imbalanced MSAs.

Quick Answer: This question evaluates competence in designing panel-aware time-series cross-validation with embargo handling, grouped blocking, deterministic splitting, scalability analysis, and adversarial unit-test design for issues like duplicate timestamps and entity migration.

Freddie Mac logo
Freddie Mac
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Coding & Algorithms
7
0

Implement a panel-aware blocked time-series cross-validation splitter with an embargo. Input: DataFrame columns [loan_id, msa, month]. Requirements: (1) K=5 expanding-window folds with cutoffs t1<...<t5; for fold k, train on months <= tk−embargo and test on (tk−embargo, tk+1]; embargo = 90 days prevents any loan_id from appearing in both sets within the window. (2) Support grouped blocking so that in at least one fold, an entire MSA's months are held out as test while preserving temporal order within each MSA. (3) Ensure determinism and stability under shuffled input. (4) Output precise algorithm steps or pseudocode plus time complexity in N rows, G MSAs, and K folds; discuss memory characteristics. (5) Describe unit tests for adversarial cases: duplicate timestamps, missing months, loan migration across MSAs, and highly imbalanced MSAs.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Freddie Mac•More Data Scientist•Freddie Mac Data Scientist•Freddie Mac Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.