Domain adaptation evaluation
Quick answer
Domain adaptation addresses differences between source and target data distributions. Evaluate whether a transferred representation actually helps on the intended target domain, not just on familiar validation examples. Examples are static Python snippets tested locally on CPU; PyTorch is required for selected examples. ByteMind execution is unverified.
Domain accuracy gap
source=[1,1,1,0]; target=[1,0,0,1]print(sum(source)/len(source),sum(target)/len(target),sum(source)/len(source)-sum(target)/len(target))Expected output (locally tested): 0.75 0.5 0.25. The gap is 25 percentage points, not a relative percentage change.
How it works
Let source and target have different joint distributions P_s(X,Y) and P_t(X,Y). Covariate shift changes P(X) under a stable conditional P(Y|X); label shift changes P(Y) under a stable class-conditional P(X|Y); conditional shift can change P(Y|X). Real shifts can combine these. Domain generalization leaves the target domain unseen during fitting; supervised adaptation uses labeled target training examples, and unsupervised adaptation may use unlabeled target training data. Define which is allowed before evaluation. Compare random frozen features and source-trained frozen features at equal representation width, head initialization, target examples and target update count; extra source compute must be reported. Choose configuration on target validation, then inspect held-out domain results once without retuning. Report per-domain metrics, counts and a gap, not only pooled accuracy. Audit source data, model version, hashes, license and training/test contamination. A local synthetic source model avoids third-party weight licensing but does not remove the need for release review. Never run arbitrary model repository code or untrusted checkpoints. Negative transfer is possible when source structure is irrelevant or conflicts with target labels.
Partition ID audit
parts={"source":{"s1","s2"},"target_train":{"t1"},"target_test":{"t2","t3"}}from itertools import combinationsprint(all(not a&b for a,b in combinations(parts.values(),2)))Expected output (locally tested): True. ID isolation is necessary but not sufficient; also check content duplicates and related groups.
Common mistakes
Do not call a target test domain unseen if its labels or examples informed fitting. Do not infer causal invariance from one successful synthetic comparison or mistake a checksum for permission to redistribute.
Practice and next steps
Compute the accuracy gap for source 9/10 and target 6/10, then list the dataset and weight provenance fields needed for independent review.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Domain adaptation evaluation — knowledge check
Apply domain adaptation evaluation to small examples and debugging scenarios.
What is negative transfer?
Which target data may guide head selection?
What does a weight checksum establish?
What is covariate shift under its standard assumption?
Why report extra source training cost?