If you’ve ever tried to get in shape, you know how difficult it can be to develop a regular exercise habit. At first, just changing into your workout clothes and getting yourself to the gym seems to take an inordinate amount of effort, and the actual exercising may feel uncomfortable and awkward. But gradually, if you stick with it, you not only see improvement in your physical condition, but even begin to look forward to your regular workouts.
A popular myth says that if you stick with a new behavior for 21 days, it becomes permanent, but this isn’t based on scientific research.
But how long does it take to make exercising a habit? There’s a popular myth that if you stick with a new behavior for 21 days, it becomes permanent, but that guestimate isn’t based on scientific research. That’s why I and my colleagues at several U.S. universities decided to investigate the subject of habit formation using a powerful tool—machine learning, a branch of AI and computer science which utilizes data and algorithms to mimic the way that humans learn. Our paper marks the first time that machine learning has been used to study how humans develop habits in natural settings.
Our paper is the first to use machine learning to study how people form habits in real-world situations.
What we learned about habit formation refuted popular wisdom. As it turns out, it appears that there isn’t a single magic number of days, weeks or months for establishing a new habit. To the contrary, when we studied the development of two different behaviors, we found very different time spans were required for each one to become predictable. Exercising appears to take several months to become habitual. In contrast, handwashing – the other behavior we analyzed - is predictably executed over a much shorter time span, a few days to weeks.
How we studied gym goers and hand-washers
In the past, one of the limitations of habit research has been that researchers have depended upon participants filling out surveys to record what they do, a methodology that typically limits sample size and may introduce noise. In our research, by using large datasets that rely on automatically recorded behavior—for example, exercisers swiping their badges to enter a fitness center—and then using machine learning to make sense of the data, we were able to study a larger group of people over longer time periods in a natural environment.
In addition, by using machine learning, we don’t necessarily have to start with a hypothesis based upon a specific variable. Instead, we’re able to observe hundreds of context variables that may be predictive of behavioral execution. Machine learning essentially does the work for us, finding the relevant predictors.
To study exercisers’ habit formation, we partnered with 24 Hour Fitness, a major North American gym chain, to study anonymized data about gym use. Our dataset spanned a 14-year-period from 2006 to 2019, and included about 12 million data points collected from more than 60,000 users who had consented to share their information with researchers when they signed up to be in a fitness program. We were able to look at a long list of variables, ranging from the number of days that had elapsed between visits to the gym, to the number of consecutive days of attendance on the same day of the week. We whittled down the participants to about 30,000 who had been members for at least a year, and studied their behavior from the first day that they joined the gym.
To study hospital workers’ formation of hand-washing as a habit, we obtained data from a company that employed radio frequency identification (RFID) technology to monitor workers’ compliance with sanitary rules. Each data point had a timestamp, as well as anonymized hospital and room locations. This enabled us to look at the behavior of more than 3,000 workers in 30 hospitals over the course of a year.
What affects habit formation
We discovered that certain variables had very little effect on the formation of a habit, whereas other factors turned out to matter a lot. For example, for about three-quarters of the subjects, the amount of time that had passed since a previous gym visit was an important indicator of whether they would show up to the gym. The longer it had been since they’d worked out, the less likely they were to make a habit of it. Additionally, we found that the day of the week was highly predictive of gym attendance, with Monday and Tuesday being the strongest predictors.
We discovered that certain variables had very little effect on the formation of a habit, whereas other factors turned out to matter a lot.
We also studied the impact of the StepUp Challenge, a behavioral science intervention intended to increase gym attendance, whose designers included two of the researchers on our team. That analysis yielded an interesting insight. The motivational program had a greater effect on less predictable gym-goers than it did on ones who had already established a regular pattern, echoing a finding in the habit literature that habits may make people less sensitive to changes in rewards.
With hospital workers and hand-washing, we discovered that habit formation came more quickly—usually within about two weeks, with most hospital staff forming habits after nine to 10 hospital shifts. The most important predictor of hand-washing was whether workers had complied with hand-washing rules on the previous shift. We also found that 66 percent of workers were influenced by whether others complied with hand-washing rules, and that workers were most likely to wash their hands upon exiting rooms rather than when they entered them.
That raises the question: Why did workers develop the hand-washing habit so much more quickly than gym goers developed the workout habit? One possible explanation is that compared to hand-washing, going to the gym is a less frequent and more complex sort of behavior. Hand-washing is more likely to involve chained sensorimotor action sequences, which are more automatic. Once you get in the habit of washing your hands, you may do it without even thinking. Going to the gym, in contrast, is something that still requires time, planning and intention, even after it’s become a familiar part of your lifestyle.