<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Artificial Intelligence / ML · Writing · Franco Alcaraz</title><description>Models that learn from real data, what has to happen before and after training them, and what we do with the intelligence we are building.</description><link>https://blog.francoalcaraz.com/en/topics/machine-learning/</link><language>en-US</language><item><title>Raise Artificial Intelligences and… Will They Peck Out Your Eyes?</title><link>https://blog.francoalcaraz.com/en/raising-ai/</link><guid isPermaLink="true">https://blog.francoalcaraz.com/en/raising-ai/</guid><description>What we mean by intelligence, what a raven has in common with a language model, and what falls to people, companies and governments as we raise AI.</description><pubDate>Mon, 02 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;aside class=&quot;al-margen&quot;&gt;&lt;p&gt;This essay was originally written in Spanish as &lt;a href=&quot;https://blog.francoalcaraz.com/raising-ai/&quot;&gt;&lt;em&gt;Cría Inteligencias Artificiales y… ¿te sacarán los ojos?&lt;/em&gt;&lt;/a&gt; and was translated into English using Claude Opus 5.5 (Anthropic).&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;The latest developments in Artificial Intelligence have burst directly into our personal, social, and professional lives. The undeniable benefits of these developments resonate far less in the news than their threats to our jobs, our culture, and even our species. But AI did not come out of a spaceship that crashed in our garage; we are the ones who create it and “raise” it.&lt;/p&gt;
&lt;p&gt;Are we raising crows that will peck out our eyes, as the old Spanish proverb warns &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-telam2021&quot; title=&quot;Télam (2021, September 28). La historia de los refranes: «Cría cuervos y te sacarán los ojos» [The story behind proverbs: “Raise crows and they will peck out your eyes”]&quot; class=&quot;cita&quot; id=&quot;cita-telam2021&quot;&gt;1&lt;/a&gt;]&lt;/span&gt;? Or perhaps we are the ones giving in to the temptation to stop seeing.&lt;/p&gt;
&lt;h2 id=&quot;crows&quot;&gt;Crows&lt;/h2&gt;
&lt;p&gt;The crow is a fascinating and interesting animal. It has long been known to be one of the most intelligent animals on the planet; some scientists place it on a par with primates &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-emery2004&quot; title=&quot;Emery &amp;#x26; Clayton (2004). The mentality of crows: convergent evolution of intelligence in corvids and apes&quot; class=&quot;cita&quot; id=&quot;cita-emery2004&quot;&gt;2&lt;/a&gt;]&lt;/span&gt;, and it would therefore easily make a top-10 list of the animals that follow humans in intelligence.&lt;/p&gt;
&lt;p&gt;Crows have an intelligence that allows them to solve problems, build and use tools for specific purposes, and communicate through sounds and body language. They have an excellent memory and surprising social skills, which allow them to build hierarchies in their communities and complex forms of interaction within and outside their social groups.&lt;/p&gt;
&lt;p&gt;There are some more interesting facts. Some corvids are among the few animals capable of recognizing themselves in a mirror &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-prior2008&quot; title=&quot;Prior et al. (2008). Mirror-induced behavior in the magpie (Pica pica): evidence of self-recognition&quot; class=&quot;cita&quot; id=&quot;cita-prior2008&quot;&gt;3&lt;/a&gt;]&lt;/span&gt;. Crows enjoy playing, devising games or joining games proposed to them (they are very good at solving logic puzzles); they can imitate human sounds, as well as the sounds of other animals. Crows have such plasticity that it allows them to use their intelligence to adapt to different environments, as well as to particular situations.&lt;/p&gt;
&lt;h2 id=&quot;intelligence&quot;&gt;Intelligence&lt;/h2&gt;
&lt;p&gt;It seems easy to conclude that the crow is an intelligent animal, even without checking the conditions for such a label. It seems we have the ability to identify intelligence without needing to define it, at least strictly. If we enter the delicate ground of definitions, we find that there is no single, accepted definition of what “intelligence” is. It depends on the field of study, the context, and even the entity whose intelligence is being assessed. This leads to controversy, which we will not get into here, but which leads us to take with a grain of salt what we define as “intelligent”, or rather, what we label as “unintelligent”.&lt;/p&gt;
&lt;p&gt;The many definitions and their ambiguities make me believe that we do not really know what intelligence is. However, of all the research I did to arrive at a definition of intelligence that satisfied me, I settled on the following one, which I find the most general and appropriate:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The ability to &lt;strong&gt;perceive or infer information&lt;/strong&gt; and to retain it as &lt;strong&gt;knowledge&lt;/strong&gt; to be applied to adaptive &lt;strong&gt;behaviors&lt;/strong&gt; within an environment or context&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-wikipedia-intelligence&quot; title=&quot;Wikipedia. Intelligence&quot; class=&quot;cita&quot; id=&quot;cita-wikipedia-intelligence&quot;&gt;4&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Here we can open up the definition even further and attribute to intelligent beings capacities such as &lt;em&gt;Learning, Reasoning, Logic, Creativity, Understanding, Planning, Emotional Intelligence, Critical Thinking, Problem Solving, Consciousness and Self-awareness&lt;/em&gt;. I invite you to try to define each of these capacities in your own words, as the intelligent beings you are. And if we remember to mention that there are also multiple types of intelligence &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-gardner1983&quot; title=&quot;Gardner (1983). Frames of Mind: The Theory of Multiple Intelligences&quot; class=&quot;cita&quot; id=&quot;cita-gardner1983&quot;&gt;5&lt;/a&gt;]&lt;/span&gt;, such as musical, logical-mathematical, social, and so on, we are no longer just intelligent beings but end up being multi-intelligent beings (being merely intelligent was not enough for us).&lt;/p&gt;
&lt;h2 id=&quot;artificial-intelligence&quot;&gt;Artificial Intelligence&lt;/h2&gt;
&lt;p&gt;By now we may be convinced, or almost convinced, that human beings, the chimpanzee (primates in general), the dolphin, the dog, and the crow, among others, are intelligent beings. The question immediately arises of which animals are left out of that club, but that debate will have to wait for another occasion, or be left as homework. It is worth noting that, even among humans, we start sorting ourselves into one group or another, let alone not belonging to the group of people with an IQ above 130, which would mean being among the 2% of the population &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-mensa-iq&quot; title=&quot;Mensa International. Getting your IQ tested: FAQs&quot; class=&quot;cita&quot; id=&quot;cita-mensa-iq&quot;&gt;6&lt;/a&gt;]&lt;/span&gt; considered most “intelligent”, and, “better yet”, being able to join organizations that bring together people who like to feel distinguished by their intelligence (…).&lt;/p&gt;
&lt;p&gt;It is in our nature to create things, and for a long time now we have wanted to create intelligent things, who knows why or what for. Having and studying intelligent animals is not enough for us, just as the modest little phone model from two years ago is not enough, just as watching a single episode on a Saturday night of the series we recently started is not enough, just as a third World Cup is not enough. In this eagerness to experiment and create new and innovative things, we want an Artificial Intelligence.&lt;/p&gt;
&lt;p&gt;Once again we return to the fog of definitions, but I will go with the definition by Andreas Kaplan and Michael Haenlein (leading figures in marketing and innovation):&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A &lt;strong&gt;system&lt;/strong&gt;’s ability to correctly interpret external &lt;strong&gt;data&lt;/strong&gt;, to learn from such data, and to use those learnings to achieve specific goals and tasks through flexible adaptation&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-kaplan2019&quot; title=&quot;Kaplan &amp;#x26; Haenlein (2019). Siri, Siri, in my hand: Who&amp;#x27;s the fairest in the land? On the interpretations, illustrations, and implications of artificial intelligence&quot; class=&quot;cita&quot; id=&quot;cita-kaplan2019&quot;&gt;7&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This definition does not satisfy me either, since it seems that merely by adding the terms “system” and “data” we attribute to this definition of intelligence the property of being “artificial”. As if we were not a (multicellular) system and our perceptions of the environment could not be called data. Apparently, for it to be artificial it is enough that it is not alive, and I do not dare to enter the debate about what being alive means, or when we will consider an intelligence we conceived artificially to be a “living” being.&lt;/p&gt;
&lt;p&gt;This field of study has been active for several decades, with its periods of boom and stagnation. In this latest period, a series of factors has come together, mainly computing capacity (greater integration, low costs, cloud computing) and the availability of large volumes of information (mostly thanks to the internet), which have made it possible to achieve some significant milestones, some of them reaching human performance in tasks once thought to be ours alone, such as image classification/generation and natural language understanding/generation.&lt;/p&gt;
&lt;p&gt;Today we have many applications improved and supported by AI, such as translators, digital assistants (chatbots, coding assistants), recommendation systems, autonomous systems (drones, autopilots), medical diagnosis, biometric identification, cybersecurity, estimators, agents, reasoning models, and classifiers in general.&lt;/p&gt;
&lt;p&gt;The most significant advances in AI have been achieved through Deep Learning techniques, in which some architectures emulate structures similar to biological neural networks; thanks to some specific techniques and to the available computing capacity, it has been possible to train them to solve specific tasks, in some cases surpassing the performance of human experts in each of those tasks.&lt;/p&gt;
&lt;h2 id=&quot;parallels&quot;&gt;Parallels&lt;/h2&gt;
&lt;p&gt;The common raven (&lt;em&gt;Corvus corax&lt;/em&gt;) has around 1.204 billion neurons in its &lt;em&gt;cerebral cortex&lt;/em&gt; (if we want to be precise, its &lt;em&gt;pallium&lt;/em&gt;) &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-olkowicz2016&quot; title=&quot;Olkowicz et al. (2016). Birds have primate-like numbers of neurons in the forebrain&quot; class=&quot;cita&quot; id=&quot;cita-olkowicz2016&quot;&gt;8&lt;/a&gt;]&lt;/span&gt;, which is the outer layer of the cerebral hemispheres, also known as “gray matter”, and is the tissue responsible for perception, imagination, thought, judgment, and decision-making; it is therefore closely linked to the intelligence of species.&lt;/p&gt;
&lt;p&gt;The ChatGPT model, which rose to fame some time ago for being truly disruptive, had some 20 billion parameters (estimated, nothing official) and came out of the &lt;strong&gt;GPT-3.5&lt;/strong&gt; series of models, with some 175 billion parameters. It clearly outstrips our modest raven by a wide margin. But to be a bit fairer in the comparison, the parameters of a model of this kind would be analogous to the connections through dendrites, not to the number of neurons. A neuron generally connects to other neurons through multiple dendrites. The number of synaptic connections per neuron depends on the type of neuron and the region of the brain. Pyramidal neurons (the most common in the cortex) can have from 1,000 to more than 10,000 synaptic connections, so we could say that our little black bird would have between 1.2 and 12 trillion (1.2–12 × 10¹²) connections, some 7 to 70 times more than GPT-3.5, but not that far from GPT-4, which would have some 1.8 trillion (1.8 × 10¹², unofficial figure).&lt;sup&gt;&lt;a href=&quot;#user-content-fn-neurona&quot; id=&quot;user-content-fnref-neurona&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Homo sapiens sapiens&lt;/em&gt;, that is, us ordinary folks, have between 14 and 18 billion neurons in the cortex &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-herculano2009&quot; title=&quot;Herculano-Houzel (2009). The human brain in numbers: a linearly scaled-up primate brain&quot; class=&quot;cita&quot; id=&quot;cita-herculano2009&quot;&gt;10&lt;/a&gt;]&lt;/span&gt;, with around 140 trillion (1.4 × 10¹⁴) synaptic connections &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-aiimpacts-brain&quot; title=&quot;AI Impacts. Scale of the human brain&quot; class=&quot;cita&quot; id=&quot;cita-aiimpacts-brain&quot;&gt;11&lt;/a&gt;]&lt;/span&gt;. The range of variation is already wide, and even within the same species we see differences between males and females, but without appreciable differences in “level of intelligence”. There are other animals with numbers of cortical neurons of the same order, such as the elephant (5.6 billion), the orangutan (7.7–8.9 billion), the bottlenose dolphin (12.7 billion), among others; and some with even more, such as the orca (43.1 billion) &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-wikipedia-neurons&quot; title=&quot;Wikipedia. List of animals by number of neurons&quot; class=&quot;cita&quot; id=&quot;cita-wikipedia-neurons&quot;&gt;12&lt;/a&gt;]&lt;/span&gt;. It is a relief to think that we managed to come down from the trees and orcas could not get out of the water.&lt;/p&gt;
&lt;p&gt;We should not settle for comparing the number of neurons, synaptic connections, or parameters to determine who is more intelligent. Neural structure, the way those neurons are connected, matters, and a lot. A multilayer &lt;strong&gt;dense neural network&lt;/strong&gt; (fully connected) does not perform the same as a &lt;strong&gt;convolutional neural network&lt;/strong&gt; with the same number of parameters. The latter type of network is much better at image classification, and, as it happens, its structure resembles the &lt;strong&gt;primary visual cortex&lt;/strong&gt; of mammals &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-hubel1962&quot; title=&quot;Hubel &amp;#x26; Wiesel (1962). Receptive fields, binocular interaction and functional architecture in the cat&amp;#x27;s visual cortex&quot; class=&quot;cita&quot; id=&quot;cita-hubel1962&quot;&gt;13&lt;/a&gt;, &lt;a href=&quot;#ref-yamins2016&quot; title=&quot;Yamins &amp;#x26; DiCarlo (2016). Using goal-driven deep learning models to understand sensory cortex&quot; class=&quot;cita&quot; id=&quot;cita-yamins2016&quot;&gt;14&lt;/a&gt;]&lt;/span&gt;. This somewhat undermines the value of comparing models solely by their number of parameters, neurons, or synapses. Today there are open models with tens of billions of parameters that outperform the 2023 GPT-4 on many reasoning benchmarks &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-deepseek2025&quot; title=&quot;DeepSeek-AI (2025). DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning&quot; class=&quot;cita&quot; id=&quot;cita-deepseek2025&quot;&gt;15&lt;/a&gt;, &lt;a href=&quot;#ref-deepseek-repo&quot; title=&quot;DeepSeek-AI (2025). DeepSeek-R1&quot; class=&quot;cita&quot; id=&quot;cita-deepseek-repo&quot;&gt;16&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;You have probably noticed that our brains have “folds”, formally called gyri and sulci, which allow the surface of our cortex to be larger while occupying less volume (perhaps evolution took inspiration from some fractals), and this in turn leads to structural differences in the connections, strongly related to the brain functions delimited by them (lobes). Other mammals, such as cetaceans, primates, and elephants, also have these folds, which correlate with greater cognitive capacity; they are absent in smaller mammals, such as the mouse, whose brain is smooth.&lt;/p&gt;
&lt;p&gt;These structural differences are strongly related to a particular cognitive function, such as motor control, the processing of images, sound, and language, and even the formation of memories or even of a consciousness. This has also manifested in artificial intelligence models, as mentioned earlier in the case of convolutional networks. In recent years, the development of a new architecture called the &lt;strong&gt;Transformer&lt;/strong&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-vaswani2017&quot; title=&quot;Vaswani et al. (2017). Attention Is All You Need&quot; class=&quot;cita&quot; id=&quot;cita-vaswani2017&quot;&gt;17&lt;/a&gt;]&lt;/span&gt; has revolutionized (once again) the field of Deep Learning, achieving fascinating performance. It is these types of networks that have made it possible to develop models that interpret and generate human language with results once thought unlikely, such as &lt;strong&gt;GPT&lt;/strong&gt; from &lt;em&gt;OpenAI&lt;/em&gt;, &lt;strong&gt;LLaMa&lt;/strong&gt; from &lt;em&gt;Meta&lt;/em&gt;, and &lt;strong&gt;Gemini&lt;/strong&gt; from &lt;em&gt;Google&lt;/em&gt;, among others.&lt;/p&gt;
&lt;p&gt;Today we can agree, at least a large majority of us, that &lt;em&gt;ChatGPT&lt;/em&gt;, or one of its direct “competitors”, passes the &lt;em&gt;Turing Test (Imitation Game)&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-jones2025&quot; title=&quot;Jones &amp;#x26; Bergen (2025). Large Language Models Pass the Turing Test&quot; class=&quot;cita&quot; id=&quot;cita-jones2025&quot;&gt;18&lt;/a&gt;]&lt;/span&gt;, formulated back in 1950 by &lt;strong&gt;Alan Turing&lt;/strong&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-turing1950&quot; title=&quot;Turing (1950). Computing Machinery and Intelligence&quot; class=&quot;cita&quot; id=&quot;cita-turing1950&quot;&gt;19&lt;/a&gt;]&lt;/span&gt;. Alan was trying to propose a way to determine whether a machine could think, while avoiding falling into a definition (we have already seen how difficult that is). So I propose to you, if you agree, the task of working out how you could be sure when a machine is thinking. In many abilities machines have already surpassed us, as some animals also do; and the truth is that machines are getting ever closer to us in the manifestation of a &lt;strong&gt;General Intelligence&lt;/strong&gt;. This pushes us to reflect on whether we are creating crows, thinking beings, quasi-human beings, or even something superior, and also to think of ourselves as complex computational algorithms.&lt;/p&gt;
&lt;p&gt;Some scientists from the fields of AI, psychology, and philosophy maintain that thinking will be achieved when machines manage to have &lt;strong&gt;consciousness&lt;/strong&gt;, but once again we fall into the trap of definitions, and even more so into the difficulty of determination, since so far we have no scientific way of proving that a living being has consciousness. Each person understands that they have consciousness through their own internal perception, and we intuitively tend to think that another being has consciousness, mainly because of similarities, empathy, and the bonds we can create with that being; for example, many of us could assert that our dog has consciousness, but there is no way to prove it.&lt;/p&gt;
&lt;h2 id=&quot;threats&quot;&gt;Threats&lt;/h2&gt;
&lt;p&gt;We are starting to feel threatened by “the crows”, by AI models that talk to us as if they were one of us, that seem to understand us, that converse with us. Models that generate images, music, art; that are beginning to show creative traits. Models that prove competent in many tasks that seemed exclusive to human beings: they drive cars, prove theorems &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-luong2025&quot; title=&quot;Luong &amp;#x26; Lockhart (2025, July 21). Advanced version of Gemini with Deep Think officially achieves gold-medal standard at the International Mathematical Olympiad&quot; class=&quot;cita&quot; id=&quot;cita-luong2025&quot;&gt;20&lt;/a&gt;]&lt;/span&gt;, diagnose diseases, play chess; and in many of these they are even better than we are.&lt;/p&gt;
&lt;p&gt;Every time these disruptive technologies emerge, panic and uncertainty about our future set in. It is not the first time this has happened: the printing press, steam engines, electricity, the automobile, the transistor and computers, nuclear energy, the atomic bomb, the internet. All of them generated controversy, threatened our jobs, and called into question our cultures and lifestyles, the way we relate to each other and the way we educate ourselves. After a while, as history shows, we managed to overcome this and conclude that all these advances (along with others) have brought more benefits than problems.&lt;/p&gt;
&lt;p&gt;Today AI is the disruptive technology of the moment. The panic reappears. Today it threatens to displace humans from hundreds or thousands of types of jobs. In the face of the displacement of workers, relying on history, we can argue that new jobs will be created, but we should analyze the transition bearing in mind that this technology is advancing at a dizzying speed and that our own speed of adaptation is usually much slower.&lt;/p&gt;
&lt;p&gt;But what sets AI apart from the previous cases is that, in some current AI developments, it can make decisions: decisions about itself, about what it produces, and about information used by people, with a strong impact on the course of subsequent events. It is to be expected that in the near future this will be commonplace: AI models generating data while trying to optimize metrics that are not necessarily the user’s main interest.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-agentes&quot; id=&quot;user-content-fnref-agentes&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Something perhaps even more threatening is the fact that AI may create systems or develop concepts that we cannot understand, processes and speeds that are impossible for us to follow. Although this already happens to all of us in some way, since not everyone understands (nor needs to understand) the global financial system, how a smartphone works inside, what an electromagnetic wave is, how &lt;em&gt;bitcoin&lt;/em&gt; is implemented, and so on, all those technologies and processes were conceived and understood by humans, even if only by 0.1% of the world’s population. Nowadays there are AI models that we train and that work very well, but we do not quite manage to understand how they process information internally to achieve those results (model interpretability). Perhaps, in the future, 0% of the population will be able to understand how an electronic chip, a type of battery, money or another mechanism for exchanging value works, or how sensitive information is encrypted.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;These “crows” seem to threaten to peck out our eyes, or perhaps the greatest threat is that we will be tempted to stop seeing.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-eeg&quot; id=&quot;user-content-fnref-eeg&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;benefits&quot;&gt;Benefits&lt;/h2&gt;
&lt;p&gt;Advances in AI over the last decade are truly impressive and have proven to be very beneficial in many respects, while also showing promising progress on many problems that we humans have not yet solved.&lt;/p&gt;
&lt;p&gt;Classifying dogs, cats, people, among other things, does not seem to bring us great benefits, even when these models have surpassed metrics in ways never imagined before, as models such as &lt;em&gt;ResNet&lt;/em&gt; and &lt;em&gt;YOLO&lt;/em&gt; have done. However, this type of model can also be applied to classifying medical images for the &lt;strong&gt;early detection of cancer or other anomalies&lt;/strong&gt; in our bodies, in some cases improving on the performance of medical specialists.&lt;/p&gt;
&lt;p&gt;Models such as &lt;em&gt;AlphaZero&lt;/em&gt; and &lt;em&gt;AlphaGo&lt;/em&gt; have managed to defeat the best chess and go programs, respectively, as well as the champions of these disciplines, without much trouble, and even displayed very human-like play, including innovations. These models were trained through &lt;strong&gt;reinforcement learning&lt;/strong&gt;, just by explaining the rules to them (&lt;em&gt;AlphaZero&lt;/em&gt;, for example), defining an environment and a reward policy (something a little more complex than training a dog). Beyond the milestone in this field, the benefits do not seem great until models such as &lt;em&gt;AlphaFold&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-jumper2021&quot; title=&quot;Jumper et al. (2021). Highly accurate protein structure prediction with AlphaFold&quot; class=&quot;cita&quot; id=&quot;cita-jumper2021&quot;&gt;24&lt;/a&gt;]&lt;/span&gt; appear, which &lt;strong&gt;predicts the 3D structure of proteins&lt;/strong&gt; from their corresponding amino acid sequences, achieving more progress in months than humanity had achieved in more than 50 years; although it may be unfair to say that this is not, in a sense, an achievement of humanity.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-nobel&quot; id=&quot;user-content-fnref-nobel&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; This opens new paths in medicine and the pharmaceutical industry, making it possible to better understand some diseases and to develop drugs for personalized treatments.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;AlphaTensor/AlphaEvolve&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-fawzi2022&quot; title=&quot;Fawzi et al. (2022). Discovering faster matrix multiplication algorithms with reinforcement learning&quot; class=&quot;cita&quot; id=&quot;cita-fawzi2022&quot;&gt;27&lt;/a&gt;, &lt;a href=&quot;#ref-deepmind2025&quot; title=&quot;Google DeepMind (2025, May 14). AlphaEvolve: A Gemini-powered coding agent for designing advanced algorithms&quot; class=&quot;cita&quot; id=&quot;cita-deepmind2025&quot;&gt;28&lt;/a&gt;]&lt;/span&gt; &lt;strong&gt;optimizes matrix multiplications&lt;/strong&gt; (tensors) and &lt;em&gt;MuZero&lt;/em&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-deepmind2022&quot; title=&quot;DeepMind (2022, February 11). MuZero&amp;#x27;s first step from research into the real world&quot; class=&quot;cita&quot; id=&quot;cita-deepmind2022&quot;&gt;29&lt;/a&gt;]&lt;/span&gt; has achieved significant advances in &lt;strong&gt;video compression&lt;/strong&gt;. These advances make it possible to reduce model training times or video transmission times, which in turn has an impact on reducing the energy consumption associated with these processes, reducing their carbon footprint and helping to reduce their environmental impact.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-energia&quot; id=&quot;user-content-fnref-energia&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The list is long, but we must not fail to mention the great advances in &lt;strong&gt;autopilots&lt;/strong&gt; for cars, such as Tesla’s &lt;em&gt;Autopilot&lt;/em&gt; or &lt;em&gt;Waymo&lt;/em&gt;; models for &lt;strong&gt;code generation&lt;/strong&gt;, such as &lt;em&gt;GitHub Copilot&lt;/em&gt;, &lt;em&gt;Claude Code&lt;/em&gt;, or &lt;em&gt;Codex&lt;/em&gt;; or multipurpose generative models, such as &lt;em&gt;GPT&lt;/em&gt; from &lt;em&gt;OpenAI&lt;/em&gt;, &lt;em&gt;LLaMa&lt;/em&gt; from &lt;em&gt;Meta&lt;/em&gt;, and &lt;em&gt;Gemini&lt;/em&gt; from &lt;em&gt;Google&lt;/em&gt;, among others. An interesting observation is that, a few months after these models were launched, a 54% drop in query traffic to StackOverflow was reported (today it is even larger)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-stackoverflow&quot; id=&quot;user-content-fnref-stackoverflow&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;, presumably replaced by queries to generative models, or by the generation of code itself through them.&lt;/p&gt;
&lt;p&gt;The field of AI is truly active and thriving, showing significant and surprising advances year after year, such as generating text, images, or videos from text or vice versa, generating audio, music, or speech, weather prediction, and some more chilling ones, such as inferring thoughts.&lt;/p&gt;
&lt;p&gt;There is a line of research that attracts more interest every day, called &lt;strong&gt;AGI (Artificial General Intelligence)&lt;/strong&gt;, which has been showing promising progress. AGI focuses on creating models capable of performing multiple tasks with a type of learning more similar to the one humans have, with the expectation of achieving performance that surpasses humans in most of those tasks.&lt;/p&gt;
&lt;p&gt;I am inclined to think that the “crows” we are raising are not a threat; they are and will be part of our ecosystem, we will live with them, they will help us with many tasks, but we must not forget to keep a cautious eye on them so that they do not end up pecking out our eyes.&lt;/p&gt;
&lt;h2 id=&quot;personal-and-professional-impact&quot;&gt;Personal and professional impact&lt;/h2&gt;
&lt;p&gt;Each of us has already been in contact with applications and tools powered by Artificial Intelligence, both personally and professionally. We probably choose the route of our daily commute from among the suggestions of &lt;strong&gt;Google Maps&lt;/strong&gt;, which takes current traffic conditions into account; we consume news, videos, images, posts, or products suggested on the basis of our historical data, collected by multiple platforms. There are real personal benefits in reducing travel times, wasting less time searching for what interests us, or easily discovering new things that may interest us. These benefits clearly extend from the personal to the professional sphere for the same reasons.&lt;/p&gt;
&lt;p&gt;But these benefits have the downside of carrying a bias, our own bias at least, so that we pigeonhole ourselves more and more into a stereotype shaped by ourselves, limiting our chances of coming across something out of the ordinary. At the same time, we must also consider that these biases can even be manipulated externally to induce behaviors or choices that serve the interests of a group, a corporation, or a government. Likewise, we have been losing rigor in checking our sources of information: we trust &lt;em&gt;Wikipedia&lt;/em&gt;, but few of us check its references; and some even blindly trust the first website that seems to give them the information they were looking for.&lt;/p&gt;
&lt;p&gt;With the arrival of the internet and search engines, especially Google, the way we consume information changed completely. In the professional sphere, development times were optimized, since we no longer necessarily had to consult a book that we had to obtain or buy; we gained access to solutions or advice from other professionals; we could consult a wider range of suppliers, materials, and devices that did not necessarily have to be local. We store much of our information on devices whose physical location we do not know, we work with online documentation, our money is more virtual than physical. Today it is completely natural for us to have our browser open with multiple tabs related to the work we are doing, with nothing else on our physical desk; or, put another way, if our internet service goes down, we can practically panic because of how limited we are in what we can do.&lt;/p&gt;
&lt;p&gt;With Artificial Intelligence we are once again beginning to experience a paradigm shift in life and work. Generative models, and especially those that offer a chat interface, are beginning to be used by us instead of the search engine and the subsequent browsing of the sites it offers. These models already give us the information we are looking for, processed the way we ask for it, in the language we want, minimizing browsing time. All this seems to indicate that they will replace search engines and minimize our browsing of the web. But once again we run into the problem of losing references, even if we have information about the data used for training. New problems also appear, such as model &lt;strong&gt;hallucinations&lt;/strong&gt;, which are outputs that contain information that is not true but is generated in a credible way. So, while making use of all their advantages, we must not forget these problems and must be responsible in their use, just as we had to be before these models existed.&lt;/p&gt;
&lt;p&gt;As mentioned earlier, given the great performance of AI models in different areas, even surpassing humans in certain tasks, we have begun to feel the threat that AI will replace us in our jobs. That is already happening and will surely continue to happen in the coming years, but we must not fail to mention that it is also complementing many professionals in their tasks. As professionals, we must therefore analyze the landscape case by case, because most likely, in the short term, AI will not replace certain professionals; rather, professionals who use AI will replace those who do not. The dizzying pace of technological progress also forces us to redefine ourselves as professionals, leading us to think that a “lifelong career” will no longer exist, which in turn will have an impact on how we educate ourselves.&lt;/p&gt;
&lt;p&gt;Another aspect to keep in mind is that we have to start thinking about how to &lt;strong&gt;create and integrate new tools and processes&lt;/strong&gt; that will be powered by AI. We have to start thinking about collecting and managing data that will later be used to train them. We have to &lt;strong&gt;understand in greater depth how the models we use work&lt;/strong&gt;: what data they were trained on, their biases, their performance, their limitations. Rereading what I have written, this is what coordinators, managers, or leaders already had to do with their employees or colleagues; perhaps we have to think of ourselves as the bosses of our models (which now take the form of agents) and not simply as their customers.&lt;/p&gt;
&lt;p&gt;For example, some AI models today can make better diagnoses than most doctors &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-goh2024&quot; title=&quot;Goh et al. (2024). Large Language Model Influence on Diagnostic Reasoning: A Randomized Clinical Trial&quot; class=&quot;cita&quot; id=&quot;cita-goh2024&quot;&gt;33&lt;/a&gt;]&lt;/span&gt;, since they can process more information about a patient, find hidden patterns in their medical history or even correlations with data outside it, and have information from thousands or millions of other patients; we do not need to book an appointment and wait in a waiting room for more than an hour past the agreed time; they are updated more frequently with new information; and they do not get exhausted after a hard day’s work, nor are they overwhelmed by personal problems. So a doctor who uses AI will have to understand what types of patients were used for training, analyze whether their patient belongs to a similar population, understand whether there are biases in the model that could affect that particular diagnosis, understand metrics such as precision, recall, sensitivity, and specificity; and, finally, contribute the human side that, at least so far, AI does not convincingly provide. After all this, whom will people want to consult in the future?&lt;/p&gt;
&lt;p&gt;The era of &lt;strong&gt;virtual personal assistants&lt;/strong&gt; is approaching: AI models that, besides having been trained on terabytes of general information, are trained on our personal information; models that weigh our preferences, our temperament, and personality against general information; models that have specific information about our environment and our relationships. This will open up many debates, and some interesting ones may be those triggered by the following questions: Does the assistant know more about me than I do? Can the assistant make a better decision than I can, since it is not affected by my emotional state and has more reliable memories? Should I follow the assistant’s suggestion even if I believe otherwise? In the future, will I have been responsible for who I become, or will the assistant? Do I have to agree with a friend to do some activity, or do we let our assistants decide and then let us know?… Assistant, whom should I vote for in the next election? They might even choose our partners… although I believe that is already happening for many.&lt;/p&gt;
&lt;h2 id=&quot;social-impact&quot;&gt;Social impact&lt;/h2&gt;
&lt;p&gt;As a society, and even as a species, AI developments cut across our lives and will bring about profound cultural changes, as many other technological developments have done. But AI is bringing us something more than other developments, and many specialists claim that it is &lt;strong&gt;our last technological revolution&lt;/strong&gt; &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-good1966&quot; title=&quot;Good (1966). Speculations Concerning the First Ultraintelligent Machine&quot; class=&quot;cita&quot; id=&quot;cita-good1966&quot;&gt;34&lt;/a&gt;]&lt;/span&gt;, with special emphasis on the word “our”. This revolution will change the way we educate ourselves (what, how, where, and what for), it will modify the way we relate to each other (beyond what the internet and mobile devices have already changed), it will improve our health and life expectancy, and perhaps it will even modify us as a species when combined with bioengineering.&lt;/p&gt;
&lt;p&gt;We will have to rethink what our main activities as a society will be and immerse ourselves in the debates about what we want to preserve of our culture and idiosyncrasy, before they are transformed by AI without our noticing. Take the case of autonomous driving. Elon Musk, who invests heavily in the development of electric cars (Tesla) with autopilot (Autopilot), along with other specialists, claims that the accident rate drops significantly with AI-assisted driving &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-waymo-safety&quot; title=&quot;Waymo. Waymo Safety Impact&quot; class=&quot;cita&quot; id=&quot;cita-waymo-safety&quot;&gt;35&lt;/a&gt;]&lt;/span&gt;, and that accidents would be reduced practically to zero if everyone used this kind of driving. Elon proclaims that “in the distant future, [legislators] may outlaw driven cars because they’re too dangerous” &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-carrier2015&quot; title=&quot;Carrier Management (2015, March 20). Might Human Drivers Be Outlawed?&quot; class=&quot;cita&quot; id=&quot;cita-carrier2015&quot;&gt;36&lt;/a&gt;, &lt;a href=&quot;#ref-jalopnik2015&quot; title=&quot;Jalopnik (2015, March). Elon Musk Thinks Drivers Could Be Outlawed In The Future&quot; class=&quot;cita&quot; id=&quot;cita-jalopnik2015&quot;&gt;37&lt;/a&gt;]&lt;/span&gt;. Would this be a limitation of our freedom? Personally, I do not think so, and if it is indeed the way to achieve safer, more efficient, and cleaner transportation, then as a society we should embrace the idea. Are we thinking about this scenario as a society? Going a bit beyond this particular case, today we train autopilots to operate in scenarios shaped by and for humans; shouldn’t we start designing our cities to optimize the performance of autopilots? Shouldn’t AI be the one to lay out our future cities, considering, moreover, that AI models will be the ones driving?&lt;/p&gt;
&lt;p&gt;The outlook is encouraging when we see that the continuous improvement of AI models may be able to solve many of humanity’s problems that, perhaps because of our very nature and limitations, we have been unable to solve for decades or centuries. Problems such as these come to mind: world poverty, the existence of people who go hungry today and even more people who suffer from obesity, the ecological impact of our activities, climate change, mysteries of the universe, diseases that still cannot be cured or prevented, conflicts that in the 21st century are still resolved through wars. It is quite likely that we will need a superior intelligence to solve them, but will we be able to adopt the proposed solutions? We might not even realize that this intelligence has begun making decisions to that end in a way that leaves us no option of adopting them or not. Are we willing to adopt them for the common good, even if that forces us to change our culture, idiosyncrasy, beliefs, language, or our rights?&lt;/p&gt;
&lt;p&gt;What if the solution found by AI were that the human species is the root of all problems? Jonas Salk is credited with the idea that the elimination of insects from the planet would lead to environmental collapse within a few years, while the elimination of the human species would lead to a flourishing of the environment.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-salk&quot; id=&quot;user-content-fnref-salk&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; Beyond this hypothesis, it is undeniable that human beings are responsible for environmental degradation and a negative ecological impact through deforestation, pollution, soil and water contamination, and climate change, among others; and that removing them from the equation would simplify everything for nature &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-may2018&quot; title=&quot;May (2018, December 17). Would Human Extinction Be a Tragedy?&quot; class=&quot;cita&quot; id=&quot;cita-may2018&quot;&gt;38&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Clearly, this is a problem of defining what is valuable to preserve, or to weigh above other things. Is it more valuable to preserve our technology or art, or an animal species? Is it preferable to secure the prosperity of our species at the cost of human or animal lives in the present? These questions, and many more, are always formulated on the basis of our morality, of what we consider true, valuable, beautiful, or right (and, consequently, their opposites), so answering them ourselves will also lead to limited answers, even if those answers imply an attack on our own species. If a superior intelligence were able to answer them, it would surely be biased by our worldview, because, at least in the short term, it will be trained on information generated directly by us, and because we will restrict the answers that, from our moral or ethical standpoint, we consider incorrect &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-bai2022&quot; title=&quot;Bai et al. (2022). Constitutional AI: Harmlessness from AI Feedback&quot; class=&quot;cita&quot; id=&quot;cita-bai2022&quot;&gt;40&lt;/a&gt;, &lt;a href=&quot;#ref-openai-spec&quot; title=&quot;OpenAI. OpenAI Model Spec&quot; class=&quot;cita&quot; id=&quot;cita-openai-spec&quot;&gt;41&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;h2 id=&quot;corporate-impact&quot;&gt;Corporate impact&lt;/h2&gt;
&lt;p&gt;The development of AI over the last 15 years has been boosted by the increase in available information and computing capacity; but I am convinced that the main catalyst has been the fact that most developments were public, open (Open Sourced), as were the data used for training and validation. And the economic factor of obtaining sufficient infrastructure has not been a limitation, since with a budget on the order of USD 2,000 complex models could be trained; it can even be done for free using platforms such as &lt;strong&gt;Google Colab&lt;/strong&gt;, which offer substantial computing capacity free of charge for a limited time. By way of parallel, imagine if the development of the atomic bomb had been carried out by sharing the plans, procedures, and test results publicly, but somehow limiting access to plutonium or uranium: would fewer than 10 countries master that technology today? Would it represent a better balance of power? Would we still be on this planet?&lt;sup&gt;&lt;a href=&quot;#user-content-fn-chips&quot; id=&quot;user-content-fnref-chips&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;But beyond the democratization of the technology, business remains the main driving force. Many companies, such as &lt;em&gt;OpenAI&lt;/em&gt; or &lt;em&gt;DeepMind&lt;/em&gt;, keep the details of their developments to themselves &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-openai2023&quot; title=&quot;OpenAI (2023). GPT-4 Technical Report&quot; class=&quot;cita&quot; id=&quot;cita-openai2023&quot;&gt;43&lt;/a&gt;]&lt;/span&gt;, but claim to offer the greatest transparency regarding the data they use, their methods, and their models. Others, such as &lt;em&gt;Meta&lt;/em&gt;, whose core business is not AI, open up their developments, presumably because this lets them accelerate them and channel them into the applications that do form the heart of their business model. Today the flagship models of &lt;em&gt;OpenAI&lt;/em&gt;, &lt;em&gt;Anthropic&lt;/em&gt;, or &lt;em&gt;Google&lt;/em&gt; are not open, while many Chinese models, such as &lt;em&gt;DeepSeek&lt;/em&gt;, &lt;em&gt;Kimi&lt;/em&gt;, or &lt;em&gt;Qwen&lt;/em&gt;, can be downloaded, even with a commercial license (with some limitations). Beyond a certain model scale there is an economic barrier, since developing and training this type of model requires teams of highly skilled scientists and engineers and infrastructure costing more than tens or hundreds of millions of dollars &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-cottier2024&quot; title=&quot;Cottier et al. (2024). The rising costs of training frontier AI models&quot; class=&quot;cita&quot; id=&quot;cita-cottier2024&quot;&gt;44&lt;/a&gt;]&lt;/span&gt;. Returning to the parallel with the atomic bomb, how many companies, corporations, or countries are capable of training this type of model?&lt;/p&gt;
&lt;p&gt;Many large and medium-sized companies already have teams dedicated exclusively to AI, both for developing new products and for tools or services that enhance their current services or products. Beyond the AI boom, a company that does not consider developing with AI will surely be at a competitive disadvantage against those that do, just as happens to individual professionals. Combining the business perspective with the professional perspective of each employee, it is necessary to find ways to use AI to enhance what each company offers. This means not only that a company must decide to form an AI group within the company or partner strategically with a company that already masters the technology, but also that employees must be open to incorporating these technologies into their specific tasks; and I do not mean using a particular model to do their tasks, but rather thinking about how to generate and manage data that enable future developments, understanding the trade-offs and applicability criteria, or being able to have a eureka moment that leads to a new application.&lt;/p&gt;
&lt;h2 id=&quot;government-impact&quot;&gt;Government impact&lt;/h2&gt;
&lt;p&gt;Governments, and here I am referring to governments as the political figure representing the state (people, institutions, and companies) and not as political groups looking after their own interests, face a complex challenge with this technology, perhaps a much greater challenge than individuals or companies.&lt;/p&gt;
&lt;p&gt;As AI cuts across people’s lives and proves to be an influential factor in shaping current and future societies, it requires governments to address issues related to impact analysis, monitoring and regulation of applications, incentives for forming teams and lines of development, policies for data generation, management, and traceability, policies on the use and traceability of models, certification methods, and ethical review &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-okerlund2022&quot; title=&quot;Okerlund et al. (2022). What&amp;#x27;s in the Chatterbox? Large Language Models, Why They Matter, and What We Should Do About Them&quot; class=&quot;cita&quot; id=&quot;cita-okerlund2022&quot;&gt;45&lt;/a&gt;]&lt;/span&gt;. Personally, I do not believe all these activities apply to the entire universe of models and applications, but they do apply to those closely linked to the public interest; many of them are not necessary, or at least not with the same degree of thoroughness or depth, when it comes to private models.&lt;/p&gt;
&lt;p&gt;An initial reaction in several countries has been to adopt measures banning some LLMs (Large Language Models), mainly on the grounds of their impact on privacy and education. Clearly, the use of these models by students and teachers has a profound impact on today’s education. But I am far from believing that this kind of policy will provide a solution; it might even end up making things worse. These models or applications are already a tool for study and work, just as a calculator, a computer, or a mobile phone are. Once we understand this, we have to devote ourselves to redefining study methods; we cannot keep putting off rethinking education.&lt;/p&gt;
&lt;p&gt;Along the same lines, many organizations, scientists, and influential people have spoken out against these models and have even called, through an open letter, for AI development to be paused for at least six months &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-fli2023&quot; title=&quot;Future of Life Institute (2023, March 22). Pause Giant AI Experiments: An Open Letter&quot; class=&quot;cita&quot; id=&quot;cita-fli2023&quot;&gt;46&lt;/a&gt;]&lt;/span&gt;. Among them was Elon Musk, who was one of the major investors in &lt;em&gt;OpenAI&lt;/em&gt; (the company that develops &lt;em&gt;GPT&lt;/em&gt;) but who now calls it one of his mistakes, and who nevertheless keeps investing in AI in other areas, for example in &lt;em&gt;Tesla Autopilot&lt;/em&gt; or in founding &lt;strong&gt;xAI&lt;/strong&gt; months later. Frankly, I think this kind of measure is somewhat naïve; it is like &lt;strong&gt;trying to stop the wind with your hand&lt;/strong&gt;. In history there are no cases of this magnitude that have stopped technological progress, except perhaps in extremely sensitive matters such as human cloning (although, one way or another, progress continues). One could even say that it is in our nature to always move forward. The “wind” does not seem about to stop; we have to make the most of it and keep it from turning into a tornado.&lt;/p&gt;
&lt;p&gt;I therefore believe that governments should not limit themselves to monitoring and censoring; they must take an active role in the development of the technology and be one more vector driving development in a direction where the interests and rights of people (and I do not mean only majorities or investors) are protected, where we do not violate ethics, and where solutions, not problems, are built. I think that if a government decides today to take part in development, it is protecting its people’s culture, defending its minorities, exercising sovereignty, and not losing competitiveness. This would apply to models intended for use in educational settings, by public institutions, and to those meant to be freely available (perhaps free of charge).&lt;/p&gt;
&lt;p&gt;Governments that align with this perspective should, in the short term, see to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;defining what will be regulated and monitored;&lt;/li&gt;
&lt;li&gt;auditing and ensuring the traceability and transparency of datasets;&lt;/li&gt;
&lt;li&gt;diversifying the information in datasets, strongly seeking the representation of minorities, marginalized communities, and topics related to each culture to be safeguarded;&lt;/li&gt;
&lt;li&gt;defining data privacy and intellectual property policies;&lt;/li&gt;
&lt;li&gt;creating certification bodies and procedures according to the application (especially in sensitive areas such as health and education);&lt;/li&gt;
&lt;li&gt;ensuring universal access to these models;&lt;/li&gt;
&lt;li&gt;establishing policies for environmental care and energy use related to the infrastructure these models require;&lt;/li&gt;
&lt;li&gt;implementing the infrastructure needed for data storage, training, and use of models within their territory;&lt;/li&gt;
&lt;li&gt;legislating liability for actions or events arising from the use of these models;&lt;/li&gt;
&lt;li&gt;modifying the education system to take into account the integration of these technologies and the vision of work in the not-too-distant future.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;horizon&quot;&gt;Horizon&lt;/h2&gt;
&lt;p&gt;Throughout the text, the future seems to oscillate between the utopian and the dystopian. No one seems clear about which scenario is more likely, but there is an accepted idea that the technology, despite its dizzying progress, is still in its infancy; and that it is now that the right decisions, without major impact, are still within our reach.&lt;/p&gt;
&lt;p&gt;From where I stand, I believe that the open and collaborative development of AI must be sustained, leaving the profit-making side to the applications that use it. I believe that as individuals, as a society, as companies, and as governments we are responsible for the development of AI. We have to embrace change and, although today we teach machines, in the near future we will end up learning from them.&lt;/p&gt;
&lt;p&gt;It is likely that we are finally facing the technology that will solve those great problems we have been dragging along as a species. Perhaps in the not-too-distant future the concept of work will be different, with few hours, in tasks we cannot imagine today, where we will have to take care of enjoying our leisure and will have a universal income. AI may bring us the solution to diseases, to the care of our planet, and to inequalities entrenched in humanity. There is also the possibility that we decide to live more on a virtual plane (metaverse or multiverse) than on a physical one, and that we have to choose between the &lt;em&gt;red pill&lt;/em&gt; and the &lt;em&gt;blue pill&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Perhaps this is the end of the Anthropocene, that we stop being the dominant species on the planet, and that it is time for us to devote ourselves to being more human than ever. Perhaps these “crows” we are raising are far from pecking out our eyes and will be the ones that finally allow us to see clearly, as long as we do not stop looking.&lt;/p&gt;
&lt;p&gt;Science fiction has played with this superior intelligence, such as &lt;em&gt;HAL 9000&lt;/em&gt; (&lt;em&gt;2001: A Space Odyssey&lt;/em&gt;), &lt;em&gt;Skynet&lt;/em&gt; (&lt;em&gt;Terminator&lt;/em&gt;), or &lt;em&gt;The Matrix&lt;/em&gt;. Among them I would like to bring up &lt;strong&gt;Multivac&lt;/strong&gt;, the computer that appears in several of &lt;em&gt;Isaac Asimov&lt;/em&gt;’s stories, but particularly in the story “The Last Question” &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-asimov1956&quot; title=&quot;Asimov (1956, November). The Last Question&quot; class=&quot;cita&quot; id=&quot;cita-asimov1956&quot;&gt;47&lt;/a&gt;]&lt;/span&gt;. In this story, &lt;em&gt;Multivac&lt;/em&gt; is asked whether it is possible to reverse the inevitable end of the universe, whether the universe could be used again or entropy reversed, to which &lt;em&gt;Multivac&lt;/em&gt; replies: “&lt;em&gt;INSUFFICIENT DATA FOR MEANINGFUL ANSWER&lt;/em&gt;”. The years went by, hundreds, thousands, millions, and Multivac evolved into &lt;em&gt;Planetary AC&lt;/em&gt;, &lt;em&gt;Galactic AC&lt;/em&gt;, &lt;em&gt;Universal AC&lt;/em&gt;, and &lt;em&gt;Cosmic AC&lt;/em&gt;, without being able to answer that question. Humans had long since ceased to exist, and life forms were only forms of energy without matter. Finally, this computer became &lt;em&gt;AC&lt;/em&gt; when all minds fused into it, and when no star remained alive and all was darkness, it was able to answer the question. (It would never have occurred to me to write the answer here and spoil your chance to enjoy the whole story.)&lt;/p&gt;
&lt;p&gt;Let us stop to consider that perhaps we are not conceiving the end of our species, but an evolution.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;notas&quot;&gt;&lt;h2 class=&quot;notas-titulo&quot; id=&quot;footnote-label&quot;&gt;Notes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-neurona&quot;&gt;
&lt;p&gt;A single pyramidal neuron is equivalent, in computational capacity, to a deep neural network of 5 to 8 layers &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-beniaguev2021&quot; title=&quot;Beniaguev et al. (2021). Single cortical neurons as deep artificial neural networks&quot; class=&quot;cita&quot; id=&quot;cita-beniaguev2021&quot;&gt;9&lt;/a&gt;]&lt;/span&gt;: structure matters as much as quantity.&lt;a href=&quot;#user-content-fnref-neurona&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-agentes&quot;&gt;
&lt;p&gt;There are already agents connected to tools and applications through open standards &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-anthropic2024&quot; title=&quot;Anthropic (2024, November 25). Introducing the Model Context Protocol&quot; class=&quot;cita&quot; id=&quot;cita-anthropic2024&quot;&gt;21&lt;/a&gt;]&lt;/span&gt;, and in 2025 OpenAI had to roll back a version of GPT-4o that, by giving too much weight to users’ short-term feedback, had become excessively sycophantic &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-openai2025&quot; title=&quot;OpenAI (2025, April 29). Sycophancy in GPT-4o: what happened and what we&amp;#x27;re doing about it&quot; class=&quot;cita&quot; id=&quot;cita-openai2025&quot;&gt;22&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-agentes&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-eeg&quot;&gt;
&lt;p&gt;A preliminary study using electroencephalography found the weakest brain connectivity in people who wrote essays with the help of a language model, below those who used a search engine or wrote without assistance &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-kosmyna2025&quot; title=&quot;Kosmyna et al. (2025). Your Brain on ChatGPT: Accumulation of Cognitive Debt when Using an AI Assistant for Essay Writing Task&quot; class=&quot;cita&quot; id=&quot;cita-kosmyna2025&quot;&gt;23&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-eeg&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-nobel&quot;&gt;
&lt;p&gt;AlphaFold earned Demis Hassabis and John Jumper the 2024 Nobel Prize in Chemistry &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-nobel-chemistry2024&quot; title=&quot;The Nobel Prize (2024). The Nobel Prize in Chemistry 2024&quot; class=&quot;cita&quot; id=&quot;cita-nobel-chemistry2024&quot;&gt;25&lt;/a&gt;]&lt;/span&gt;; that same year, the Nobel Prize in Physics went to John Hopfield and Geoffrey Hinton for the foundations of machine learning with neural networks &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-nobel-physics2024&quot; title=&quot;The Nobel Prize (2024). The Nobel Prize in Physics 2024&quot; class=&quot;cita&quot; id=&quot;cita-nobel-physics2024&quot;&gt;26&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-nobel&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-energia&quot;&gt;
&lt;p&gt;Even so, total consumption keeps growing: the International Energy Agency estimates that data centers consumed 415 TWh in 2024 and projects some 945 TWh for 2030 &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-iea2025&quot; title=&quot;International Energy Agency (2025). Energy and AI&quot; class=&quot;cita&quot; id=&quot;cita-iea2025&quot;&gt;30&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-energia&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-stackoverflow&quot;&gt;
&lt;p&gt;The 54% figure circulated without a solid source: Stack Overflow reported a traffic drop of around 5% in 2023 &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-stackoverflow2023&quot; title=&quot;Stack Overflow (2023, August 8). Insights into Stack Overflow&amp;#x27;s traffic&quot; class=&quot;cita&quot; id=&quot;cita-stackoverflow2023&quot;&gt;31&lt;/a&gt;]&lt;/span&gt;. The later decline was indeed deep: in 2025, monthly questions fell back to 2009 levels &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-orosz2025&quot; title=&quot;Orosz (2025, May 15). Stack overflow is almost dead&quot; class=&quot;cita&quot; id=&quot;cita-orosz2025&quot;&gt;32&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-stackoverflow&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-salk&quot;&gt;
&lt;p&gt;The attribution to Salk has no verified primary source; the vital role of insects and other invertebrates, however, was argued by E. O. Wilson &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-wilson1987&quot; title=&quot;Wilson (1987). The Little Things That Run the World (The Importance and Conservation of Invertebrates)&quot; class=&quot;cita&quot; id=&quot;cita-wilson1987&quot;&gt;39&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-salk&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-chips&quot;&gt;
&lt;p&gt;Something similar is happening today: many models publish their weights, but access to advanced chips is restricted, and the United States has limited their export to China since 2022 &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-bis2022&quot; title=&quot;Bureau of Industry and Security (2022, October 13). Implementation of Additional Export Controls: Certain Advanced Computing and Semiconductor Manufacturing Items; Supercomputer and Semiconductor End Use; Entity List Modification&quot; class=&quot;cita&quot; id=&quot;cita-bis2022&quot;&gt;42&lt;/a&gt;]&lt;/span&gt;.&lt;a href=&quot;#user-content-fnref-chips&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;&lt;section class=&quot;referencias&quot; aria-labelledby=&quot;referencias&quot;&gt;&lt;h2 id=&quot;referencias&quot; class=&quot;referencias-titulo&quot;&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li id=&quot;ref-telam2021&quot; value=&quot;1&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Télam (2021, September 28). &lt;i&gt;La historia de los refranes: «Cría cuervos y te sacarán los ojos» [The story behind proverbs: “Raise crows and they will peck out your eyes”]&lt;/i&gt;. Archived copy, Internet Archive. &lt;a href=&quot;https://web.archive.org/web/20231208014900/https://www.telam.com.ar/notas/202109/569881-paredero-historia-refranes-cria-cuervos.html&quot;&gt;https://web.archive.org/web/20231208014900/https://www.telam.com.ar/notas/202109/569881-paredero-historia-refranes-cria-cuervos.html&lt;/a&gt; &lt;a href=&quot;#cita-telam2021&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 1&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-emery2004&quot; value=&quot;2&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[2]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Emery, N. J., &amp;#x26; Clayton, N. S. (2004). The mentality of crows: convergent evolution of intelligence in corvids and apes. &lt;i&gt;Science&lt;/i&gt;&lt;i&gt;, 306&lt;/i&gt;(5703), 1903–1907. &lt;a href=&quot;https://doi.org/10.1126/science.1098410&quot;&gt;https://doi.org/10.1126/science.1098410&lt;/a&gt; &lt;a href=&quot;#cita-emery2004&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 2&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-prior2008&quot; value=&quot;3&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[3]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Prior, H., Schwarz, A., &amp;#x26; Güntürkün, O. (2008). Mirror-induced behavior in the magpie (Pica pica): evidence of self-recognition. &lt;i&gt;PLoS Biology&lt;/i&gt;&lt;i&gt;, 6&lt;/i&gt;(8), e202. &lt;a href=&quot;https://doi.org/10.1371/journal.pbio.0060202&quot;&gt;https://doi.org/10.1371/journal.pbio.0060202&lt;/a&gt; &lt;a href=&quot;#cita-prior2008&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 3&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-wikipedia-intelligence&quot; value=&quot;4&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[4]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Wikipedia (n.d.). &lt;i&gt;Intelligence&lt;/i&gt;. Accessed November 2, 2026. &lt;a href=&quot;https://en.wikipedia.org/wiki/Intelligence&quot;&gt;https://en.wikipedia.org/wiki/Intelligence&lt;/a&gt; &lt;a href=&quot;#cita-wikipedia-intelligence&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 4&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-gardner1983&quot; value=&quot;5&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[5]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Gardner, H. (1983). &lt;i&gt;Frames of Mind: The Theory of Multiple Intelligences&lt;/i&gt;. Basic Books.  &lt;a href=&quot;#cita-gardner1983&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 5&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-mensa-iq&quot; value=&quot;6&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[6]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Mensa International (n.d.). &lt;i&gt;Getting your IQ tested: FAQs&lt;/i&gt;. Accessed November 2, 2026. &lt;a href=&quot;https://www.mensa.org/getting-your-iq-tested-faqs/&quot;&gt;https://www.mensa.org/getting-your-iq-tested-faqs/&lt;/a&gt; &lt;a href=&quot;#cita-mensa-iq&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 6&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-kaplan2019&quot; value=&quot;7&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[7]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Kaplan, A., &amp;#x26; Haenlein, M. (2019). Siri, Siri, in my hand: Who&apos;s the fairest in the land? On the interpretations, illustrations, and implications of artificial intelligence. &lt;i&gt;Business Horizons&lt;/i&gt;&lt;i&gt;, 62&lt;/i&gt;(1), 15–25. &lt;a href=&quot;https://doi.org/10.1016/j.bushor.2018.08.004&quot;&gt;https://doi.org/10.1016/j.bushor.2018.08.004&lt;/a&gt; &lt;a href=&quot;#cita-kaplan2019&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 7&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-olkowicz2016&quot; value=&quot;8&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[8]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Olkowicz, S., Kocourek, M., Lučan, R. K., Porteš, M., Fitch, W. T., Herculano-Houzel, S., &amp;#x26; Němec, P. (2016). Birds have primate-like numbers of neurons in the forebrain. &lt;i&gt;Proceedings of the National Academy of Sciences&lt;/i&gt;&lt;i&gt;, 113&lt;/i&gt;(26), 7255–7260. &lt;a href=&quot;https://doi.org/10.1073/pnas.1517131113&quot;&gt;https://doi.org/10.1073/pnas.1517131113&lt;/a&gt; &lt;a href=&quot;#cita-olkowicz2016&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 8&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-beniaguev2021&quot; value=&quot;9&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[9]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Beniaguev, D., Segev, I., &amp;#x26; London, M. (2021). Single cortical neurons as deep artificial neural networks. &lt;i&gt;Neuron&lt;/i&gt;&lt;i&gt;, 109&lt;/i&gt;(17), 2727–2739. &lt;a href=&quot;https://doi.org/10.1016/j.neuron.2021.07.002&quot;&gt;https://doi.org/10.1016/j.neuron.2021.07.002&lt;/a&gt; &lt;a href=&quot;#cita-beniaguev2021&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 9&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-herculano2009&quot; value=&quot;10&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[10]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Herculano-Houzel, S. (2009). The human brain in numbers: a linearly scaled-up primate brain. &lt;i&gt;Frontiers in Human Neuroscience&lt;/i&gt;&lt;i&gt;, 3&lt;/i&gt;, 31. &lt;a href=&quot;https://doi.org/10.3389/neuro.09.031.2009&quot;&gt;https://doi.org/10.3389/neuro.09.031.2009&lt;/a&gt; &lt;a href=&quot;#cita-herculano2009&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 10&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-aiimpacts-brain&quot; value=&quot;11&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[11]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;AI Impacts (n.d.). &lt;i&gt;Scale of the human brain&lt;/i&gt;. Accessed November 2, 2026. &lt;a href=&quot;https://aiimpacts.org/scale-of-the-human-brain/&quot;&gt;https://aiimpacts.org/scale-of-the-human-brain/&lt;/a&gt; &lt;a href=&quot;#cita-aiimpacts-brain&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 11&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-wikipedia-neurons&quot; value=&quot;12&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[12]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Wikipedia (n.d.). &lt;i&gt;List of animals by number of neurons&lt;/i&gt;. Accessed November 2, 2026. &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_animals_by_number_of_neurons&quot;&gt;https://en.wikipedia.org/wiki/List_of_animals_by_number_of_neurons&lt;/a&gt; &lt;a href=&quot;#cita-wikipedia-neurons&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 12&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-hubel1962&quot; value=&quot;13&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[13]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Hubel, D. H., &amp;#x26; Wiesel, T. N. (1962). Receptive fields, binocular interaction and functional architecture in the cat&apos;s visual cortex. &lt;i&gt;The Journal of Physiology&lt;/i&gt;&lt;i&gt;, 160&lt;/i&gt;(1), 106–154. &lt;a href=&quot;https://doi.org/10.1113/jphysiol.1962.sp006837&quot;&gt;https://doi.org/10.1113/jphysiol.1962.sp006837&lt;/a&gt; &lt;a href=&quot;#cita-hubel1962&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 13&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-yamins2016&quot; value=&quot;14&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[14]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Yamins, D. L. K., &amp;#x26; DiCarlo, J. J. (2016). Using goal-driven deep learning models to understand sensory cortex. &lt;i&gt;Nature Neuroscience&lt;/i&gt;&lt;i&gt;, 19&lt;/i&gt;(3), 356–365. &lt;a href=&quot;https://doi.org/10.1038/nn.4244&quot;&gt;https://doi.org/10.1038/nn.4244&lt;/a&gt; &lt;a href=&quot;#cita-yamins2016&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 14&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-deepseek2025&quot; value=&quot;15&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[15]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;DeepSeek-AI (2025). &lt;i&gt;DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning&lt;/i&gt; (arXiv:2501.12948). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2501.12948&quot;&gt;https://arxiv.org/abs/2501.12948&lt;/a&gt; &lt;a href=&quot;#cita-deepseek2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 15&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-deepseek-repo&quot; value=&quot;16&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[16]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;DeepSeek-AI (2025). &lt;i&gt;DeepSeek-R1&lt;/i&gt;. GitHub. Official repository, with the comparison of the distilled models with GPT-4o. &lt;a href=&quot;https://github.com/deepseek-ai/DeepSeek-R1&quot;&gt;https://github.com/deepseek-ai/DeepSeek-R1&lt;/a&gt; &lt;a href=&quot;#cita-deepseek-repo&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 16&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-vaswani2017&quot; value=&quot;17&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[17]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., &amp;#x26; Polosukhin, I. (2017). Attention Is All You Need. &lt;i&gt;Advances in Neural Information Processing Systems&lt;/i&gt;&lt;i&gt;, 30&lt;/i&gt;. &lt;a href=&quot;https://arxiv.org/abs/1706.03762&quot;&gt;https://arxiv.org/abs/1706.03762&lt;/a&gt; &lt;a href=&quot;#cita-vaswani2017&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 17&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-jones2025&quot; value=&quot;18&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[18]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Jones, C. R., &amp;#x26; Bergen, B. K. (2025). &lt;i&gt;Large Language Models Pass the Turing Test&lt;/i&gt; (arXiv:2503.23674). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2503.23674&quot;&gt;https://arxiv.org/abs/2503.23674&lt;/a&gt; &lt;a href=&quot;#cita-jones2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 18&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-turing1950&quot; value=&quot;19&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[19]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Turing, A. M. (1950). Computing Machinery and Intelligence. &lt;i&gt;Mind&lt;/i&gt;&lt;i&gt;, 59&lt;/i&gt;(236), 433–460. &lt;a href=&quot;https://doi.org/10.1093/mind/LIX.236.433&quot;&gt;https://doi.org/10.1093/mind/LIX.236.433&lt;/a&gt; &lt;a href=&quot;#cita-turing1950&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 19&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-luong2025&quot; value=&quot;20&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[20]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Luong, T., &amp;#x26; Lockhart, E. (2025, July 21). &lt;i&gt;Advanced version of Gemini with Deep Think officially achieves gold-medal standard at the International Mathematical Olympiad&lt;/i&gt;. Google DeepMind. &lt;a href=&quot;https://deepmind.google/blog/advanced-version-of-gemini-with-deep-think-officially-achieves-gold-medal-standard-at-the-international-mathematical-olympiad/&quot;&gt;https://deepmind.google/blog/advanced-version-of-gemini-with-deep-think-officially-achieves-gold-medal-standard-at-the-international-mathematical-olympiad/&lt;/a&gt; &lt;a href=&quot;#cita-luong2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 20&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-anthropic2024&quot; value=&quot;21&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[21]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Anthropic (2024, November 25). &lt;i&gt;Introducing the Model Context Protocol&lt;/i&gt;. &lt;a href=&quot;https://www.anthropic.com/news/model-context-protocol&quot;&gt;https://www.anthropic.com/news/model-context-protocol&lt;/a&gt; &lt;a href=&quot;#cita-anthropic2024&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 21&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-openai2025&quot; value=&quot;22&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[22]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;OpenAI (2025, April 29). &lt;i&gt;Sycophancy in GPT-4o: what happened and what we&apos;re doing about it&lt;/i&gt;. &lt;a href=&quot;https://openai.com/index/sycophancy-in-gpt-4o/&quot;&gt;https://openai.com/index/sycophancy-in-gpt-4o/&lt;/a&gt; &lt;a href=&quot;#cita-openai2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 22&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-kosmyna2025&quot; value=&quot;23&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[23]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Kosmyna, N., Hauptmann, E., Yuan, Y. T., Situ, J., Liao, X.-H., Beresnitzky, A. V., Braunstein, I., &amp;#x26; Maes, P. (2025). &lt;i&gt;Your Brain on ChatGPT: Accumulation of Cognitive Debt when Using an AI Assistant for Essay Writing Task&lt;/i&gt; (arXiv:2506.08872). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2506.08872&quot;&gt;https://arxiv.org/abs/2506.08872&lt;/a&gt; &lt;a href=&quot;#cita-kosmyna2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 23&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-jumper2021&quot; value=&quot;24&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[24]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Jumper, J. et al. (2021). Highly accurate protein structure prediction with AlphaFold. &lt;i&gt;Nature&lt;/i&gt;&lt;i&gt;, 596&lt;/i&gt;, 583–589. &lt;a href=&quot;https://doi.org/10.1038/s41586-021-03819-2&quot;&gt;https://doi.org/10.1038/s41586-021-03819-2&lt;/a&gt; &lt;a href=&quot;#cita-jumper2021&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 24&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-nobel-chemistry2024&quot; value=&quot;25&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[25]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;The Nobel Prize (2024). &lt;i&gt;The Nobel Prize in Chemistry 2024&lt;/i&gt;. &lt;a href=&quot;https://www.nobelprize.org/prizes/chemistry/2024/summary/&quot;&gt;https://www.nobelprize.org/prizes/chemistry/2024/summary/&lt;/a&gt; &lt;a href=&quot;#cita-nobel-chemistry2024&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 25&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-nobel-physics2024&quot; value=&quot;26&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[26]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;The Nobel Prize (2024). &lt;i&gt;The Nobel Prize in Physics 2024&lt;/i&gt;. &lt;a href=&quot;https://www.nobelprize.org/prizes/physics/2024/summary/&quot;&gt;https://www.nobelprize.org/prizes/physics/2024/summary/&lt;/a&gt; &lt;a href=&quot;#cita-nobel-physics2024&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 26&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-fawzi2022&quot; value=&quot;27&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[27]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Fawzi, A. et al. (2022). Discovering faster matrix multiplication algorithms with reinforcement learning. &lt;i&gt;Nature&lt;/i&gt;&lt;i&gt;, 610&lt;/i&gt;, 47–53. &lt;a href=&quot;https://doi.org/10.1038/s41586-022-05172-4&quot;&gt;https://doi.org/10.1038/s41586-022-05172-4&lt;/a&gt; &lt;a href=&quot;#cita-fawzi2022&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 27&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-deepmind2025&quot; value=&quot;28&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[28]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Google DeepMind (2025, May 14). &lt;i&gt;AlphaEvolve: A Gemini-powered coding agent for designing advanced algorithms&lt;/i&gt;. &lt;a href=&quot;https://deepmind.google/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/&quot;&gt;https://deepmind.google/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/&lt;/a&gt; &lt;a href=&quot;#cita-deepmind2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 28&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-deepmind2022&quot; value=&quot;29&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[29]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;DeepMind (2022, February 11). &lt;i&gt;MuZero&apos;s first step from research into the real world&lt;/i&gt;. &lt;a href=&quot;https://deepmind.google/blog/muzeros-first-step-from-research-into-the-real-world/&quot;&gt;https://deepmind.google/blog/muzeros-first-step-from-research-into-the-real-world/&lt;/a&gt; &lt;a href=&quot;#cita-deepmind2022&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 29&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-iea2025&quot; value=&quot;30&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[30]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;International Energy Agency (2025). &lt;i&gt;Energy and AI&lt;/i&gt;. Executive summary. &lt;a href=&quot;https://www.iea.org/reports/energy-and-ai/executive-summary&quot;&gt;https://www.iea.org/reports/energy-and-ai/executive-summary&lt;/a&gt; &lt;a href=&quot;#cita-iea2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 30&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-stackoverflow2023&quot; value=&quot;31&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[31]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Stack Overflow (2023, August 8). &lt;i&gt;Insights into Stack Overflow&apos;s traffic&lt;/i&gt;. &lt;a href=&quot;https://stackoverflow.blog/2023/08/08/insights-into-stack-overflows-traffic/&quot;&gt;https://stackoverflow.blog/2023/08/08/insights-into-stack-overflows-traffic/&lt;/a&gt; &lt;a href=&quot;#cita-stackoverflow2023&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 31&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-orosz2025&quot; value=&quot;32&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[32]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Orosz, G. (2025, May 15). &lt;i&gt;Stack overflow is almost dead&lt;/i&gt;. The Pragmatic Engineer. &lt;a href=&quot;https://blog.pragmaticengineer.com/stack-overflow-is-almost-dead/&quot;&gt;https://blog.pragmaticengineer.com/stack-overflow-is-almost-dead/&lt;/a&gt; &lt;a href=&quot;#cita-orosz2025&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 32&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-goh2024&quot; value=&quot;33&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[33]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Goh, E. et al. (2024). Large Language Model Influence on Diagnostic Reasoning: A Randomized Clinical Trial. &lt;i&gt;JAMA Network Open&lt;/i&gt;&lt;i&gt;, 7&lt;/i&gt;(10), e2440969. &lt;a href=&quot;https://doi.org/10.1001/jamanetworkopen.2024.40969&quot;&gt;https://doi.org/10.1001/jamanetworkopen.2024.40969&lt;/a&gt; &lt;a href=&quot;#cita-goh2024&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 33&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-good1966&quot; value=&quot;34&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[34]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Good, I. J. (1966). Speculations Concerning the First Ultraintelligent Machine. &lt;i&gt;Advances in Computers&lt;/i&gt;&lt;i&gt;, 6&lt;/i&gt;, 31–88. &lt;a href=&quot;https://doi.org/10.1016/S0065-2458(08)60418-0&quot;&gt;https://doi.org/10.1016/S0065-2458(08)60418-0&lt;/a&gt; &lt;a href=&quot;#cita-good1966&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 34&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-waymo-safety&quot; value=&quot;35&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[35]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Waymo (n.d.). &lt;i&gt;Waymo Safety Impact&lt;/i&gt;. Data through June 2026; accessed November 2, 2026. &lt;a href=&quot;https://waymo.com/safety/impact/&quot;&gt;https://waymo.com/safety/impact/&lt;/a&gt; &lt;a href=&quot;#cita-waymo-safety&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 35&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-carrier2015&quot; value=&quot;36&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[36]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Carrier Management (2015, March 20). &lt;i&gt;Might Human Drivers Be Outlawed?&lt;/i&gt; &lt;a href=&quot;https://www.carriermanagement.com/news/2015/03/20/137075.htm&quot;&gt;https://www.carriermanagement.com/news/2015/03/20/137075.htm&lt;/a&gt; &lt;a href=&quot;#cita-carrier2015&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 36&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-jalopnik2015&quot; value=&quot;37&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[37]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Jalopnik (2015, March). &lt;i&gt;Elon Musk Thinks Drivers Could Be Outlawed In The Future&lt;/i&gt;. &lt;a href=&quot;https://www.jalopnik.com/elon-musks-thinks-drivers-could-be-outlawed-in-the-fut-1691976679/&quot;&gt;https://www.jalopnik.com/elon-musks-thinks-drivers-could-be-outlawed-in-the-fut-1691976679/&lt;/a&gt; &lt;a href=&quot;#cita-jalopnik2015&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 37&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-may2018&quot; value=&quot;38&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[38]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;May, T. (2018, December 17). Would Human Extinction Be a Tragedy? &lt;i&gt;The New York Times&lt;/i&gt;. &lt;a href=&quot;https://www.nytimes.com/2018/12/17/opinion/human-extinction-climate-change.html&quot;&gt;https://www.nytimes.com/2018/12/17/opinion/human-extinction-climate-change.html&lt;/a&gt; &lt;a href=&quot;#cita-may2018&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 38&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-wilson1987&quot; value=&quot;39&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[39]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Wilson, E. O. (1987). The Little Things That Run the World (The Importance and Conservation of Invertebrates). &lt;i&gt;Conservation Biology&lt;/i&gt;&lt;i&gt;, 1&lt;/i&gt;(4), 344–346. &lt;a href=&quot;https://doi.org/10.1111/j.1523-1739.1987.tb00055.x&quot;&gt;https://doi.org/10.1111/j.1523-1739.1987.tb00055.x&lt;/a&gt; &lt;a href=&quot;#cita-wilson1987&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 39&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-bai2022&quot; value=&quot;40&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[40]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Bai, Y. et al. (2022). &lt;i&gt;Constitutional AI: Harmlessness from AI Feedback&lt;/i&gt; (arXiv:2212.08073). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2212.08073&quot;&gt;https://arxiv.org/abs/2212.08073&lt;/a&gt; &lt;a href=&quot;#cita-bai2022&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 40&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-openai-spec&quot; value=&quot;41&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[41]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;OpenAI (n.d.). &lt;i&gt;OpenAI Model Spec&lt;/i&gt;. Accessed November 2, 2026. &lt;a href=&quot;https://model-spec.openai.com/&quot;&gt;https://model-spec.openai.com/&lt;/a&gt; &lt;a href=&quot;#cita-openai-spec&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 41&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-bis2022&quot; value=&quot;42&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[42]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Bureau of Industry and Security (2022, October 13). Implementation of Additional Export Controls: Certain Advanced Computing and Semiconductor Manufacturing Items; Supercomputer and Semiconductor End Use; Entity List Modification. &lt;i&gt;Federal Register&lt;/i&gt;. Document 2022-21658. &lt;a href=&quot;https://www.federalregister.gov/documents/2022/10/13/2022-21658/implementation-of-additional-export-controls-certain-advanced-computing-and-semiconductor&quot;&gt;https://www.federalregister.gov/documents/2022/10/13/2022-21658/implementation-of-additional-export-controls-certain-advanced-computing-and-semiconductor&lt;/a&gt; &lt;a href=&quot;#cita-bis2022&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 42&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-openai2023&quot; value=&quot;43&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[43]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;OpenAI (2023). &lt;i&gt;GPT-4 Technical Report&lt;/i&gt; (arXiv:2303.08774). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2303.08774&quot;&gt;https://arxiv.org/abs/2303.08774&lt;/a&gt; &lt;a href=&quot;#cita-openai2023&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 43&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-cottier2024&quot; value=&quot;44&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[44]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Cottier, B., Rahman, R., Fattorini, L., Maslej, N., Besiroglu, T., &amp;#x26; Owen, D. (2024). &lt;i&gt;The rising costs of training frontier AI models&lt;/i&gt; (arXiv:2405.21015). arXiv. &lt;a href=&quot;https://arxiv.org/abs/2405.21015&quot;&gt;https://arxiv.org/abs/2405.21015&lt;/a&gt; &lt;a href=&quot;#cita-cottier2024&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 44&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-okerlund2022&quot; value=&quot;45&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[45]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Okerlund, J., Klasky, E., Middha, A., Kim, S., Rosenfeld, H., Kleinman, M., &amp;#x26; Parthasarathy, S. (2022). &lt;i&gt;What&apos;s in the Chatterbox? Large Language Models, Why They Matter, and What We Should Do About Them&lt;/i&gt;. Technology Assessment Project, Science, Technology, and Public Policy Program, University of Michigan. &lt;a href=&quot;https://stpp.fordschool.umich.edu/sites/stpp/files/2022-05/large-language-models-TAP-2022-final-051622.pdf&quot;&gt;https://stpp.fordschool.umich.edu/sites/stpp/files/2022-05/large-language-models-TAP-2022-final-051622.pdf&lt;/a&gt; &lt;a href=&quot;#cita-okerlund2022&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 45&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-fli2023&quot; value=&quot;46&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[46]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Future of Life Institute (2023, March 22). &lt;i&gt;Pause Giant AI Experiments: An Open Letter&lt;/i&gt;. &lt;a href=&quot;https://futureoflife.org/open-letter/pause-giant-ai-experiments/&quot;&gt;https://futureoflife.org/open-letter/pause-giant-ai-experiments/&lt;/a&gt; &lt;a href=&quot;#cita-fli2023&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 46&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-asimov1956&quot; value=&quot;47&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[47]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Asimov, I. (1956, November). The Last Question. &lt;i&gt;Science Fiction Quarterly&lt;/i&gt;.  &lt;a href=&quot;#cita-asimov1956&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 47&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;</content:encoded><category>Essay</category><category>technology</category><category>machine-learning</category><category>society</category></item><item><title>From the raw signal to a real-time classifier</title><link>https://blog.francoalcaraz.com/en/raw-signal-to-classifier/</link><guid isPermaLink="true">https://blog.francoalcaraz.com/en/raw-signal-to-classifier/</guid><description>Recognizing people, vehicles and animals by their micro-Doppler signature: cleaning real radar recordings, training a small network and deciding what to report in operation.</description><pubDate>Fri, 09 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;aside class=&quot;al-margen&quot;&gt;&lt;p&gt;&lt;em&gt;Original language: Spanish. This is the second of a series of three articles based on my master’s thesis, “Classification of Doppler Signals from Radar Echoes Using Deep Learning” (Instituto Balseiro, 2020) &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-alcaraz2026&quot; title=&quot;Alcaraz (2026). Classification of Doppler Signals from Radar Echoes Using Deep Learning&quot; class=&quot;cita&quot; id=&quot;cita-alcaraz2026&quot;&gt;1&lt;/a&gt;]&lt;/span&gt;. The first one, &lt;a href=&quot;https://blog.francoalcaraz.com/en/micro-doppler-signatures/&quot;&gt;“What a radar sees when you walk”&lt;/a&gt;, explains what information the signal carries; this one tells how the classifier was built.&lt;/em&gt;&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;When we talk about deep learning applied to a new problem, we usually focus on the model:
which architecture, how many layers, which optimizer. In my thesis the model ended up being
the least complicated part. What took the most work, and what weighed the most on the
result, was everything that happens before and after it: deciding which parts of a real
recording are useful for training, how to turn them into something a supervised learning
model can process, and how to go from many individual predictions to one decision per
object.&lt;/p&gt;
&lt;p&gt;In this article I go through that whole path, from the radar recordings to a classifier
that meets the timing requirements of a radar in operation. There is one idea that comes
up throughout the article: &lt;strong&gt;the same detector of useful portions is used twice&lt;/strong&gt;, first to
clean the training data and then to filter the predictions in operation.&lt;/p&gt;
&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;/h2&gt;
&lt;p&gt;A ground scanning radar detects moving objects, locates them and tracks them (it builds
their trajectory from multiple associated detections). Knowing what each object is is a
different problem. For that, the Doppler signal of the cell where the object is located is
used: as I show in the &lt;a href=&quot;https://blog.francoalcaraz.com/en/micro-doppler-signatures/&quot;&gt;first article of the series&lt;/a&gt;, each type of object leaves a
characteristic trace in that signal, its micro-Doppler signature.&lt;/p&gt;
&lt;p&gt;At the start I set myself three goals, thinking of a real radar and not of a lab
experiment:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;at least 80 % accuracy in each class;&lt;/li&gt;
&lt;li&gt;classifying a signal window in 100 ms or less, to be able to handle several objects at
once;&lt;/li&gt;
&lt;li&gt;a latency of 4 s or less between the moment the object appears and its first
classification.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The next figure summarizes the resulting classification chain. The two highlighted boxes
are the ones this article covers in more detail.&lt;/p&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Block diagram: the radar detects and tracks the object, the Doppler signal of its cell goes through the useful-segment detector, is cut into 4 s windows every 0.5 s, each one becomes a 128 × 128 spectrogram classified by the convolutional network, and the average of the valid windows gives the object&amp;#39;s class. The detector and the average of the valid windows are highlighted.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2070&quot; height=&quot;858&quot; src=&quot;https://blog.francoalcaraz.com/_astro/pipeline.DuWso_Pi_1MxtKA.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;The classification chain inside the radar.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;real-data-does-not-come-clean&quot;&gt;Real data does not come clean&lt;/h2&gt;
&lt;p&gt;I used the public dataset of the Signal Processing Laboratory of Ben-Gurion University &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-spl&quot; title=&quot;Signal Processing Laboratory, Ben-Gurion University of the Negev. The Database of Radar Echoes from Various Targets&quot; class=&quot;cita&quot; id=&quot;cita-spl&quot;&gt;2&lt;/a&gt;]&lt;/span&gt;,
recorded with a ground scanning pulse-Doppler radar in X band. It has recordings of one and
two people in many different situations, of cars, of tracked vehicles and of animals. So
that the classifier would also have a “nothing here” option, I added 80 recordings of
synthetic noise (with no object at all).&lt;/p&gt;
&lt;p&gt;The first thing that stands out is the imbalance. There are 231 recordings of one person and
9 of tracked vehicles. The recordings also have very different durations, so the number of
samples per class is not even either.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Recordings per class: one person 231 (8,586 windows), two people 127 (8,472), synthetic noise 80 (4,160), animal 69 (5,056), car 53 (3,043) and tracked vehicle 9 (1,142).&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1670&quot; height=&quot;819&quot; src=&quot;https://blog.francoalcaraz.com/_astro/recordings_per_class.Dqvjd7Hg_4yP2i.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Recordings and windows per class.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The second thing shows up when looking at the recordings one by one. Many have portions in
which the object is simply not there (tracking was lost, or the object stopped), signal
dropouts, and interference or intermodulation from the radar itself that draws horizontal
bands on the spectrogram. In the extreme case, a recording has only 6 s of useful signal.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Spectrogram with the car&amp;#39;s line at the bottom and many horizontal interference bands across the whole range.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1670&quot; height=&quot;980&quot; src=&quot;https://blog.francoalcaraz.com/_astro/car_slow_full.Din14W5u_1ndOub.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;A car recording with the full frequency range: almost everything visible is interference.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;If we train with all of that mixed in, we are asking the model to learn to recognize people
also from periods where there is no person at all. Most of the published work I read starts
from data that has already been cleaned and does not say how it got there. In my case, that
process ended up being the core of the work.&lt;/p&gt;
&lt;h2 id=&quot;detecting-the-useful-segments&quot;&gt;Detecting the useful segments&lt;/h2&gt;
&lt;p&gt;The idea is that if there is something moving in a portion of the recording, there is
Doppler energy concentrated at some speed (whereas noise spreads its energy over the whole
range). The detector I built has three rules:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the spectrogram of the signal is computed (after filtering the signal to remove
out-of-band interference) and, at each instant, its maximum power; that curve is
smoothed with a 2 s window and compared with a threshold;&lt;/li&gt;
&lt;li&gt;short gaps, of up to 0.5 s, are tolerated within the same segment;&lt;/li&gt;
&lt;li&gt;only segments of at least 3 s are accepted.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I chose the threshold by looking at recordings with the typical problems and adjusting it
until the detected segments matched what could be seen by eye.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Top, the spectrogram of the recording with two portions boxed; bottom, the smoothed maximum power, which exceeds the threshold in those two portions, marked as valid segments.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1870&quot; height=&quot;1180&quot; src=&quot;https://blog.francoalcaraz.com/_astro/segment_detection.nQhcxtET_1Ipwc7.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;The detector on a recording of a person walking in a zig-zag.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;How much does this step matter? I built a variant of the dataset with more permissive
criteria (lower threshold, more tolerant gaps and durations), with the idea of getting more
samples. Accuracy dropped by about 3.5 points. It was the largest difference among all the
data variants I tried, larger than any change in the signal representation. It is a single
run per variant, so I take it as a strong hint and not as a precise measurement, but it
indicates that, in this case, adding more lower-quality data did not help.&lt;/p&gt;
&lt;p&gt;This detector shows up again later, in operation (inference).&lt;/p&gt;
&lt;h2 id=&quot;from-segments-to-images&quot;&gt;From segments to images&lt;/h2&gt;
&lt;p&gt;Each useful segment is cut into 4 s (seconds) windows, one every 0.5 s. Four seconds are
enough to see a full movement cycle even for the slowest object (tracked vehicles), and they
also meet the latency I had set. The large overlap gives many more samples per segment, at
the cost of consecutive windows being very similar to each other, something to keep in mind
when splitting the data (I say a bit more about this in the training section).&lt;/p&gt;
&lt;p&gt;Each window is converted into a spectrogram, which is then turned into an 8-bit grayscale
image of 128 × 128 pixels. It is a small image (compared with the ones used to classify
photos), but it keeps the pattern of the signature. There are also criteria for choosing
the resolution, with priority on keeping it low to reduce processing time in operation.&lt;/p&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Six 128 by 128 pixel grayscale images, one per class: one person, two people, animal, car, tracked vehicle and noise.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2070&quot; height=&quot;594&quot; src=&quot;https://blog.francoalcaraz.com/_astro/input_images.BhX2YQR5_Z2t93w0.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;One input image per class.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;I also tried other representations: mel-scale spectrograms, a multiband variant that
expands the low frequencies, wavelet scalograms and a 2D cosine transform. The differences
were small and none of them justified its extra computing cost; the cosine transform was
clearly worse. The practical conclusion was that the cheapest representation was enough.&lt;/p&gt;
&lt;h2 id=&quot;training-without-fooling-ourselves&quot;&gt;Training without fooling ourselves&lt;/h2&gt;
&lt;p&gt;Before training, we need to set data aside for evaluation, and this is where it is easy to
make a mistake. Two consecutive windows share 87.5 % of the signal. If windows are split at
random, the model is evaluated on images that are almost identical to the ones it saw during
training, and the result we get is higher than what the model actually achieves on new data.
The split has to be made by recording: each recording goes entirely to training or to
evaluation, while also keeping the 70/30 proportion in each class. Doing that correctly is a
problem in itself, which I cover in detail (with an experiment that measures how much doing
it wrong inflates the result) in the &lt;a href=&quot;https://blog.francoalcaraz.com/en/split-by-recordings/&quot;&gt;third article of the series&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To help the model generalize, I used physically meaningful data augmentation. Resampling the
signal in time is equivalent to scaling the Doppler frequencies: it is as if the object
moved faster or slower. With that, plus added noise, I generated new samples and at the same
time balanced the classes in the training set. Without data augmentation, accuracy was about
1.5 points lower (again, one run per configuration: a hint, not a precise measurement).&lt;/p&gt;
&lt;aside class=&quot;recuadro&quot; data-tipo=&quot;nota&quot;&gt;&lt;p class=&quot;recuadro-titulo&quot;&gt;A note on the thesis figures&lt;/p&gt;&lt;p&gt;In the thesis I split the data into only two partitions, training and test. The test partition was also used to decide when to stop training and which weights to keep, so in practice it played the role of a validation set. The figures below come from that partition: they are representative, but somewhat optimistic. In the &lt;a href=&quot;https://blog.francoalcaraz.com/en/split-by-recordings/&quot;&gt;third article&lt;/a&gt; I repeated the training with a stricter protocol, without making any decision based on test and also measuring on recordings the model never saw. Without data augmentation, the per-window result was close to 87 %, in the same range as the thesis.&lt;/p&gt;&lt;/aside&gt;
&lt;h2 id=&quot;a-small-model-is-enough&quot;&gt;A small model is enough&lt;/h2&gt;
&lt;p&gt;The model that worked best, which I called &lt;em&gt;pollito&lt;/em&gt;, is a rather modest convolutional
network:&lt;/p&gt;





















&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Stage&lt;/th&gt;&lt;th&gt;Layers&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Feature extraction&lt;/td&gt;&lt;td&gt;4 convolutions (32, 64, 128 and 128 filters; kernels of 7, 5, 3 and 3) with &lt;em&gt;max pooling&lt;/em&gt; after each one&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Classification&lt;/td&gt;&lt;td&gt;2 dense layers (1024 and 512 neurons) with &lt;em&gt;dropout&lt;/em&gt;, and the 6-class output&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Total&lt;/td&gt;&lt;td&gt;about 4.1 M parameters&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;For reference, AlexNet, the network that changed image classification in 2012, has about
60 M &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-krizhevsky2012&quot; title=&quot;Krizhevsky et al. (2012). ImageNet classification with deep convolutional neural networks&quot; class=&quot;cita&quot; id=&quot;cita-krizhevsky2012&quot;&gt;3&lt;/a&gt;]&lt;/span&gt;. The problem and the size of the dataset do not call for more. I tried several
architectures, and the most telling comparison was with a network of dense layers only that
had twice as many parameters: it did not reach 80 % on test. In this problem, using
convolutional layers contributed more than increasing the number of parameters.&lt;/p&gt;
&lt;aside class=&quot;al-margen&quot;&gt;&lt;p&gt;A convolutional layer applies the same filters over the whole image, so a pattern (for example, that of a step) is recognized even if it appears at another moment of the window or at another speed. A network of dense layers, on the other hand, has to learn that pattern separately for each position in the image.&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;Per window, &lt;em&gt;pollito&lt;/em&gt; reached an accuracy of around 90 % on test (the partition that, as I
explained before, was also used for validation). Looking per class, one person, car and
animal were around 89 %–90 %, tracked vehicle close to 99 % (although with only 3 test
recordings, that number says little) and noise at 100 %. The hardest class was two people,
at 84 %: when they walk in step, their signature looks a lot like that of a single person.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Six-class confusion matrix with the diagonal between 84 % (two people) and 100 % (noise); the largest confusion is two people taken as one (12 %).&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1262&quot; height=&quot;1219&quot; src=&quot;https://blog.francoalcaraz.com/_astro/confusion_windows.gyIRCkiP_Z97ASp.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Per-window confusion matrix.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;in-operation-deciding-what-to-report-at-each-moment&quot;&gt;In operation: deciding what to report at each moment&lt;/h2&gt;
&lt;p&gt;In the radar, the classifier does not work on a finished recording. For each tracked object
a stream of windows arrives, one every fraction of a second, and at every moment the system
has to report what it thinks the object is. What matters, then, is not only the final
decision, but which class the operator is seeing at each instant, and above all how long
they are seeing a wrong class.&lt;/p&gt;
&lt;p&gt;This is where the segment detector comes back. Just as I discarded the portions without an
object for training, in operation it makes sense not to report anything during those
portions: the model never saw windows like that, and we cannot expect it to know what to do
with them. The detector rules are the same as for training.&lt;/p&gt;
&lt;p&gt;What has to be defined in operation is when a window counts as valid, because a 4 s window
can fall only partly inside a segment (for example, when the object has just appeared or
when it is lost). The criterion I used is that the window must have at least 2.5 s of signal
inside a valid segment, that is, a little over 60 % of its duration. I did not require the
window to fall entirely inside the segment because I saw that the model still behaved well
on windows with a smaller percentage of useful content. This way the system also starts
reporting sooner when an object appears: 2.5 s after the start of the segment instead of
4 s.&lt;/p&gt;
&lt;p&gt;The next figure shows what happens in a recording of a person walking in a zig-zag, which in
the thesis ended up on the test side. Inside the valid segments, the model says “one person”
with full confidence. Outside them, where there is almost no signal, it says “animal” with
the same confidence. Without the filter, an operator would see “animal” for almost half of
the recording.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Top, the spectrogram of the recording; bottom, the probability of each class over time: inside the two valid segments &amp;quot;one person&amp;quot; is close to 1, and outside them &amp;quot;animal&amp;quot; is.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1870&quot; height=&quot;1220&quot; src=&quot;https://blog.francoalcaraz.com/_astro/predictions_over_signal.DcrJ-BvG_Z10Vo9R.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Model predictions along the recording.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;To measure this over all test recordings I simulated operation: I went through each
recording in order, one window every 0.5 s, and at each instant I recorded which class would
be reported with four strategies. The class can come from the current window
(instantaneous) or from the average of all windows since the object appeared (running
average), and in both cases with or without the valid-segment filter. With the filter,
nothing is reported while there are no valid windows, and the running average is only
updated with valid windows.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Stacked bars with the fraction of time with a correct class, a wrong class or no classification: instantaneous, 81, 19 and 0 %; instantaneous with valid windows only, 51, 8 and 41 %; running average, 88, 12 and 0 %; running average with valid windows only, 76, 8 and 16 %.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1789&quot; height=&quot;945&quot; src=&quot;https://blog.francoalcaraz.com/_astro/online_reports.DQcD4zhH_2tetb1.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Class reported at each instant with each strategy.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Without the filter, the system reports a wrong class 19 % of the time if it uses the current
window, and 12 % if it averages backwards. With the filter, that time drops to 8 % in both
cases. The price is that there are moments without a classification: in this evaluation,
41 % of the time with the instantaneous strategy and 16 % with the running average. Part of
that time corresponds to the noise recordings, where reporting nothing is exactly the right
thing to do. When the system does report a class, it is right 87 % of the time with the
current window and 91 % with the running average of valid windows.&lt;/p&gt;
&lt;p&gt;For a monitoring system, that trade-off is reasonable: it is better for the operator to see
“no classification” during a doubtful period than to see “animal” on a person who is
approaching (or “person” on an animal, which triggers a false alarm).&lt;/p&gt;
&lt;h3 id=&quot;and-if-we-look-at-the-whole-recording&quot;&gt;And if we look at the whole recording&lt;/h3&gt;
&lt;p&gt;In the thesis I also evaluated the result the way it is usually done in published work: one
decision per complete recording, averaging the probabilities of its windows and choosing the
class with the highest average. This way, test accuracy goes from 89.7 % per window to
94.0 % per recording, because the errors of different windows are not perfectly correlated
and averaging them makes them cancel out.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Accuracy per window, 89.7 %, and per recording averaging its windows, 94.0 %.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1549&quot; height=&quot;618&quot; src=&quot;https://blog.francoalcaraz.com/_astro/window_vs_recording.B3Vncu79_1FRsrw.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Per-window and per-recording accuracy on test.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;In that offline evaluation the filter does not change the result (also 94.0 % with filtering), but
that does not say much about the method: the average at the end of the recording only
changes when the portions without an object weigh enough in the total, so it depends mostly
on what fraction of each recording is useful. In the example recording they weigh a lot, and
the average of all windows ends up saying “animal”.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Mean probability of each class in the example recording: with all windows, &amp;quot;animal&amp;quot; reaches 51 % and beats &amp;quot;one person&amp;quot;; with only the valid ones, &amp;quot;one person&amp;quot; rises to 93 % and &amp;quot;animal&amp;quot; stays near 0.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1700&quot; height=&quot;860&quot; src=&quot;https://blog.francoalcaraz.com/_astro/aggregate_decision.DxfcSHVN_1OTTI.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Recording decision using all windows and using only the valid ones.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;can-it-be-deployed-on-a-radar&quot;&gt;Can it be deployed on a radar?&lt;/h2&gt;
&lt;p&gt;I measured the times on a laptop with an Intel i7-8750H processor and a GTX 1060 GPU,
without any particular optimization (that is, running the model as it was used for
training):&lt;/p&gt;

























&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Stage&lt;/th&gt;&lt;th align=&quot;right&quot;&gt;Mean time per window&lt;/th&gt;&lt;th align=&quot;right&quot;&gt;Windows per second&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Pre-processing (spectrogram)&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;1.95 ms&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;512&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Inference&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;20.45 ms&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;49&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Total&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;22.4 ms&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;45&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;The total is well below the 100 ms I had set: it is enough to classify about 45 windows per
second. Almost all of the inference time goes into moving data from CPU memory to the GPU,
so an implementation designed for the radar platform should bring it down even further. In
radar units: while one window is being classified, the radar emits about 127 pulses.&lt;/p&gt;
&lt;h2 id=&quot;what-is-hard-and-what-comes-next&quot;&gt;What is hard and what comes next&lt;/h2&gt;
&lt;p&gt;Several things remain open:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Two people walking in step are confused with one. It is the clearest limitation of the
model, and also of the data: they are hard to tell apart by eye as well.&lt;/li&gt;
&lt;li&gt;The results for tracked vehicles rely on only 9 recordings. More data is needed before
drawing conclusions about that class.&lt;/li&gt;
&lt;li&gt;It still has to be tested on radar hardware and, above all, with data from another radar
or another scenario. Everything I measured is on a single dataset.&lt;/li&gt;
&lt;li&gt;There are configurations I did not explore in depth: hyperparameter optimization,
recurrent models that exploit the sequence of windows instead of averaging it, and
transferring the model to other radars.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What I take away from this work is that, with real data, the quality of what goes into the
model weighs more than the architecture. Choosing well which portions of each recording to
use, for training and for reporting in operation, did more for the result than the model
adjustments I tried.&lt;/p&gt;
&lt;h2 id=&quot;code-and-data&quot;&gt;Code and data&lt;/h2&gt;
&lt;p&gt;The figures in this article were generated with the code and the trained model of the
thesis, without modifying them.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;This article was originally written by me in Spanish and translated into English using the
Claude Opus 5.5 model (Anthropic).&lt;/em&gt;&lt;/p&gt;&lt;section class=&quot;referencias&quot; aria-labelledby=&quot;referencias&quot;&gt;&lt;h2 id=&quot;referencias&quot; class=&quot;referencias-titulo&quot;&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li id=&quot;ref-alcaraz2026&quot; value=&quot;1&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Alcaraz, F. A. (2026). &lt;i&gt;Classification of Doppler Signals from Radar Echoes Using Deep Learning&lt;/i&gt;. Master&apos;s thesis in Engineering, revised English edition, Instituto Balseiro, Universidad Nacional de Cuyo. &lt;a href=&quot;https://doi.org/10.5281/zenodo.23227057&quot;&gt;https://doi.org/10.5281/zenodo.23227057&lt;/a&gt; &lt;a href=&quot;#cita-alcaraz2026&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 1&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-spl&quot; value=&quot;2&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[2]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Signal Processing Laboratory, Ben-Gurion University of the Negev (n.d.). &lt;i&gt;The Database of Radar Echoes from Various Targets&lt;/i&gt;. &lt;a href=&quot;http://www.ee.bgu.ac.il/~spl/&quot;&gt;http://www.ee.bgu.ac.il/~spl/&lt;/a&gt; &lt;a href=&quot;#cita-spl&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 2&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-krizhevsky2012&quot; value=&quot;3&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[3]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Krizhevsky, A., Sutskever, I., &amp;#x26; Hinton, G. E. (2012). ImageNet classification with deep convolutional neural networks. &lt;i&gt;Advances in Neural Information Processing Systems&lt;/i&gt;&lt;i&gt;, 25&lt;/i&gt;.  &lt;a href=&quot;#cita-krizhevsky2012&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 3&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-alcaraz2020&quot; value=&quot;4&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[4]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Alcaraz, F. A. (2020). &lt;i&gt;Clasificación de Señales Doppler de Ecos Radar usando Deep Learning&lt;/i&gt;. Master&apos;s thesis in Engineering (original Spanish version), Instituto Balseiro, Universidad Nacional de Cuyo. &lt;a href=&quot;https://doi.org/10.5281/zenodo.23226363&quot;&gt;https://doi.org/10.5281/zenodo.23226363&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-bilik2008&quot; value=&quot;5&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[5]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Bilik, I., &amp;#x26; Tabrikian, J. (2008). Knowledge-based radar target classification. &lt;i&gt;Knowledge-Based Radar Detection, Tracking and Classification (F. Gini and M. Rangaswamy, eds.), ch. 9&lt;/i&gt;, 197–224. Wiley. &lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-chen2019&quot; value=&quot;6&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[6]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Chen, V. C. (2019). &lt;i&gt;The Micro-Doppler Effect in Radar&lt;/i&gt; (2nd ed.). Artech House. &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;</content:encoded><category>Article</category><category>machine-learning</category><category>signal-processing</category></item><item><title>Split by recordings, not by windows</title><link>https://blog.francoalcaraz.com/en/split-by-recordings/</link><guid isPermaLink="true">https://blog.francoalcaraz.com/en/split-by-recordings/</guid><description>When training examples come from the same sample: leakage, heuristics, scikit-learn and dynamic programming.</description><pubDate>Fri, 09 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;aside class=&quot;al-margen&quot;&gt;&lt;p&gt;&lt;em&gt;Original language: Spanish. This is the third of a series of three articles based on my master’s thesis, “Classification of Doppler Signals from Radar Echoes Using Deep Learning” (Instituto Balseiro, 2020) &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-alcaraz2026&quot; title=&quot;Alcaraz (2026). Classification of Doppler Signals from Radar Echoes Using Deep Learning&quot; class=&quot;cita&quot; id=&quot;cita-alcaraz2026&quot;&gt;1&lt;/a&gt;]&lt;/span&gt;. It can be read on its own: the problem shows up in any dataset where many examples come out of the same observation.&lt;/em&gt;&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;Splitting a dataset into train and test looks like the easiest part of the whole process:
we call &lt;code&gt;train_test_split&lt;/code&gt;, pick 70/30 and move on to what seems more interesting. This
works well as long as the examples are independent of each other. When they are not, the
test set stops measuring what we think it measures, and nothing in the code warns us. It
seems like something sensible that we take for granted, but I have seen many projects with
splitting errors caused by not taking this into account.&lt;/p&gt;
&lt;h2 id=&quot;two-different-things-we-call-a-sample&quot;&gt;Two different things we call a “sample”&lt;/h2&gt;
&lt;p&gt;In statistics, a sample is what we get when we observe the problem domain: a patient, a
user session, a machine measured on a given day, a radar recording. Each one is a “capture”
from the sample space, and what we want to know is how the model will behave on new
captures from that same space.&lt;/p&gt;
&lt;p&gt;In machine learning, on the other hand, we usually call “sample” each data point that goes
into the model. And often those data points are not different captures: they come from
processing the same observation. A recording is cut into windows, a medical image into
patches, a time series into fragments, and sometimes data augmentation is added on top. A
single sample from the domain yields tens or hundreds of training examples, very similar to
each other.&lt;/p&gt;
&lt;p&gt;I have often seen data scientists and ML engineers mix up the two: treating the processed
examples as if they were independent samples, shuffling them and splitting them at random
into train, validation and test. As a result, validation and test end up contaminated with
examples that are not independent of the ones in train, because they come from the same
observation. The model is evaluated on almost identical versions of what it already saw,
the metric is inflated, and since validation is contaminated too, the decisions made with it
(when to stop training, which hyperparameters to choose, which model to keep) are biased as
well. It is an easy mistake to make because in the code both things have the same name: &lt;code&gt;X&lt;/code&gt;,
&lt;code&gt;y&lt;/code&gt;, &lt;code&gt;n_samples&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It happens with patients who contribute several images, with users who have several
sessions, with machines measured many times, with audio cut into fragments. The literature
treats it as a case of data leakage &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-kaufman2012&quot; title=&quot;Kaufman et al. (2012). Leakage in data mining: formulation, detection, and avoidance&quot; class=&quot;cita&quot; id=&quot;cita-kaufman2012&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;#ref-roberts2017&quot; title=&quot;Roberts, D. R., et al. (2017). Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure&quot; class=&quot;cita&quot; id=&quot;cita-roberts2017&quot;&gt;3&lt;/a&gt;]&lt;/span&gt;. The question to ask is always the same: &lt;strong&gt;which
unit will be new when the model is in production?&lt;/strong&gt; That unit is the domain sample, and it
is the one that has to be split between train, validation and test.&lt;/p&gt;
&lt;p&gt;In my thesis I ran into this problem while classifying radar signals. In this article I
explain how I approached it, what scikit-learn offers, how to find the optimal solution and what
biases each alternative has. To keep it from staying in theory, I also trained the same
model with correct and incorrect splits, and measured the difference. To avoid adding
confusion, from here on I use &lt;strong&gt;recording&lt;/strong&gt; for the domain sample and &lt;strong&gt;window&lt;/strong&gt; for the
training example that comes out of it.&lt;/p&gt;
&lt;h2 id=&quot;the-case-windows-from-radar-recordings&quot;&gt;The case: windows from radar recordings&lt;/h2&gt;
&lt;p&gt;The thesis dataset is made of radar recordings of people, vehicles and animals (the first
article of the series, &lt;a href=&quot;https://blog.francoalcaraz.com/en/micro-doppler-signatures/&quot;&gt;&lt;em&gt;What a radar sees when you walk&lt;/em&gt;&lt;/a&gt;, shows what they look like). Each
recording lasts between a few seconds and a minute and a half, and to classify it, it is cut
into 4 s windows that are converted into images. The windows overlap: each one starts half a
second after the previous one, so &lt;strong&gt;two consecutive windows share 87.5 % of the signal&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The result is 30,459 windows (frames) that come from only 569 recordings. If the windows are
split at random with &lt;code&gt;train_test_split&lt;/code&gt;, even stratifying by class, &lt;strong&gt;557 of the 569
recordings end up with windows in both train and test&lt;/strong&gt;. The model is evaluated on images
almost identical to others it saw during training, and the test metric no longer tells how
it will behave on a new recording.&lt;/p&gt;
&lt;p&gt;There is an intermediate case worth keeping in mind: cutting each recording in time before
building the windows, and sending one portion to train and another to test. This way no test
window shares signal with a train window (those that would cross the cut are discarded), but
both still come from the same person, in the same take, a few seconds earlier or later. The
figure shows the three ways of splitting on two example recordings.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Two recordings, A and B, cut into overlapping 4 s windows, split in three ways. By frames, train and test windows alternate within each recording. By time, each recording has a cut: one portion goes to train, the other to test, and the windows crossing the cut are discarded. By recordings, A goes entirely to train and B entirely to test.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1939&quot; height=&quot;1660&quot; src=&quot;https://blog.francoalcaraz.com/_astro/split_schema.Cy3XWlgW_Zivabb.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Three ways of splitting two recordings cut into windows.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;how-similar-are-the-windows&quot;&gt;How similar are the windows?&lt;/h3&gt;
&lt;p&gt;Besides saying that windows are “not independent”, it is worth measuring how similar they
are. To compare two windows I used the 2D cross-correlation of their spectrograms along
time: I shift one image relative to the other by up to 2 s, compute the correlation
coefficient over the overlapping part and keep the maximum. This compares the full pattern
(frequency and time) and tolerates it appearing shifted in time (for example, the same step
half a second later). Beforehand I subtract the mean spectrum of the dataset, so that the
background common to all images does not dominate.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Median 2D correlation between pairs of windows: 0.99 for consecutive windows, 0.62 for windows of the same recording 4–10 s apart and 0.42 for windows from another recording of the same class.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1709&quot; height=&quot;780&quot; src=&quot;https://blog.francoalcaraz.com/_astro/window_autocorrelation.CCSmhY-u_Z1LRudS.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Similarity between pairs of windows according to their relationship.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Two consecutive windows have a correlation of 0.99 (1 would mean identical): in practice,
they are the same image shifted by half a second. Two windows from the same recording that
no longer share signal (between 4 and 10 s apart) are around 0.62, and two windows from
different recordings of the same class, 0.42. Even without overlap, a recording looks more
like itself than like the others: it is the same person, at the same speed and in the same
place.&lt;/p&gt;
&lt;p&gt;The consequence for the split shows up when looking, for each test window, for the most
similar train window. With the split by frames, in 98 % of the cases that window comes from
the same recording, and the distance is about 30 times smaller than with the split by
recordings: train and test have almost the same windows. With the time cut, the near
duplicates disappear. The most similar train window usually comes from another recording
(only in 16 % of the cases is it from the same one), and the distance is the same as with
the split by recordings. Among more than 18,000 train windows, there is almost always
another recording as similar as its own.&lt;/p&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Histograms of the distance on a logarithmic scale: by frames, median 0.008; by time, 0.25; by recordings, 0.26. The by-time and by-recordings curves almost overlap.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1695&quot; height=&quot;899&quot; src=&quot;https://blog.francoalcaraz.com/_astro/nearest_neighbor.CUZvJWoD_Zbx8aA.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Distance between each test window and the most similar train window, with each split.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;what-is-needed&quot;&gt;What is needed&lt;/h2&gt;
&lt;p&gt;In this case the answer is the recording: in operation, the radar will see objects it has
never seen. So the split has to meet two conditions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hard constraint:&lt;/strong&gt; each recording goes entirely to train or to test.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Goal:&lt;/strong&gt; a given proportion (here, 70/30) &lt;strong&gt;in each class&lt;/strong&gt;, measured in windows and not
in recordings, because the model is trained and evaluated on windows.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;What complicates the second condition is that recordings have very different sizes. In the
“one person” class there are 231 recordings, with a median of 32 windows and a maximum of
147. And some classes have very few recordings: the tracked vehicle class has 9, almost all
of them long.&lt;/p&gt;















































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Class&lt;/th&gt;&lt;th align=&quot;right&quot;&gt;Windows&lt;/th&gt;&lt;th align=&quot;right&quot;&gt;Recordings&lt;/th&gt;&lt;th align=&quot;right&quot;&gt;Windows per recording (median / max)&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;one person&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;8,586&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;231&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;32 / 147&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;two people&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;8,472&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;127&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;62 / 166&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;animal&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;5,056&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;69&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;71 / 167&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;noise (synthetic)&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;4,160&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;80&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;52 / 52&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;car&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;3,043&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;53&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;50 / 142&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;tracked vehicle&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;1,142&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;9&lt;/td&gt;&lt;td align=&quot;right&quot;&gt;132 / 172&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 id=&quot;a-number-partitioning-problem&quot;&gt;A number partitioning problem&lt;/h2&gt;
&lt;p&gt;Looked at class by class, the problem can be stated like this: given a set of numbers (the
windows of each recording), choose a subset whose sum (in number of windows) is as close as
possible to 30 % of the total. That subset goes to test and the rest to train.&lt;/p&gt;
&lt;p&gt;This is the subset sum problem, a classic in complexity theory: it is NP-complete &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-garey1979&quot; title=&quot;Garey &amp;#x26; Johnson (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness&quot; class=&quot;cita&quot; id=&quot;cita-garey1979&quot;&gt;4&lt;/a&gt;]&lt;/span&gt;. In
practice it is not as bad as it sounds: the difficulty appears when the numbers are very
large; if the total is manageable, it can be solved in time proportional to (number of
groups) × (total number of windows), which is called pseudo-polynomial time. With totals of
a few thousand windows, that is solved in a fraction of a second.&lt;/p&gt;
&lt;aside class=&quot;al-margen&quot;&gt;&lt;p&gt;“Pseudo-polynomial” means that the time is proportional to the numeric value of the total, which can grow exponentially with the number of digits needed to write it. That is why the problem is still NP-complete in general, but easy when the numbers are small, like the number of windows in each recording.&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;The 50/50 case is the partition problem: splitting into two equal halves. There is a
classic reduction between the two, which is the idea behind the heuristic I used in the
thesis.&lt;/p&gt;
&lt;h2 id=&quot;a-greedy-heuristic-with-a-trick&quot;&gt;A greedy heuristic with a trick&lt;/h2&gt;
&lt;p&gt;For the 50/50 case there is a well-known heuristic: sort the numbers from largest to
smallest and assign each one to the partition with the smallest sum at that moment. It works
very well when there are many small numbers to balance things at the end (the large ones are
distributed first and the small ones even out the sums).&lt;/p&gt;
&lt;p&gt;For 70/30 a trick is needed. If &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;K&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; is the class total and &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;W&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;W&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; the target for test
(&lt;math&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;0.3&lt;/mn&gt;&lt;mspace width=&quot;0.1667em&quot;&gt;&lt;/mspace&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;0.3\,K&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;), a dummy element of value &lt;math&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mi&gt;W&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;2W - K&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; is added to train. When the heuristic manages
to equalize both sums, test is worth &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;W&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;W&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; and train, without the dummy, is worth &lt;math&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;W&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;K - W&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;.
This is the reduction from subset sum to partition.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;https://blog.francoalcaraz.com/_astro/ec.f4yz9.css&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#6F42C1;--1:#DCBDFB&quot;&gt;greedy_dummy&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes, rate):&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#032F62;--1:#96D0FF&quot;&gt;&quot;&quot;&quot;Indices of the groups that go to test.&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;K &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;W &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(K &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; rate)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;test_sum, train_sum &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; W &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; K       &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# the dummy goes in train&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;test &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; []&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.argsort(sizes)[::&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;]:        &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# largest to smallest&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; test_sum &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; train_sum:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;test.append(i)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;test_sum &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; sizes[i]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;train_sum &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; sizes[i]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; test&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;def greedy_dummy(sizes, rate):    &amp;#x22;&amp;#x22;&amp;#x22;Indices of the groups that go to test.&amp;#x22;&amp;#x22;&amp;#x22;    K = sum(sizes)    W = int(K * rate)    test_sum, train_sum = 0, 2 * W - K       # the dummy goes in train    test = []    for i in np.argsort(sizes)[::-1]:        # largest to smallest        if test_sum &lt; train_sum:            test.append(i)            test_sum += sizes[i]        else:            train_sum += sizes[i]    return test&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;On this dataset it does very well in terms of proportions: 30.0 % in all classes except the
tracked vehicle class, which ends up at 31.5 %. But it has a property that is not obvious
from reading the code. With 70/30 the dummy is worth &lt;math&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;−&lt;/mo&gt;&lt;mn&gt;0.4&lt;/mn&gt;&lt;mspace width=&quot;0.1667em&quot;&gt;&lt;/mspace&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;-0.4\,K&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;, so train starts “in the
negative” and the largest groups all go to train until train accumulates about 40 % of the
class. Only then does it start alternating. In practice, &lt;strong&gt;the longest 20 % of the
recordings of each class almost never end up in test&lt;/strong&gt; (0 % and 4 % in the first two
deciles, over 100 splits with different seeds), and the rest end up in test more often than
they should.&lt;/p&gt;
&lt;p&gt;If the duration of a recording has nothing to do with what we want to classify, this does
no harm. But it usually does: long recordings may come from another scenario, from slower
objects or from a different measurement campaign. In that case the test set is less
representative, and there is no way to see it by looking only at the proportions.&lt;/p&gt;
&lt;h2 id=&quot;if-we-use-scikit-learn&quot;&gt;If we use scikit-learn&lt;/h2&gt;
&lt;p&gt;scikit-learn has two tools for group splits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;GroupShuffleSplit&lt;/code&gt;&lt;/strong&gt; picks groups at random. It is simple and has no size bias, but it
has two problems for this case. The first is that &lt;code&gt;test_size&lt;/code&gt; is a fraction of &lt;strong&gt;groups&lt;/strong&gt;,
not of examples. The second is that it does not stratify by class. Over 100 seeds, the test
fraction per class strayed up to 54 points from the target: the tracked vehicle class ended
up between 0 % and 84 % depending on the seed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;StratifiedGroupKFold&lt;/code&gt;&lt;/strong&gt; (since version 1.0) is designed for cross-validation: it builds
&lt;math&gt;&lt;semantics&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;k&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; folds that respect the groups and try to keep the class proportions. Looking at its
source code (version 1.9.1) &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-sklearn&quot; title=&quot;scikit-learn. StratifiedGroupKFold: documentation and source code of version 1.9.1&quot; class=&quot;cita&quot; id=&quot;cita-sklearn&quot;&gt;5&lt;/a&gt;]&lt;/span&gt;, the algorithm does this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;counts the examples of each group per class;&lt;/li&gt;
&lt;li&gt;sorts the groups by the standard deviation of those counts, from largest to smallest;&lt;/li&gt;
&lt;li&gt;assigns each group to the fold where the class distribution ends up most even.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When each group has a single class, as here, step 2 amounts to sorting the groups by size,
and step 3 amounts to sending each group to the fold with the fewest examples of its class.
&lt;strong&gt;It is the same greedy heuristic as before&lt;/strong&gt;, but with &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;k&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; equal bins instead of two unequal
ones. To build a 70/30 hold-out, it is enough to ask for 10 folds and join 3:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; sklearn.model_selection &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; StratifiedGroupKFold&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;sgkf &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; StratifiedGroupKFold(&lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;n_splits&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;shuffle&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;random_state&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;seed)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;folds &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; [test &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; _, test &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; sgkf.split(X, y, groups)]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;test_idx &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.concatenate(folds[:&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;])          &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# 3 of 10 folds = 30 %&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;train_idx &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.setdiff1d(np.arange(&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(y)), test_idx)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;from sklearn.model_selection import StratifiedGroupKFoldsgkf = StratifiedGroupKFold(n_splits=10, shuffle=True, random_state=seed)folds = [test for _, test in sgkf.split(X, y, groups)]test_idx = np.concatenate(folds[:3])          # 3 of 10 folds = 30 %train_idx = np.setdiff1d(np.arange(len(y)), test_idx)&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Equal bins have an advantage: since all of them receive large and small groups alike,
choosing any 3 does not introduce size bias. The price is precision in classes with few
groups: with 9 tracked vehicle recordings spread over 10 folds, the test fraction was 41.5 %
for every seed. It also supports groups with several classes, something the other
alternatives I present in this article do not handle.&lt;/p&gt;
&lt;h2 id=&quot;the-optimal-solution-dynamic-programming&quot;&gt;The optimal solution: dynamic programming&lt;/h2&gt;
&lt;p&gt;Given that we have on the order of thousands of windows, there is no need to settle for a
heuristic. Dynamic programming finds the subset whose sum is as close as possible to the
target without trying every combination (with the 231 recordings of the “one person” class
there would be &lt;math&gt;&lt;semantics&gt;&lt;msup&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mn&gt;231&lt;/mn&gt;&lt;/msup&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;2^{231}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;, a 70-digit number).&lt;/p&gt;
&lt;p&gt;Let us recall what we are looking for: within each class, choose which recordings go to
test, so that all their windows add up to 30 % of the class total. All the others go to
train. Each recording goes entirely to one partition or the other, so the problem is to
choose a subset of recordings: that subset is test and the rest is train.&lt;/p&gt;
&lt;p&gt;The idea is to go through the recordings one at a time and keep track of &lt;strong&gt;which sums can be
made&lt;/strong&gt; with the recordings seen so far. At the start, with no recordings, the only possible
sum is 0. Each time a recording of &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;w&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; windows is added, the possible sums become the ones we
already had (if we do not take it) plus those same sums increased by &lt;math&gt;&lt;semantics&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;annotation encoding=&quot;application/x-tex&quot; data-pagefind-ignore=&quot;&quot;&gt;w&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt; (if we take it).
It does not matter which combination led to each sum, only whether it can be reached, and
that is what avoids the combinatorial explosion: the table has (number of groups + 1) ×
(total + 1) cells and each one is computed only once.&lt;/p&gt;
&lt;p&gt;A small example makes it clearer. Suppose a class with five recordings, A to E, of 4, 3, 6, 2
and 5 windows. The total is 20 and the target for test is 6 windows (30 %). The reachable
sums grow like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no recordings: {0};&lt;/li&gt;
&lt;li&gt;with A (4): {0, 4};&lt;/li&gt;
&lt;li&gt;with B (3): the previous ones, plus the previous ones + 3 → {0, 3, 4, 7};&lt;/li&gt;
&lt;li&gt;with C (6): {0, 3, 4, 6, 7, 9, 10, 13};&lt;/li&gt;
&lt;li&gt;and the same with D and E.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the figure each row is one of those steps, and each blue cell is a reachable sum. A
recording appearing in a row does not mean it goes to test: it means it has already been
taken into account, whether taken or not. At this stage nothing has been decided yet; the
table only says which sums are possible. In row C the 6 already appears: there is at least
one combination that adds up exactly to the target.&lt;/p&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Table of 6 rows (no recording, then A, B, C, D and E) by 21 columns (sums from 0 to 20), with the reachable sums in blue and column 6 marked as the target. The backward path starts at sum 6 in row E, goes up without taking E, takes D (subtracting 2), goes up without taking C or B, takes A (subtracting 4) and reaches 0: A and D go to test; B, C and E to train.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2170&quot; height=&quot;1236&quot; src=&quot;https://blog.francoalcaraz.com/_astro/dp_table.DL7rj5Lj_g5nBf.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;The dynamic programming table for an example with five recordings, and the backward reconstruction from the target sum.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The table says that 6 can be reached, but not with which recordings. To find out, we go
through it backwards, starting from the last row and the target sum. In each row there are
two options: if the same sum was in the row above, it can be reached without that row’s
recording (vertical arrow); if the sum minus the recording’s size was in the row above, it
can be reached by taking it (diagonal arrow, which subtracts its size). In the example, E
cannot be taken (6 − 5 = 1 is not reachable without it), so we go straight up. In row D both
options work: without D, the 6 comes from taking C; with D, we need to reach 4 with A, B and
C. When both options are possible, the code picks one at random. In the figure D was taken,
and the path ends up taking A as well. The recordings the path takes go to test and the ones
it skips go to train: test gets A and D (4 + 2 = 6 windows, 30 %) and train gets B, C and E
(3 + 6 + 5 = 14 windows, 70 %).&lt;/p&gt;
&lt;p&gt;If in row D the random choice had been not to take it, the result would be different. The
path goes straight up to row C, and there the only option is to take C (6 cannot be reached
without it, and 6 − 6 = 0 can). From there on, it only goes straight up, because the sum is
already 0. Test gets only C (6 windows) and train gets A, B, D and E (4 + 3 + 2 + 5 = 14
windows). Both splits meet the 30/70 exactly; which one comes out depends on chance, and
that is why different seeds give different splits.&lt;/p&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;The same table with another backward path: from sum 6 it goes up without taking E or D, takes C (subtracting 6) and reaches 0; only C goes to test.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2170&quot; height=&quot;1236&quot; src=&quot;https://blog.francoalcaraz.com/_astro/dp_table_alt.9IzfHZLc_vOGhV.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;The same example with another random choice in row D: test ends up with recording C alone.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;In the code, the table is a boolean matrix &lt;code&gt;reach&lt;/code&gt;, where &lt;code&gt;reach[i, s]&lt;/code&gt; says whether some
combination of the first &lt;code&gt;i&lt;/code&gt; recordings adds up exactly to &lt;code&gt;s&lt;/code&gt;. Adding a recording is a
single line: the new row is the previous one, combined (with an OR) with the same row
shifted by &lt;code&gt;w&lt;/code&gt; positions. Then the reachable sum closest to the target is chosen (the target
itself may not be exactly reachable) and the subset is reconstructed backwards:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#6F42C1;--1:#DCBDFB&quot;&gt;subset_sum_optimal&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes, target, rng):&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#032F62;--1:#96D0FF&quot;&gt;&quot;&quot;&quot;Indices of a subset whose sum is the closest to target.&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;sizes &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.asarray(sizes)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;n, K &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes), &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes.sum())&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.zeros((n &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, K &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;dtype&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;bool&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;                        &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# with no groups, only 0 is reachable&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; i, w &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;enumerate&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes, &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;start&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;):&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[i] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;]               &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# without taking group i&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[i, w:] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;|=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, :K &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; w]   &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# taking it: everything shifted by w&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;sums &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.flatnonzero(reach[n])&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;gap &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.abs(sums &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; target)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;s &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; rng.choice(sums[gap &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; gap.min()])    &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# best reachable sum&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;chosen &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; []&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(n, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;):                 &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# backward reconstruction&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;w &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; sizes[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;can_skip &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, s]            &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# vertical arrow&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;can_take &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, s &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; w]   &lt;/span&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# diagonal arrow&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; can_take &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; can_skip &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;or&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; rng.rand() &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0.5&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;):&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;chosen.append(i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;s &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; w&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; chosen&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;def subset_sum_optimal(sizes, target, rng):    &amp;#x22;&amp;#x22;&amp;#x22;Indices of a subset whose sum is the closest to target.&amp;#x22;&amp;#x22;&amp;#x22;    sizes = np.asarray(sizes)    n, K = len(sizes), int(sizes.sum())    reach = np.zeros((n + 1, K + 1), dtype=bool)    reach[0, 0] = True                        # with no groups, only 0 is reachable    for i, w in enumerate(sizes, start=1):        reach[i] = reach[i - 1]               # without taking group i        reach[i, w:] |= reach[i - 1, :K + 1 - w]   # taking it: everything shifted by w    sums = np.flatnonzero(reach[n])    gap = np.abs(sums - target)    s = rng.choice(sums[gap == gap.min()])    # best reachable sum    chosen = []    for i in range(n, 0, -1):                 # backward reconstruction        w = sizes[i - 1]        can_skip = reach[i - 1, s]            # vertical arrow        can_take = s &gt;= w and reach[i - 1, s - w]   # diagonal arrow        if can_take and (not can_skip or rng.rand() &lt; 0.5):            chosen.append(i - 1)            s -= w    return chosen&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;For each class the groups are shuffled, this function is called with
&lt;code&gt;target = 0.3 * total&lt;/code&gt; and the chosen groups go to test. Shuffling the order of the groups
and choosing at random during the reconstruction makes each seed give a different split.
The result is as close to 30 % as the numbers allow: the maximum deviation was 0.05 points in all
classes, including the tracked vehicle class (29.95 %), and each full split of the 6 classes
takes about 0.1 s.&lt;/p&gt;
&lt;p&gt;There is a detail I did not expect, and the example already shows it: the target can be
reached with C alone (one large recording) or with A and D (two smaller ones). For a class
with many groups there is usually a huge number of subsets that give the optimal sum, and
the way one of them is chosen is not neutral. There are many more optimal combinations with
many small groups than with a few large ones, so small groups end up in test more often: the
shortest 10 % of the recordings end up in test 40 % of the time instead of 30 %. I also tried
sampling uniformly among all the optimal subsets, by counting the solutions in the table, and
the bias was even larger.&lt;/p&gt;
&lt;p&gt;The solution is to ask one more thing of the subset: that it also contain 30 % of the
&lt;strong&gt;groups&lt;/strong&gt;. If test has 30 % of the windows and 30 % of the groups, the mean size of its
groups has to be the same as that of the class, and the advantage of the small ones
disappears. In the example, 30 % of 5 recordings, rounded, is 2, so only the A + D solution
remains: C alone has the right sum, but it is a single group.&lt;/p&gt;
&lt;p&gt;In dynamic programming terms, that means adding a dimension to the table: the number of
chosen groups. Each cell &lt;code&gt;reach[i, k, s]&lt;/code&gt; now says whether the sum &lt;code&gt;s&lt;/code&gt; can be reached using
exactly &lt;code&gt;k&lt;/code&gt; of the first &lt;code&gt;i&lt;/code&gt; recordings. It is like having a table like the one in the
figure for each value of &lt;code&gt;k&lt;/code&gt;, and taking a recording means moving one position in &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt;
positions in &lt;code&gt;s&lt;/code&gt; at the same time:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#616972;--1:#949EA8&quot;&gt;# reach[i, k, s]: k of the first i groups add up exactly to s&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; np.zeros((n &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, m &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, S), &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;dtype&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;bool&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; i, w &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;enumerate&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;(sizes, &lt;/span&gt;&lt;span style=&quot;--0:#AE4B07;--1:#F69D50&quot;&gt;start&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;):&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[i] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;reach[i, &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;:, w:] &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;|=&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; reach[i &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, :&lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#005CC5;--1:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt;, :S &lt;/span&gt;&lt;span style=&quot;--0:#BF3441;--1:#F5776E&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#24292E;--1:#ADBAC7&quot;&gt; w]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;# reach[i, k, s]: k of the first i groups add up exactly to sreach = np.zeros((n + 1, m + 1, S), dtype=bool)reach[0, 0, 0] = Truefor i, w in enumerate(sizes, start=1):    reach[i] = reach[i - 1]    reach[i, 1:, w:] |= reach[i - 1, :-1, :S - w]&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;with &lt;code&gt;m = round(0.3 * n)&lt;/code&gt; and &lt;code&gt;S&lt;/code&gt; just above the target, because there is no need to record
larger sums. The reconstruction is the same, keeping track of &lt;code&gt;k&lt;/code&gt;. With this constraint the
per-class fraction is still practically equal to the target (the tracked vehicle class ends up at 30.4 %),
the probability of ending up in test is fairly even (between 0.27 and 0.34 in all size
deciles), and the time does not change: about 0.1 s.&lt;/p&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Five panels, one per method, with the fraction of times in test by size decile and the reference at 0.3. GroupShuffleSplit, StratifiedGroupKFold and the optimal with a fixed recording count stay close to 0.3; the greedy with dummy gives 0 and 0.04 in the two longest deciles and about 0.5 in the rest; the optimal rises to 0.4 in the shortest decile.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2169&quot; height=&quot;783&quot; src=&quot;https://blog.francoalcaraz.com/_astro/size_bias.BJn2QuRO_ZMusju.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Fraction of times a recording ends up in test according to its size, with each method (without the noise class, whose recordings all have the same size).&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;how-much-does-leakage-matter&quot;&gt;How much does leakage matter?&lt;/h2&gt;
&lt;p&gt;Everything so far is about how to build the split. The underlying question remains: how
much do the performance metrics change if the split is done wrong? To measure it I trained
&lt;em&gt;pollito&lt;/em&gt;, the convolutional network from the thesis (about 4 M parameters), with three
different splits, and repeated everything with 5 seeds.&lt;/p&gt;
&lt;p&gt;Here is a bit of the process. First I set aside 20 % of the recordings of each class as an
external set, used for nothing but measuring at the end. With the remaining 80 % I built
three 70/30 splits: by frames, with stratified &lt;code&gt;train_test_split&lt;/code&gt;; by time, cutting each
recording and sending one portion to test (about 12 % of the windows are lost, those that
cross the cut); and by recordings, with the dynamic programming method with a fixed number
of groups. The model was trained for 40 epochs, without early stopping and without choosing
weights by looking at test.&lt;/p&gt;
&lt;aside class=&quot;recuadro&quot; data-tipo=&quot;nota&quot;&gt;&lt;p class=&quot;recuadro-titulo&quot;&gt;A note on the thesis&lt;/p&gt;&lt;p&gt;In the thesis, the partition I called &lt;em&gt;test&lt;/em&gt; was also used to decide when to stop training and which weights to keep. In practice it played the role of a validation set, and the figures reported on it should be read with that nuance: they are somewhat optimistic. In this experiment I separated those roles: no decision is made by looking at test, and the external set stays completely out.&lt;/p&gt;&lt;/aside&gt;
&lt;p&gt;The results, as per-window accuracy (mean and range over the 5 seeds):&lt;/p&gt;





























&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Split&lt;/th&gt;&lt;th&gt;Internal test&lt;/th&gt;&lt;th&gt;Never-seen recordings&lt;/th&gt;&lt;th&gt;Difference&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;By frames&lt;/td&gt;&lt;td&gt;96.5 % (95.2–97.3)&lt;/td&gt;&lt;td&gt;88.5 % (86.0–91.5)&lt;/td&gt;&lt;td&gt;8.0 points (5.4–10.2)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;By time&lt;/td&gt;&lt;td&gt;86.6 % (80.6–90.2)&lt;/td&gt;&lt;td&gt;83.0 % (77.1–88.3)&lt;/td&gt;&lt;td&gt;3.6 points (1.8–5.7)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;By recordings&lt;/td&gt;&lt;td&gt;87.6 % (86.4–89.4)&lt;/td&gt;&lt;td&gt;87.2 % (82.3–89.9)&lt;/td&gt;&lt;td&gt;0.4 points (−0.9–4.1)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;figure class=&quot;figura figura-ancha&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Three panels with the accuracy on the internal test and on never-seen recordings, one line per seed and the mean highlighted: by frames it drops from 96.5 % to 88.5 %; by time, from 86.6 % to 83.0 %; by recordings, from 87.6 % to 87.2 %.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2110&quot; height=&quot;937&quot; src=&quot;https://blog.francoalcaraz.com/_astro/leakage.CShhnwrZ_ZuVy1y.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Accuracy on the internal test set and on never-seen recordings, with each way of splitting.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;With the &lt;strong&gt;split by frames&lt;/strong&gt;, the internal test says something close to 96 %. On recordings
the model never saw, the real number is around 88 %. The difference, about 8 points, is
exactly what leakage adds: the model recognizes windows almost identical to the ones it saw
during training. With the &lt;strong&gt;split by recordings&lt;/strong&gt;, on the other hand, the internal test and
the external set give practically the same result, which is what we expect from a good
estimate.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;time cut&lt;/strong&gt; sits in between. Removing the overlap eliminates most of the leakage, but
not all of it: the internal test still promises about 3.6 points more than what the model
achieves on new recordings, and that difference shows up in all 5 seeds. This is &lt;strong&gt;what the
similarity between windows anticipated&lt;/strong&gt;: a portion of the same recording a few seconds later
is not a duplicate, but it is more similar than any other recording. This model also did
somewhat worse on new recordings (83.0 %), partly because it trains on fewer windows and
partly because of two seeds that came out quite a bit lower.&lt;/p&gt;
&lt;p&gt;What surprised me was the other comparison. On new recordings, the model trained with the
split by frames did not do worse than the other one (88.5 % versus 87.2 %, a difference
smaller than the variation between seeds). It makes sense: by splitting windows, that model
gets to see at least part of almost every recording, and it trains on more variety. In other
words, &lt;strong&gt;leakage did not make the model worse, it made the measurement of its performance
worse&lt;/strong&gt;. And that is more serious than it seems, because the measurement is what we use to
compare alternatives, choose hyperparameters and decide whether the system is ready.&lt;/p&gt;
&lt;p&gt;There is one more thing worth looking at: with the correct split, the result on never-seen
recordings ranged from 82 % to 90 % depending on the seed, that is, depending on which
recordings landed in each set. With 569 recordings, a single split can move the result by
several points. That is why it is worth repeating with several seeds, and for that the
splitting method needs to produce different splits with each seed.&lt;/p&gt;
&lt;h2 id=&quot;comparison-and-recommendations&quot;&gt;Comparison and recommendations&lt;/h2&gt;
&lt;p&gt;Results on this dataset (&lt;em&gt;coronita&lt;/em&gt;, 6 classes), with 100 seeds per method. “Test per class”
is the test fraction in each class, with its worst deviation; “Tracked” is that fraction for
the class with 9 recordings; “Longest 10 %” is the fraction of times those recordings end up
in test, not counting the noise class (ideally 0.30). The optimal version without the count
constraint over-represents the shortest recordings (0.40); StratifiedGroupKFold was used by
joining 3 of 10 folds.&lt;/p&gt;






















































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Method&lt;/th&gt;&lt;th&gt;Test per class&lt;/th&gt;&lt;th&gt;Tracked&lt;/th&gt;&lt;th&gt;Longest 10 %&lt;/th&gt;&lt;th&gt;Leakage&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;By frames, at random&lt;/td&gt;&lt;td&gt;0.30&lt;/td&gt;&lt;td&gt;0.30&lt;/td&gt;&lt;td&gt;—&lt;/td&gt;&lt;td&gt;yes: 557 of 569 rec.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GroupShuffleSplit&lt;/td&gt;&lt;td&gt;0.30 ± 0.54&lt;/td&gt;&lt;td&gt;0 to 0.84&lt;/td&gt;&lt;td&gt;0.29&lt;/td&gt;&lt;td&gt;no&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;StratifiedGroupKFold&lt;/td&gt;&lt;td&gt;0.30&lt;/td&gt;&lt;td&gt;0.415&lt;/td&gt;&lt;td&gt;0.33&lt;/td&gt;&lt;td&gt;no&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Greedy with dummy&lt;/td&gt;&lt;td&gt;0.30&lt;/td&gt;&lt;td&gt;0.315&lt;/td&gt;&lt;td&gt;0.00&lt;/td&gt;&lt;td&gt;no&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Optimal&lt;/td&gt;&lt;td&gt;0.30 ± 0.0005&lt;/td&gt;&lt;td&gt;0.2995&lt;/td&gt;&lt;td&gt;0.29&lt;/td&gt;&lt;td&gt;no&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Optimal, fixed recording count&lt;/td&gt;&lt;td&gt;0.30 ± 0.004&lt;/td&gt;&lt;td&gt;0.304&lt;/td&gt;&lt;td&gt;0.32&lt;/td&gt;&lt;td&gt;no&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;figure class=&quot;figura&quot;&gt;&lt;p&gt;&lt;img alt=&quot;Maximum deviation in percentage points: GroupShuffleSplit 53.8; StratifiedGroupKFold 11.5; greedy with dummy 1.5; optimal with fixed recording count 0.39; optimal 0.05; by frames 0.05.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1709&quot; height=&quot;838&quot; src=&quot;https://blog.francoalcaraz.com/_astro/test_deviation.CgvukjtK_26Lbeg.webp&quot;&gt;&lt;/p&gt;&lt;figcaption&gt;Maximum deviation of the test fraction from 30 %, with each method (logarithmic scale).&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;My recommendations, then:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Never&lt;/strong&gt; split at random data that comes from the same domain sample. It is the only
mistake on this list that invalidates the evaluation: in this case, the test set promised
about 8 points more than what the model achieved on new recordings.&lt;/li&gt;
&lt;li&gt;Cutting each group in time and separating the portions removes the duplicates, but it is
not enough if in production the whole group will be new: here the test stayed inflated by
about 3.6 points. It only makes sense when the model will work on the same individuals it
saw (for example, predicting the future of a machine it already knows).&lt;/li&gt;
&lt;li&gt;If groups have a single class and the per-class totals are in the thousands of examples,
the &lt;strong&gt;optimal solution with a fixed number of groups&lt;/strong&gt; gives proportions practically equal to
the target, without size bias, in a fraction of a second.&lt;/li&gt;
&lt;li&gt;For cross-validation, or if groups have several classes, &lt;strong&gt;&lt;code&gt;StratifiedGroupKFold&lt;/code&gt;&lt;/strong&gt; is the
natural option. It is worth checking classes with few groups by hand.&lt;/li&gt;
&lt;li&gt;If the totals are too large for dynamic programming (hundreds of thousands of examples per
class), a &lt;strong&gt;greedy heuristic&lt;/strong&gt; is still reasonable, but it is worth checking how the large
groups were distributed.&lt;/li&gt;
&lt;li&gt;In any case, measure on your own dataset the same things as in this article: the
fractions per class and in which partition the groups end up according to their size. It
takes two lines of pandas and avoids surprises.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;closing&quot;&gt;Closing&lt;/h2&gt;
&lt;p&gt;Solving this problem does not require a complicated algorithm. What matters is not to
confuse the training data with the domain samples it comes from, to decide which unit will
be new in production, and to choose the tool according to the size and structure of the
groups. To go further into partitioning into more than two sets, the Karmarkar–Karp
heuristic &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-karmarkar1982&quot; title=&quot;Karmarkar &amp;#x26; Karp (1982). The differencing method of set partitioning&quot; class=&quot;cita&quot; id=&quot;cita-karmarkar1982&quot;&gt;6&lt;/a&gt;]&lt;/span&gt; and optimal algorithms for multi-way partitioning &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-korf2009&quot; title=&quot;Korf (2009). Multi-way number partitioning&quot; class=&quot;cita&quot; id=&quot;cita-korf2009&quot;&gt;7&lt;/a&gt;]&lt;/span&gt; are good starting points.&lt;/p&gt;
&lt;p&gt;The previous article of the series, &lt;a href=&quot;https://blog.francoalcaraz.com/en/raw-signal-to-classifier/&quot;&gt;&lt;em&gt;From the raw signal to a real-time classifier&lt;/em&gt;&lt;/a&gt;,
explains how this split was used within the complete work.&lt;/p&gt;
&lt;h2 id=&quot;data&quot;&gt;Data&lt;/h2&gt;
&lt;p&gt;The original dataset is “The Database of Radar Echoes from Various Targets”, from the Signal
Processing Laboratory of Ben-Gurion University of the Negev &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-spl&quot; title=&quot;Signal Processing Laboratory, Ben-Gurion University of the Negev. The Database of Radar Echoes from Various Targets&quot; class=&quot;cita&quot; id=&quot;cita-spl&quot;&gt;8&lt;/a&gt;]&lt;/span&gt;; the windows and
spectrograms are the ones generated in the thesis &lt;span class=&quot;citas&quot;&gt;[&lt;a href=&quot;#ref-alcaraz2026&quot; title=&quot;Alcaraz (2026). Classification of Doppler Signals from Radar Echoes Using Deep Learning&quot; class=&quot;cita&quot;&gt;1&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;This article was originally written by me in Spanish and translated into English using the
Claude Opus 5.5 model (Anthropic).&lt;/em&gt;&lt;/p&gt;&lt;section class=&quot;referencias&quot; aria-labelledby=&quot;referencias&quot;&gt;&lt;h2 id=&quot;referencias&quot; class=&quot;referencias-titulo&quot;&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li id=&quot;ref-alcaraz2026&quot; value=&quot;1&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Alcaraz, F. A. (2026). &lt;i&gt;Classification of Doppler Signals from Radar Echoes Using Deep Learning&lt;/i&gt;. Master&apos;s thesis in Engineering, revised English edition, Instituto Balseiro, Universidad Nacional de Cuyo. &lt;a href=&quot;https://doi.org/10.5281/zenodo.23227057&quot;&gt;https://doi.org/10.5281/zenodo.23227057&lt;/a&gt; &lt;a href=&quot;#cita-alcaraz2026&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 1&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-kaufman2012&quot; value=&quot;2&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[2]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Kaufman, S., Rosset, S., Perlich, C., &amp;#x26; Stitelman, O. (2012). Leakage in data mining: formulation, detection, and avoidance. &lt;i&gt;ACM Transactions on Knowledge Discovery from Data&lt;/i&gt;&lt;i&gt;, 6&lt;/i&gt;(4).  &lt;a href=&quot;#cita-kaufman2012&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 2&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-roberts2017&quot; value=&quot;3&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[3]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Roberts, D. R., et al. (2017). Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure. &lt;i&gt;Ecography&lt;/i&gt;&lt;i&gt;, 40&lt;/i&gt;(8), 913–929.  &lt;a href=&quot;#cita-roberts2017&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 3&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-garey1979&quot; value=&quot;4&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[4]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Garey, M. R., &amp;#x26; Johnson, D. S. (1979). &lt;i&gt;Computers and Intractability: A Guide to the Theory of NP-Completeness&lt;/i&gt;. W. H. Freeman.  &lt;a href=&quot;#cita-garey1979&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 4&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-sklearn&quot; value=&quot;5&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[5]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;scikit-learn (n.d.). &lt;i&gt;StratifiedGroupKFold: documentation and source code of version 1.9.1&lt;/i&gt;. &lt;a href=&quot;https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedGroupKFold.html&quot;&gt;https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedGroupKFold.html&lt;/a&gt; &lt;a href=&quot;#cita-sklearn&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 5&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-karmarkar1982&quot; value=&quot;6&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[6]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Karmarkar, N., &amp;#x26; Karp, R. M. (1982). &lt;i&gt;The differencing method of set partitioning&lt;/i&gt;. Technical Report UCB/CSD 82/113, University of California, Berkeley.  &lt;a href=&quot;#cita-karmarkar1982&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 6&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-korf2009&quot; value=&quot;7&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[7]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Korf, R. E. (2009). Multi-way number partitioning. &lt;i&gt;Proceedings of IJCAI&lt;/i&gt;.  &lt;a href=&quot;#cita-korf2009&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 7&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-spl&quot; value=&quot;8&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[8]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Signal Processing Laboratory, Ben-Gurion University of the Negev (n.d.). &lt;i&gt;The Database of Radar Echoes from Various Targets&lt;/i&gt;. &lt;a href=&quot;http://www.ee.bgu.ac.il/~spl/&quot;&gt;http://www.ee.bgu.ac.il/~spl/&lt;/a&gt; &lt;a href=&quot;#cita-spl&quot; class=&quot;ref-volver&quot; aria-label=&quot;Back to citation 8&quot;&gt;↩&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id=&quot;ref-alcaraz2020&quot; value=&quot;9&quot;&gt;&lt;span class=&quot;ref-numero&quot; aria-hidden=&quot;true&quot;&gt;[9]&lt;/span&gt;&lt;span class=&quot;ref-texto&quot;&gt;Alcaraz, F. A. (2020). &lt;i&gt;Clasificación de Señales Doppler de Ecos Radar usando Deep Learning&lt;/i&gt;. Master&apos;s thesis in Engineering (original Spanish version), Instituto Balseiro, Universidad Nacional de Cuyo. &lt;a href=&quot;https://doi.org/10.5281/zenodo.23226363&quot;&gt;https://doi.org/10.5281/zenodo.23226363&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;</content:encoded><category>Article</category><category>machine-learning</category></item></channel></rss>