Repository challenges
Stop fitting preprocessing on evaluation data
Debugging · Intermediate · Data analytics · 35 minutes
Engineering ticket
Implement apply(values, training_mean) in preprocessing.py. Replace only None values with the supplied mean fitted on training data. Keep zero and other numeric values unchanged. Never compute a new mean from these evaluation rows. Return a new list without mutating values. pipeline.transform(values, training_mean) must delegate to this function. Explain the leakage risk in NOTES.md.
Review rubric
- Correctness on documented inputs
- Tests and edge cases
- Clear explanation of trade-offs
Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.
Starter repository
NOTES.md
# Explain why training statistics must stay fixed
README.md
# InferenceAI engineering lab Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
pipeline.py
from preprocessing import apply
def transform(values, training_mean):
return apply(values, training_mean)
preprocessing.py
def apply(values, training_mean):
known = [v for v in values if v is not None]
mean = sum(known)/len(known) if known else 0
return [mean if v is None else v for v in values]
tests/test_pipeline.py
import unittest
from pipeline import *
class ContractTest(unittest.TestCase):
def test_example(self):
self.assertEqual(transform([None, 100, 0], 5), [5,100,0])