{
  "id": 663108,
  "title": "13th Public/12th Private Solution",
  "url": "/competitions/MABe-mouse-behavior-detection/writeups/12th-place-solution",
  "author_name": "",
  "post_date": "2025-12-16T13:29:57.757Z",
  "votes": 26,
  "comment_count": 2,
  "views": 0,
  "content": "<p>We thank the MABe Challenge organizers for running an engaging competition and for providing detailed, timely clarifications during the early stages.</p>\n<h1>High‑level idea</h1>\n<ul>\n<li>Formulate the problem as a set of per-action binary tasks, trained separately for each lab</li>\n<li>Train multiple models under diverse conditions, including tuned action-specific feature subsets, negative downsampling schemes, and hyperparameters </li>\n<li>Use video-level cross-validation and ensemble the resulting fold models at inference</li>\n<li>Sample background frames to control the ratio of true negatives and unlabeled data</li>\n<li>Calibrate predictions and adjust log-likelihood-ratio scores with training priors</li>\n<li>Apply postprocessing, including temporal smoothing, per-action threshold fitting, and argmax-based action selection</li>\n</ul>\n<h1>EDA notebooks</h1>\n<p>Several exploratory notebooks were used to understand the structure, limitations, and implicit assumptions of the dataset. These analyses informed key modeling choices, including task formulation, negative sampling, calibration strategy, and postprocessing.</p>\n<ul>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-an-exploratory-data-safari\" target=\"_blank\">Overall data overview</a> </li>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-data-constraints-modeling-implications\" target=\"_blank\">Deeper analysis of data constraints and their modeling implications</a></li>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-sanity-checks-data-issues\" target=\"_blank\">Data quality checks and identified issues</a></li>\n</ul>\n<h1>Source code</h1>\n<p>The full source code required to reproduce the solution is available at <a href=\"https://github.com/T0chka/mabe_12th_place_solution\" target=\"_blank\">the repo</a></p>\n<h1>Data assembly</h1>\n<p>Data were prepared as a combination of all frames with tracks for each video_id and each (agent_id, target_id) pair from the whitelist (behaviors_labeled column in train/test csv files). Frames annotated with a given behavior were treated as positive examples for that action; unlabeled frames were treated as background.</p>\n<h1>Shared feature space</h1>\n<p>All models reuse a common feature representation composed of three groups:</p>\n<ol>\n<li>Invariant, agent-centric geometry and kinematics (relative distances, angles, approach/retreat cues, motion alignment, and time since contact).</li>\n<li>Single-mouse descriptors (forward and lateral velocities, accelerations, total speed, turning rate, path curvature, motion smoothness, body length, ear gap, and related stability metrics).</li>\n<li>Pairwise distances between selected body parts within each mouse and across the agent-target pair, computed either on raw landmarks or on aggregated body regions obtained by averaging upper and lower body parts.</li>\n</ol>\n<p>Invariant and single-mouse descriptors were normalized by agent body length.</p>\n<p>For a subset of models, the base feature set was augmented with windowed temporal features computed for a tuned subset of base variables. Specifically, the pipeline appends rolling mean summaries over three lagged windows, providing history-aware covariates.</p>\n<h1>Models</h1>\n<p>The final ensemble includes 5 model families: XGBoost, LightGBM, Catboost, PyBoost, and TABM.\nBoosting-based models were trained separately for each lab and each action. In LightGBM, positive frames were weighted inversely to the length of the corresponding action run, preventing long continuous events from dominating the loss. Because raw boosting margins are not directly comparable across actions and labs, we applied a two-step Platt calibration with prior correction, learned from out-of-fold (OOF) predictions. \nTABM models were trained per lab using a one-vs-rest formulation with independent sigmoid heads for each action.</p>\n<p>The ensemble uses weigths fitted on OOF, and single-model scores are:</p>\n<ul>\n<li>XGBoost: public 0.521, private 0.489</li>\n<li>Catboost: public 0.517, private 0.491</li>\n<li>PyBoost: public 0.512, private 0.488</li>\n<li>TABM: public 0.506, private 0.487</li>\n<li>LightGBM: public 0.492, private 0.477</li>\n</ul>\n<h1>Subsampling negatives</h1>\n<p>For boosting-based models, unlabeled frames were partitioned into two groups with respect to a given action:</p>\n<ol>\n<li>Real negative frame: has an annotation with a different action, or is unlabeled while the action is present in the video’s whitelist (meaning it could have been annotated, the action just did not happen).</li>\n<li>Maybe negative frame: is unlabeled and the action is absent from the video’s whitelist (meaning the action could have occurred, but was outside the annotator’s labeling scope)</li>\n</ol>\n<p>The final training set for a fold consisted of all positives plus negatives sampled by video from the two pools above.</p>\n<p>For TabM, unlabeled frames were downsampled by (video, agent, target) triplets. Since the models were trained in a multiclass setting, this distinction between negative types was not applied.</p>\n<h1>Cross-validation</h1>\n<p>Folds were built at the video level. Each model applied 5-fold cross-validation and produced complete out-of-fold (OOF) predictions for the entire training set. This resulted in a good CV-LB correlation. All 5 model families ensemble their fold-specific models at inference.</p>\n<h1>Postprocessing</h1>\n<p>The frame-level predictions were filtered to the whitelist, keeping only valid (video, agent, target, action) combinations. Smoothing was then applied using rolling windows whose sizes correspond to the median action durations observed in the training data. Action-specific thresholds were fitted on OOF, and applied after smoothing; a single action per frame was selected using argmax. Consecutive frames with the same chosen action were then merged into intervals, forming the final submission.</p>",
  "messages": [
    {
      "id": "3377503",
      "postDate": "12/16/2025 13:28:29",
      "content": "<p>We thank the MABe Challenge organizers for running an engaging competition and for providing detailed, timely clarifications during the early stages.</p>\n<h1>High‑level idea</h1>\n<ul>\n<li>Formulate the problem as a set of per-action binary tasks, trained separately for each lab</li>\n<li>Train multiple models under diverse conditions, including tuned action-specific feature subsets, negative downsampling schemes, and hyperparameters </li>\n<li>Use video-level cross-validation and ensemble the resulting fold models at inference</li>\n<li>Sample background frames to control the ratio of true negatives and unlabeled data</li>\n<li>Calibrate predictions and adjust log-likelihood-ratio scores with training priors</li>\n<li>Apply postprocessing, including temporal smoothing, per-action threshold fitting, and argmax-based action selection</li>\n</ul>\n<h1>EDA notebooks</h1>\n<p>Several exploratory notebooks were used to understand the structure, limitations, and implicit assumptions of the dataset. These analyses informed key modeling choices, including task formulation, negative sampling, calibration strategy, and postprocessing.</p>\n<ul>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-an-exploratory-data-safari\" target=\"_blank\">Overall data overview</a> </li>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-data-constraints-modeling-implications\" target=\"_blank\">Deeper analysis of data constraints and their modeling implications</a></li>\n<li><a href=\"https://www.kaggle.com/code/antoninadolgorukova/mabe-sanity-checks-data-issues\" target=\"_blank\">Data quality checks and identified issues</a></li>\n</ul>\n<h1>Source code</h1>\n<p>The full source code required to reproduce the solution is available at <a href=\"https://github.com/T0chka/mabe_12th_place_solution\" target=\"_blank\">the repo</a></p>\n<h1>Data assembly</h1>\n<p>Data were prepared as a combination of all frames with tracks for each video_id and each (agent_id, target_id) pair from the whitelist (behaviors_labeled column in train/test csv files). Frames annotated with a given behavior were treated as positive examples for that action; unlabeled frames were treated as background.</p>\n<h1>Shared feature space</h1>\n<p>All models reuse a common feature representation composed of three groups:</p>\n<ol>\n<li>Invariant, agent-centric geometry and kinematics (relative distances, angles, approach/retreat cues, motion alignment, and time since contact).</li>\n<li>Single-mouse descriptors (forward and lateral velocities, accelerations, total speed, turning rate, path curvature, motion smoothness, body length, ear gap, and related stability metrics).</li>\n<li>Pairwise distances between selected body parts within each mouse and across the agent-target pair, computed either on raw landmarks or on aggregated body regions obtained by averaging upper and lower body parts.</li>\n</ol>\n<p>Invariant and single-mouse descriptors were normalized by agent body length.</p>\n<p>For a subset of models, the base feature set was augmented with windowed temporal features computed for a tuned subset of base variables. Specifically, the pipeline appends rolling mean summaries over three lagged windows, providing history-aware covariates.</p>\n<h1>Models</h1>\n<p>The final ensemble includes 5 model families: XGBoost, LightGBM, Catboost, PyBoost, and TABM.\nBoosting-based models were trained separately for each lab and each action. In LightGBM, positive frames were weighted inversely to the length of the corresponding action run, preventing long continuous events from dominating the loss. Because raw boosting margins are not directly comparable across actions and labs, we applied a two-step Platt calibration with prior correction, learned from out-of-fold (OOF) predictions. \nTABM models were trained per lab using a one-vs-rest formulation with independent sigmoid heads for each action.</p>\n<p>The ensemble uses weigths fitted on OOF, and single-model scores are:</p>\n<ul>\n<li>XGBoost: public 0.521, private 0.489</li>\n<li>Catboost: public 0.517, private 0.491</li>\n<li>PyBoost: public 0.512, private 0.488</li>\n<li>TABM: public 0.506, private 0.487</li>\n<li>LightGBM: public 0.492, private 0.477</li>\n</ul>\n<h1>Subsampling negatives</h1>\n<p>For boosting-based models, unlabeled frames were partitioned into two groups with respect to a given action:</p>\n<ol>\n<li>Real negative frame: has an annotation with a different action, or is unlabeled while the action is present in the video’s whitelist (meaning it could have been annotated, the action just did not happen).</li>\n<li>Maybe negative frame: is unlabeled and the action is absent from the video’s whitelist (meaning the action could have occurred, but was outside the annotator’s labeling scope)</li>\n</ol>\n<p>The final training set for a fold consisted of all positives plus negatives sampled by video from the two pools above.</p>\n<p>For TabM, unlabeled frames were downsampled by (video, agent, target) triplets. Since the models were trained in a multiclass setting, this distinction between negative types was not applied.</p>\n<h1>Cross-validation</h1>\n<p>Folds were built at the video level. Each model applied 5-fold cross-validation and produced complete out-of-fold (OOF) predictions for the entire training set. This resulted in a good CV-LB correlation. All 5 model families ensemble their fold-specific models at inference.</p>\n<h1>Postprocessing</h1>\n<p>The frame-level predictions were filtered to the whitelist, keeping only valid (video, agent, target, action) combinations. Smoothing was then applied using rolling windows whose sizes correspond to the median action durations observed in the training data. Action-specific thresholds were fitted on OOF, and applied after smoothing; a single action per frame was selected using argmax. Consecutive frames with the same chosen action were then merged into intervals, forming the final submission.</p>",
      "rawMarkdown": "We thank the MABe Challenge organizers for running an engaging competition and for providing detailed, timely clarifications during the early stages.\n\n# High‑level idea\n-\tFormulate the problem as a set of per-action binary tasks, trained separately for each lab\n-\tTrain multiple models under diverse conditions, including tuned action-specific feature subsets, negative downsampling schemes, and hyperparameters \n-\tUse video-level cross-validation and ensemble the resulting fold models at inference\n-\tSample background frames to control the ratio of true negatives and unlabeled data\n-\tCalibrate predictions and adjust log-likelihood-ratio scores with training priors\n-\tApply postprocessing, including temporal smoothing, per-action threshold fitting, and argmax-based action selection\n\n# EDA notebooks\nSeveral exploratory notebooks were used to understand the structure, limitations, and implicit assumptions of the dataset. These analyses informed key modeling choices, including task formulation, negative sampling, calibration strategy, and postprocessing.\n- [Overall data overview](https://www.kaggle.com/code/antoninadolgorukova/mabe-an-exploratory-data-safari ) \n- [Deeper analysis of data constraints and their modeling implications](https://www.kaggle.com/code/antoninadolgorukova/mabe-data-constraints-modeling-implications)\n- [Data quality checks and identified issues](https://www.kaggle.com/code/antoninadolgorukova/mabe-sanity-checks-data-issues)\n\n# Source code\nThe full source code required to reproduce the solution is available at [the repo](https://github.com/T0chka/mabe_12th_place_solution)\n\n# Data assembly\nData were prepared as a combination of all frames with tracks for each video_id and each (agent_id, target_id) pair from the whitelist (behaviors_labeled column in train/test csv files). Frames annotated with a given behavior were treated as positive examples for that action; unlabeled frames were treated as background.\n\n# Shared feature space\nAll models reuse a common feature representation composed of three groups:\n1. Invariant, agent-centric geometry and kinematics (relative distances, angles, approach/retreat cues, motion alignment, and time since contact).\n2. Single-mouse descriptors (forward and lateral velocities, accelerations, total speed, turning rate, path curvature, motion smoothness, body length, ear gap, and related stability metrics).\n3. Pairwise distances between selected body parts within each mouse and across the agent-target pair, computed either on raw landmarks or on aggregated body regions obtained by averaging upper and lower body parts.\n\nInvariant and single-mouse descriptors were normalized by agent body length.\n\nFor a subset of models, the base feature set was augmented with windowed temporal features computed for a tuned subset of base variables. Specifically, the pipeline appends rolling mean summaries over three lagged windows, providing history-aware covariates.\n\n# Models\nThe final ensemble includes 5 model families: XGBoost, LightGBM, Catboost, PyBoost, and TABM.\nBoosting-based models were trained separately for each lab and each action. In LightGBM, positive frames were weighted inversely to the length of the corresponding action run, preventing long continuous events from dominating the loss. Because raw boosting margins are not directly comparable across actions and labs, we applied a two-step Platt calibration with prior correction, learned from out-of-fold (OOF) predictions. \nTABM models were trained per lab using a one-vs-rest formulation with independent sigmoid heads for each action.\n\nThe ensemble uses weigths fitted on OOF, and single-model scores are:\n- XGBoost: public 0.521, private 0.489\n- Catboost: public 0.517, private 0.491\n- PyBoost: public 0.512, private 0.488\n- TABM: public 0.506, private 0.487\n- LightGBM: public 0.492, private 0.477\n\n# Subsampling negatives\nFor boosting-based models, unlabeled frames were partitioned into two groups with respect to a given action:\n1. Real negative frame: has an annotation with a different action, or is unlabeled while the action is present in the video’s whitelist (meaning it could have been annotated, the action just did not happen).\n2. Maybe negative frame: is unlabeled and the action is absent from the video’s whitelist (meaning the action could have occurred, but was outside the annotator’s labeling scope)\n\nThe final training set for a fold consisted of all positives plus negatives sampled by video from the two pools above.\n\nFor TabM, unlabeled frames were downsampled by (video, agent, target) triplets. Since the models were trained in a multiclass setting, this distinction between negative types was not applied.\n\n# Cross-validation\nFolds were built at the video level. Each model applied 5-fold cross-validation and produced complete out-of-fold (OOF) predictions for the entire training set. This resulted in a good CV-LB correlation. All 5 model families ensemble their fold-specific models at inference.\n\n# Postprocessing\nThe frame-level predictions were filtered to the whitelist, keeping only valid (video, agent, target, action) combinations. Smoothing was then applied using rolling windows whose sizes correspond to the median action durations observed in the training data. Action-specific thresholds were fitted on OOF, and applied after smoothing; a single action per frame was selected using argmax. Consecutive frames with the same chosen action were then merged into intervals, forming the final submission.",
      "votes": null
    },
    {
      "id": "3377708",
      "postDate": "12/16/2025 20:18:28",
      "content": "<p>This is actually the strongest CV-LB rank correlation in my (admittedly small with 4 competitions in total) experience!</p>\n<p>(If look at the overal R (Spearman) and models with a sufficient number of runs in the plot)</p>\n<p>The increase in rank correlation on the private split suggests that the\napproach is robust to public-leaderboard overfitting and that the private test\nset is statistically closer to the training distribution than the public one.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F12193662%2F95ffd0b3ca40b14ae11e1920ad83a515%2FScreenshot%202025-12-16%20231125.png?generation=1765916280618984&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "This is actually the strongest CV-LB rank correlation in my (admittedly small with 4 competitions in total) experience!\n\n(If look at the overal R (Spearman) and models with a sufficient number of runs in the plot)\n\nThe increase in rank correlation on the private split suggests that the\napproach is robust to public-leaderboard overfitting and that the private test\nset is statistically closer to the training distribution than the public one.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F12193662%2F95ffd0b3ca40b14ae11e1920ad83a515%2FScreenshot%202025-12-16%20231125.png?generation=1765916280618984&alt=media)",
      "votes": null
    },
    {
      "id": "3382670",
      "postDate": "12/28/2025 08:29:05",
      "content": "<p>Wow， very excellent plan！</p>",
      "rawMarkdown": "Wow， very excellent plan！",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3377708,
      "author_name": "antoninadolgorukova",
      "author_url": "",
      "post_date": "12/16/2025 20:18:28",
      "content": "<p>This is actually the strongest CV-LB rank correlation in my (admittedly small with 4 competitions in total) experience!</p>\n<p>(If look at the overal R (Spearman) and models with a sufficient number of runs in the plot)</p>\n<p>The increase in rank correlation on the private split suggests that the\napproach is robust to public-leaderboard overfitting and that the private test\nset is statistically closer to the training distribution than the public one.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F12193662%2F95ffd0b3ca40b14ae11e1920ad83a515%2FScreenshot%202025-12-16%20231125.png?generation=1765916280618984&amp;alt=media\" alt=\"\"></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 3382670,
      "author_name": "mingli321",
      "author_url": "",
      "post_date": "12/28/2025 08:29:05",
      "content": "<p>Wow， very excellent plan！</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3377503": "We thank the MABe Challenge organizers for running an engaging competition and for providing detailed, timely clarifications during the early stages.\n\n# High‑level idea\n-\tFormulate the problem as a set of per-action binary tasks, trained separately for each lab\n-\tTrain multiple models under diverse conditions, including tuned action-specific feature subsets, negative downsampling schemes, and hyperparameters \n-\tUse video-level cross-validation and ensemble the resulting fold models at inference\n-\tSample background frames to control the ratio of true negatives and unlabeled data\n-\tCalibrate predictions and adjust log-likelihood-ratio scores with training priors\n-\tApply postprocessing, including temporal smoothing, per-action threshold fitting, and argmax-based action selection\n\n# EDA notebooks\nSeveral exploratory notebooks were used to understand the structure, limitations, and implicit assumptions of the dataset. These analyses informed key modeling choices, including task formulation, negative sampling, calibration strategy, and postprocessing.\n- [Overall data overview](https://www.kaggle.com/code/antoninadolgorukova/mabe-an-exploratory-data-safari ) \n- [Deeper analysis of data constraints and their modeling implications](https://www.kaggle.com/code/antoninadolgorukova/mabe-data-constraints-modeling-implications)\n- [Data quality checks and identified issues](https://www.kaggle.com/code/antoninadolgorukova/mabe-sanity-checks-data-issues)\n\n# Source code\nThe full source code required to reproduce the solution is available at [the repo](https://github.com/T0chka/mabe_12th_place_solution)\n\n# Data assembly\nData were prepared as a combination of all frames with tracks for each video_id and each (agent_id, target_id) pair from the whitelist (behaviors_labeled column in train/test csv files). Frames annotated with a given behavior were treated as positive examples for that action; unlabeled frames were treated as background.\n\n# Shared feature space\nAll models reuse a common feature representation composed of three groups:\n1. Invariant, agent-centric geometry and kinematics (relative distances, angles, approach/retreat cues, motion alignment, and time since contact).\n2. Single-mouse descriptors (forward and lateral velocities, accelerations, total speed, turning rate, path curvature, motion smoothness, body length, ear gap, and related stability metrics).\n3. Pairwise distances between selected body parts within each mouse and across the agent-target pair, computed either on raw landmarks or on aggregated body regions obtained by averaging upper and lower body parts.\n\nInvariant and single-mouse descriptors were normalized by agent body length.\n\nFor a subset of models, the base feature set was augmented with windowed temporal features computed for a tuned subset of base variables. Specifically, the pipeline appends rolling mean summaries over three lagged windows, providing history-aware covariates.\n\n# Models\nThe final ensemble includes 5 model families: XGBoost, LightGBM, Catboost, PyBoost, and TABM.\nBoosting-based models were trained separately for each lab and each action. In LightGBM, positive frames were weighted inversely to the length of the corresponding action run, preventing long continuous events from dominating the loss. Because raw boosting margins are not directly comparable across actions and labs, we applied a two-step Platt calibration with prior correction, learned from out-of-fold (OOF) predictions. \nTABM models were trained per lab using a one-vs-rest formulation with independent sigmoid heads for each action.\n\nThe ensemble uses weigths fitted on OOF, and single-model scores are:\n- XGBoost: public 0.521, private 0.489\n- Catboost: public 0.517, private 0.491\n- PyBoost: public 0.512, private 0.488\n- TABM: public 0.506, private 0.487\n- LightGBM: public 0.492, private 0.477\n\n# Subsampling negatives\nFor boosting-based models, unlabeled frames were partitioned into two groups with respect to a given action:\n1. Real negative frame: has an annotation with a different action, or is unlabeled while the action is present in the video’s whitelist (meaning it could have been annotated, the action just did not happen).\n2. Maybe negative frame: is unlabeled and the action is absent from the video’s whitelist (meaning the action could have occurred, but was outside the annotator’s labeling scope)\n\nThe final training set for a fold consisted of all positives plus negatives sampled by video from the two pools above.\n\nFor TabM, unlabeled frames were downsampled by (video, agent, target) triplets. Since the models were trained in a multiclass setting, this distinction between negative types was not applied.\n\n# Cross-validation\nFolds were built at the video level. Each model applied 5-fold cross-validation and produced complete out-of-fold (OOF) predictions for the entire training set. This resulted in a good CV-LB correlation. All 5 model families ensemble their fold-specific models at inference.\n\n# Postprocessing\nThe frame-level predictions were filtered to the whitelist, keeping only valid (video, agent, target, action) combinations. Smoothing was then applied using rolling windows whose sizes correspond to the median action durations observed in the training data. Action-specific thresholds were fitted on OOF, and applied after smoothing; a single action per frame was selected using argmax. Consecutive frames with the same chosen action were then merged into intervals, forming the final submission.",
    "3377708": "This is actually the strongest CV-LB rank correlation in my (admittedly small with 4 competitions in total) experience!\n\n(If look at the overal R (Spearman) and models with a sufficient number of runs in the plot)\n\nThe increase in rank correlation on the private split suggests that the\napproach is robust to public-leaderboard overfitting and that the private test\nset is statistically closer to the training distribution than the public one.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F12193662%2F95ffd0b3ca40b14ae11e1920ad83a515%2FScreenshot%202025-12-16%20231125.png?generation=1765916280618984&alt=media)",
    "3382670": "Wow， very excellent plan！"
  },
  "source": "meta"
}