feat: Add per-segment drift notebooks (classifier score + MIME type)#21
Merged
Conversation
Adds `notebooks/compare_classifier_scores_segment_drift.ipynb`, a sibling to the existing baseline-vs-focus comparison notebook. Loads the per-segment `classify-warc` output CSVs for `CC-SUPPLEMENTAL-2026-22`, parses the `YYYYMMDDHHMMSS` token from each filename, and plots how the classifier score evolves over the lifetime of the focus crawl: - mean ± SEM (sized so real mean shifts are distinguishable from sampling noise; raw stdev is uninformative for the bimodal score distribution), - median with IQR (p25-p75) and outer (p10-p90) percentile bands, - high-confidence rate (P(score >= 0.5) and P(score >= 0.9)), - mean and median on shared axes as a consolidated view. Auto-discovers segment files and drops under-sized segments (n < 1000) from the plots while keeping them in the per-segment table for auditability.
Adds notebooks/compare_mime_type_drift.ipynb, a sibling to the classifier score drift notebook. Parses CDX index files (*.cdx.gz) for the focus crawl segments, caches (warc_filename, offset, mime_detected) per CDX file under data/cache/ (mirroring the source layout, gitignored), and visualises composition drift with four bar plots: absolute counts, absolute counts excluding text/html, total records per segment, and normalized share. MIME values come from CDX mime-detected (content sniffed), with the long tail bucketed into "other" via a global top-N ranking so the legend stays stable across segments.
Collaborator
|
@malteos This notebook is run based on the WARC classifier output, right? could you provide the input data somewhere so that I can try to run it locally for testing? |
Collaborator
Author
|
The files are in our internal S3 bucket. I will update the notebooks as soon as the file are moved to the public bucket. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two sibling notebooks under
notebooks/that surface per-segment drift in the focus crawlCC-SUPPLEMENTAL-2026-22. Both auto-discover the 14-digitYYYYMMDDHHMMSSsegment token from filenames / directory names, sort oldest-left, and drop probe / aborted segments via aMIN_RECORDSfloor.compare_classifier_scores_segment_drift.ipynbLoads the per-segment
classify-warcoutput CSVs and plots how the classifier score evolves over the lifetime of the focus crawl:MIN_RECORDS = 1000(drops the early probe segment with n < 1000 from plots while keeping it in the per-segment table for auditability).compare_mime_type_drift.ipynbParses the CDX index files (
*.cdx.gz) for each segment undercc-focus-tools/data/CC-SUPPLEMENTAL-2026-22/segments/*/cdx/warc/. To avoid re-parsing ~44M JSON records on every notebook run, the first execution materialises a per-CDX cache of(warc_filename, offset, mime_detected)triples underdata/cache/CC-SUPPLEMENTAL-2026-22/segments/...(mirrors the source layout, gitignored via the existingdata/rule). Subsequent runs hit the cache in seconds.MIME source is the CDX
mime-detectedfield (content-sniffed, more comparable across origins than the rawContent-Typeheader), lower-cased and stripped of parameters. The long tail (~360 minor MIME types) is bucketed into"other"via a global top-N ranking so the legend stays stable across segments.Plots:
text/htmlexcluded so the long tail (application/pdf,application/xhtml+xml,text/plain, ...) becomes readable on a linear y-axis.MIN_RECORDS = 100_000(CDX records vastly outnumber score records, so the floor is higher than in the sibling notebook).