The Intelligent Friend - The newsletter that explores how AI changes our daily lives, through scientific research.
Have you have included the gym among our New Year's resolutions? Probably, you are not alone. According to the Pew Research Center, in 2024, 79% of Americans who had made New Year's resolutions had made one regarding exercise, diet or health. But making the gym a constant part of our daily life is not easy.
Maybe we leave the workplace after a hard day and the only thing we would like to do is watch our favorite sitcom. Or have a coffee with friends. Or, for instance, read a good book. In short, we would like the gym to become a habit1, but we don't know exactly how to do it. Is there a magic number of days in which we should, for example, force ourselves to go so that everything will be more "downhill" afterwards? Maybe, we could give ourselves little reminders to support us or try other specific incentives.
There are many fascinating scientific studies on habits, as well as many books on the subject (Charles Duhigg, who write a great newsletter here on Substack, has written a great book on the subject). However, keeping track of our habits and how they evolve is not easy. Especially, when you want to look "out the window" and get ideas and results directly from the real world. In this case, we should try to seize the opportunity to analyze large amounts of data, and observe and report the results of the analysis, revealing more about the habit formation process. Cold we get insights from this kind of data? With the right tools, could we map the journey from intention to instinct?
This is precisely what Anastasia Buyalskaya and her colleagues set out to explore in their groundbreaking study2, protagonist of today’s issue, using advanced machine learning techniques to uncover how habits form in real-world settings.
The study focuses on two behaviors, gym attendance and handwashing among hospital workers, and reveals, thanks to machine learning, fascinating insights about our habit formation process.
An AI detective for habits
Imagine you are a detective. You are in an old study in a beautiful Victorian house. There has been a murder. You begin to observe. The spilled coffee cup on the table, the scuff marks on the floor, the way the window handle is slightly ajar: each clue can give you a fragment of the story. However, it may be that details, taken in isolation, do not provide you with any real value as to what happened. The point is, instead, to look at the larger scheme. In this sense, you probably will not start from a priori assumptions, but you will try to reconstruct each element and understand which may have played a role, what role, and with what weight. In essence, you sift through the various possibilities, trying to arrive at the solution without preconceptions.
In in a way, this could be an interesting analogy for what Predicting Context Sensitivity, or PCS, does, investigating human habits. This is a particular approach adopted, and operated through machine learning, by the authors. Through this method, the authors analyzed massive datasets - over 12 million gym visits and 40 million handwashing episodes - to determine what drove predictability in the two target behaviors.
However, a peculiarity of PCS is that, like the detective, it doesn’t start with fixed assumptions about which factors matter most. Instead, it “lets the data speak”, uncovering patterns across a range of context variables like the day of the week or time since the last behavior. In essence, PCS acts as a digital detective, sifting through countless possibilities to pinpoint what makes some habits stick and others falter.
Is there a ”magic” number of days for habits?
Researchers found that gym habits often take months to form, while handwashing habits solidify in weeks.
This result, as underlined by the authors, challenges the idea that there is a more or less indicative “magic” number of days for habits to form.
There can be an important variety based on behavior. It’s not just about frequency, though that plays a role. For example, handwashing is a simpler, more repetitive action embedded in a structured routine, like a hospital shift. Gym attendance, on the other hand, requires more planning, effort, and emotional investment. This could significantly and heavily impact the habit formation process.

Furthermore, the results also highlight an intriguing relationship between habit strength and responsiveness to change.
Gymgoers with well-established habits - those whose attendance was highly predictable - were less likely to respond to incentives like free workout programs. This suggests that once a habit is deeply ingrained, external rewards become less impactful.
So, if your “gym-obsessed” friend Carl, Lucas, or Tom tells you that free programs aren’t for him, he might be sincere. Individuals like Tom, Lucas or Carl can operate on autopilot, driven by an internal rhythm rather than external motivators.
For new gymgoers, however, incentives like free classes or milestone rewards were found to be much more effective, emphasizing the importance of early-stage support in habit formation.
For hospital workers, instead, the patterns were different but equally revealing. The strongest predictor of handwashing behavior wasn’t just personal consistency but also the behavior of others in the same room.
This finding underscores the social dimensions of habit formation: environments matter, and behaviors are contagious. In rooms where handwashing rates were high, compliance tended to rise collectively.
As you may have understood, therefore, the habits and factors influencing the processes, at least from the results of this study, can vary greatly. It is not black and white, but there are many shades of gray.
And in fact one of the enlightening idea emerging from this is that habits are not binary either present or absent - but instead develop as a continuum. Over time, behaviors become more predictable, reflecting the gradual strengthening of routines.
A final note
I found this research absolutely fascinating for the way in which through a deep and broad analysis at the same time it shows an integration of machine learning to scientific research. In addition to being a very relevant topic - habits - it allowed me to put my first piece of "done!" on the New Year’s Resolution of writing more about the relationship of AI and science and bring you broader perspectives on the impact of AI. I am eager to know your opinions: if you want, take 30 seconds to tell what you think in the comments or by replying to this email.
The Highlight 🔦
This is the section where I highlight some of the great issues I read during the week from other authors on Substack, and that I would like to share with you.
Did you see red and feel hungry? In the new issue of
, you will discover what research says about the strength of some colors.
Clarity, ideas and depth on research methods (and not only) by
.
Another fantastic practical guide resulting from the collaboration of
and .
Other enlightening references
Volpp, K. G., & Loewenstein, G. (2020). What is a habit? Diverse mechanisms that can produce sustained behavior change. Organizational Behavior and Human Decision Processes, 161, 36-38.
Mazar, A., & Wood, W. (2022). Illusory feelings, elusive habits: People overlook habits in explanations of behavior. Psychological Science, 33(4), 563-578.
Staats, B. R., Dai, H., Hofmann, D., & Milkman, K. L. (2017). Motivating process compliance through individual electronic monitoring: An empirical examination of hand hygiene in healthcare. Management Science, 63(5), 1563-1585.
Thank you for reading this issue of The Intelligent Friend and/or for subscribing. The relationships between humans and AI are a crucial topic and I am glad to be able to talk about it having you as a reader.
Has a friend of yours sent you this newsletter or are you not subscribed yet? You can subscribe here.
Surprise someone who deserves a gift or who you think would be interested in this newsletter. Share this post with your friend or colleague.
Fleetwood, S. (2021). A definition of habit for socio-economics. Review of social economy, 79(2), 131-165.
Buyalskaya, A., Ho, H., Milkman, K. L., Li, X., Duckworth, A. L., & Camerer, C. (2023). What can machine learning teach us about habit formation? Evidence from exercise and hygiene. Proceedings of the National Academy of Sciences, 120(17), e2216115120.
Thanks for the mention, Riccardo! Love your work!
Dear Riccardo, thank you for sharing this. I enjoyed reading it and found it to be a very interesting approach to simply "let the data speak" without prior theoretical assumptions that might constrain your thinking and potential conclusions.
The idea that habits develop as a continuum is quite intriguing!
I work as a psychotherapist, and while we don't have as much data available, I am sure that there are hidden gems to find in the data present in sessions, documentation, and questionnaires.