{
  "id": 20199220,
  "title": "Cross-validation, and the split that hides a model's failure",
  "url": "https://urgent.news/2026/11/15/cross-validation-and-the-split-that-hides-a-models-failure",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-15T16:03:47.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mashiah/cross-validation-and-the-split-that-hides-a-models-failure-1hbc"
  },
  "original_language": "en",
  "account": "Cross-validation is a common method used to assess the performance of a model. By splitting the data into equal parts, or \"folds,\" the model's performance can be evaluated by training on k-1 folds and testing on the remaining fold. This process is repeated k times, ensuring that each fold serves as the test set once. However, there is a hidden flaw in this method that can lead to misleading results.\n\nIn the provided example, a straight-line model fitted to data with two groups is scored using k-fold cross-validation with three folds. While the model achieves a decent score of 0.80, the same model trained on one group and tested on another group yields a significantly lower score of -0.67. This discrepancy arises because the model is only tested on data it has already seen during training, leading to an inflated score.\n\nFurthermore, the example demonstrates how the choice of folds can heavily influence the model's performance score. Splitting the data by group rather than randomly mixing the data leads to a much worse score, indicating that the model has learned to fit each group rather than the overall relationship. This highlights the importance of choosing folds that reflect the real-world scenarios in which the model will be used.\n\nIn the author's research on predicting the stiffness of metal plates, a similar issue was encountered. A neural network model performed exceptionally well when trained on round-hole cells but scored below zero when tested on other hole families. Splitting the data based on the group (hole type) rather than individual rows revealed that the model had simply memorized the patterns within each group rather than learning the underlying relationship between hole type and stiffness.\n\nTo mitigate this issue, the author suggests using group-based cross-validation techniques, such as GroupKFold and LeaveOneGroupOut, which ensure that the model is tested on data from different groups than those used for training. This approach helps prevent the model from being overly optimistic about its performance and encourages it to learn more generalizable patterns.",
  "summary": "Cross-validation is how most models get their score. Six points worked through by hand show how k-fold works, and how the same model scores 0.80 or −0.67 depending only on how the data was split. A model has to be scored on data it was not trained on, or the score only measures memory. Holding back one test set works, but with little data the score then depends heavily on which rows landed in it.…",
  "key_points": [
    "Cross-validation assesses model performance by splitting data into folds.",
    "Hidden flaw: model scores higher when tested on data it saw during training.",
    "Group-based cross-validation prevents overfitting to specific data groups."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}