Skip to main content
About HEC About HEC
Summer School Summer School
Faculty & Research Faculty & Research
Master’s programs Master’s programs
Bachelor Programs Bachelor Programs
MBA Programs MBA Programs
PhD Program PhD Program
Executive Education Executive Education
HEC Online HEC Online
About HEC
Overview Overview
Who
We Are
Who
We Are
Egalité des chances Egalité des chances
HEC Talents HEC Talents
International International
Campus
Life
Campus
Life
Sustainability Sustainability
Diversity
& Inclusion
Diversity
& Inclusion
Stories Stories
The HEC
Foundation
The HEC
Foundation
Summer School
Youth Programs Youth Programs
Summer programs Summer programs
Online Programs Online Programs
Faculty & Research
Overview Overview
Faculty Directory Faculty Directory
Departments Departments
Centers Centers
Chairs Chairs
Grants Grants
Knowledge@HEC Knowledge@HEC
Master’s programs
Master in
Management
Master in
Management
Master's
Programs
Master's
Programs
Double Degree
Programs
Double Degree
Programs
Bachelor
Programs
Bachelor
Programs
Summer
Programs
Summer
Programs
Exchange
students
Exchange
students
Student
Life
Student
Life
Our
Difference
Our
Difference
Bachelor Programs
Overview Overview
Course content Course content
Admissions Admissions
Fees and Financing Fees and Financing
MBA Programs
MBA MBA
Executive MBA Executive MBA
TRIUM EMBA TRIUM EMBA
PhD Program
Overview Overview
HEC Difference HEC Difference
Program details Program details
Research areas Research areas
HEC Community HEC Community
Placement Placement
Job Market Job Market
Admissions Admissions
Financing Financing
Executive Education
Home Home
About us About us
Management topics Management topics
Open Programs Open Programs
Custom Programs Custom Programs
Events/News Events/News
Contacts Contacts
HEC Online
Overview Overview
Degree Program Degree Program
Executive certificates Executive certificates
MOOCs MOOCs
Summer Programs Summer Programs
Youth programs Youth programs
Article

What Machine Learning Can Teach Us About Habit Formation

Marketing
Published on:

How long does it take to form a new habit, whether starting a yoga routine or flossing after brushing teeth? A wide-ranging study by Anastasia Buyalskaya from HEC Paris, Hung Ho of the University of Chicago, Xiaomin Li and Colin Camerer of California Institute of Technology, and Katherine L. Milkman and Angela L. Duckworth of the University of Pennsylvania, applies machine learning to answer that question.

Three key facts:

  1. Machine learning: The study uses large datasets and machine learning to uncover the diverse contextual variables influencing habit formation.
  2. Debunking the 21-days myth: There is actually not a fixed timeframe to establish new habits.
  3. Context matters: Certain variables had very little effect on the formation of a habit, whereas other factors turned out to matter a lot.
     
hand washing_cover

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.

 

Applications

The study analyzed how people form habits in natural settings. It is relevant for businesses looking to create “habit-forming” products for consumers, and managers looking to instill good habits in their employees.

Methodology

To get a better understanding how habits develop in natural settings, the researchers developed a machine learning methodology that was suitable for analyzing panel data with repeated observations of behavior. They utilized a Predicting Context Sensitivity (PCS) approach, which identified the context variables that best predict behavior for each individual. PCS uses a least absolute shrinkage and selection operator (LASSO) regression, a hypothesis-free form of statistical analysis which does not pre-specify what variables are likely to be predictive of an individual’s behavior. LASSO generated a person-specific measure of overall behavioral predictability, based on the variables that are predictive of that person’s behavior.
This article was based upon the paper “What can machine learning teach us about habit formation? Evidence from exercise and hygiene,” published in April 2023 in PNAS (Proceedings of the National Academy of Sciences), co-authored by Anastasia Buyalskaya with Hung Ho of the University of Chicago, Xiaomin Li and Colin Camerer of California Institute of Technology, and Katherine L. Milkman and Angela L. Duckworth of the University of Pennsylvania. In addition, other various published news sources were utilized.

Related content on Marketing

Sustainable Development
Reshaping Core Courses for Sustainability
Eloic Peyrache - HEC
Eloïc Peyrache
Professor, Dean
Marketing

Holding Advertisers to Account May Help Reduce Infant Deaths Linked to Unsafe Sleeping

By Anne Laure Sellier

Marketing

Going Circular to Align Business Models with Planetary Boundaries

By Daniel Halbheer

Louis Vuitton shop in Tokyo_thumbnail

©tupungato/123RF.COM

Marketing

Are Strong Brands Stressing Out Their Mid-level Employees?

By Dominique Rouziès