Bot or Not

Period
2026
Contribution
Solo feature extraction, model selection and reporting
Status
Public source and saved competition run

I built a Python pipeline that classifies English- and French-language social-media accounts as bots or humans from their profiles and posting histories. It compares text-based and behavioural models and selects a separate model and decision threshold for each language.

The classification task and my contribution

The McGill Bot or Not challenge asks participants to identify bot accounts from supplied social-media datasets without wrongly flagging human accounts. Each account has a profile and a timeline of timestamped posts; the target is the account, not whether an individual post sounds machine-generated. The output is a file of account IDs flagged as bots.

This was a solo implementation. I built the feature extraction, model comparison, threshold selection, reporting and prediction commands. English and French have separate fitted models and thresholds. The bilingual command coordinates their runs and collects their artifacts; it does not train a multilingual model.

Combining account and text features

I represented each account through both numerical summaries and its post text:

  • Profile and activity: post count, the supplied activity z-score, profile-field lengths, and flags for empty descriptions or locations.
  • Posting behaviour: duplicate-post ratio, average URL and mention counts, variation in post lengths, intervals between posts, and posting-hour entropy—a measure of how spread out the account's activity is across the day.
  • Text: posts joined into one document per account, then represented with TF-IDF. Sequences that recur within an account but are less common across training accounts receive more weight.

The comparison asks whether numerical behaviour summaries are enough, or whether text patterns add a useful signal. Character sequences capture recurring fragments without requiring whole-word matches; word sequences preserve phrases. These are representation choices, not a claim that every feature improves performance.

The five model configurations make those alternatives explicit:

  • Logistic regression joins character 3–5-gram TF-IDF with scaled numerical account features in one feature vector.
  • Hybrid text combines word 1–2-gram and character 3–5-gram TF-IDF, each compressed with truncated SVD into a smaller dense vector, with an extended set of scaled account features. A calibrated logistic regression uses that combined vector. These are fitted TF-IDF/SVD representations, not pretrained language-model embeddings.
  • Histogram gradient boosting uses the base numerical features to model nonlinear combinations of account behaviour.
  • ExtraTrees uses extended numerical features, including vocabulary diversity, punctuation ratios, retweet share and burst-versus-gap timing statistics.
  • The ensemble blends the calibrated bot probabilities from histogram gradient boosting and ExtraTrees. Its component weights are selected using out-of-fold predictions, allowing the comparison to test a blend of the two tree approaches.

The saved April run selected the tree ensemble for both languages.

Selecting models and thresholds

An official shard is one supplied, labelled dataset: account profiles and post timelines associated with a collection window and topics. The official-first workflow uses English shards 1, 3 and 5, and French shards 2, 4 and 6. It validates on one whole shard at a time while fitting on the other two. This preserves collection boundaries during selection rather than mixing accounts from every collection into each fold. The aim is to favour models that work across collections, not just within one.

Selection follows the challenge's utility score, 2TP − 6FP − 2FN, rather than maximising F1. A false accusation against a human costs three times the penalty for missing a bot. Each candidate's out-of-fold probabilities are used to choose a threshold; the candidate with the highest utility wins, with fewer false positives preferred in a tie. Thresholds are selected separately for English and French so each language's validation predictions determine its own operating point rather than assuming a shared probability scale or cutoff.

These out-of-fold predictions are selection data, not an independent final test. Model choice, ensemble weights and thresholds all use them. After selection, the estimator is refit on the combined official training data for its language. The workflow records configurations, selection reports, model bundles and prediction artifacts. These make the choices inspectable and support future reproduction; they do not establish that the historical numbers have been reproduced.

Official shards feed grouped validation, which selects a model and threshold. The model refits on official data; overlapping practice results remain separate from independent evaluation.
The saved official-first workflow separates model selection from practice reporting. A separate practice filename does not guarantee independent content.

Training-command differences

The lower-level training command can reserve a stratified primary holdout before model and threshold selection. The saved official-first run instead uses whole official shards for selection and has no additional primary holdout (selected_holdout is null). The pinned modeling tests check that reserved holdout accounts stay out of selection-time fitting and that predefined official fold IDs are respected. Those tests verify split behaviour, not numerical reproduction of the saved scores.

Finding overlap in practice data

The checked-in practice datasets contain extensive content overlap with official training inputs, so the saved practice scores cannot serve as evidence of generalisation to unseen content. A different filename or account ID is not enough to establish independence.

The table pairs historical results from 20260404T162558Z-both-official-first-optimize with an October 2026 audit of the checked-in inputs. The audit did not establish byte-for-byte identity with the historical run or reproduce its numerical scores.

Saved practice results and checked-in input overlap—not an independent assessment.
LanguageSaved practice F1AccountsExact text-timeline matches in checked-in official data
English0.95238275252
French1.000171164

This finding changes what those results support. It does not measure how much overlap affected the scores, nor establish that every official validation fold was invalid. The original practice reports remain unchanged, with their scope explained here rather than retroactively relabelled as independent results.

Overlap audit method

The audit inspected checked-in inputs at revision 5539649f4757570eab0c1bdc8d304597492d7aa4. It compared SHA-256 fingerprints of sorted complete post-text lists, ignoring post order but preserving repeated occurrences. It did not normalise case or whitespace. A separate fingerprint compared canonical full profile/post payloads with account and post identifiers excluded, retaining timestamps and other fields.

The 252 English timeline matches were against official shards 1, 3 and 5; none were identical full records. The 164 French timeline matches were present against official shard 2 alone; 131 also matched the ID-stripped full payload. The historical reports name the same dataset IDs, but lack saved input checksums to establish historical-byte parity. These checks identify exact content reuse in the inspected files, not a reconstruction of the training run.

Preventing overlap in future runs

Consider an account copied into a practice file under a new ID but with an identical list of post texts. An ID-only check would accept it as a new example. The local follow-up implementation instead treats it as an exact alias, alongside accounts sharing an ID.

Exact aliases stay together during splitting, and incompatible predefined boundaries fail before fitting. Generated outer holdout and out-of-fold splits keep alias groups intact. If an alias crosses fixed official-shard, train/practice or primary/auxiliary boundaries, the workflow stops rather than quietly moving or dropping records. Conflicting labels within an alias group also stop the run. The shipped overlapping official/practice pairing therefore cannot pass the current optimisation guard unchanged.

The follow-up audit records input and label checksums, overlap counts and label conflicts without publishing account records. These local safeguards postdate the pinned historical run and tests above; they do not turn its saved practice results into an independent assessment.

Evaluating on independent accounts

The remaining assessment needs to happen in this order:

  1. Freeze the inputs and grouping rules. Record checksums, label provenance and source/entity groups, with a declared near-duplicate policy. Exact matching misses paraphrases, edited timelines and other near duplicates.
  2. Reserve assessment data before selection. Use independently labelled accounts with appropriate separation from development data, keeping their results out of model, ensemble-weight and threshold decisions.
  3. Fit within the permitted training partitions. Learn TF-IDF vocabularies, SVD projections, scaling, calibration and models only from allowed training accounts. Internal probability calibration currently uses ungrouped folds; aliases can cross those internal folds, affecting the probabilities used for threshold selection. The protected outer boundaries still apply, but making calibration itself group-aware remains a separate modelling follow-up.
  4. Assess the fixed system on the reserved accounts. Record per-language confusion counts, utility and F1 with the frozen model and threshold choices, without using those results to promote another candidate.

That assessment has not been run. The result I can currently defend is a model-comparison pipeline with recorded decisions and increasingly careful data-splitting safeguards; independent predictive performance remains unresolved.