Machine learning and artificial intelligence is transforming the healthcare industry as we know it. Especially in the last year and half, being stuck inside one’s house has led to the manifold increase in the number of people seeking out for virtual wellness services. As a result, the wellness industry is said to increase further over the next four years. A growth of $1299.84 billion is expected between last year and 2024, at a CAGR of 6.37 percent during the forecast period.
With a growing industry in sight, California-headquartered Headspace tapped into artificial intelligence to improve health and wellness across the globe. Founded by former Buddhist monk Andy Puddicombe, and Richard Pierson in 2010, Headspace attempts to teach meditation and mindfulness at scale. The company offers guided meditation, mindfulness, sleep, exercise, and focus content through its web, Android and iOS applications.
Sign up for your weekly dose of what's up in emerging technology.
In its recent blog post, written by Yu Chen, Senior Software Engineer, and co-authored by Koyuki Nakamori, Senior Engineering Manager, Headspace reveals how it uses real-time machine learning to stay at the top of its game.
Leveraging Data in Real-time
Data is often ingested, transformed into the desired format, persisted and then made to sit idle until used by machine learning engineers and analytics teams. However, in order to make real-time decisions, user data has to be leveraged immediately. To ensure this, the Headspace team has drastically shortened the end-to-end feedback loop. User actions are analysed within seconds or minutes to generate relevant, personalised, and context-specific recommendations.
Headspace’s machine learning mode incorporates features that update throughout the day and even during sessions attended by each user. These features mostly direct to:
- On-going session bounce rates for sleep content
- Semantic embeddings for user search terms. Meaning, if a user searches for ‘Preparing for exam’, the model will assign focus-themed meditations
- Biometric data such as step count and pulse of individual users help the model provide personalised exercise content
The machine learning team at Headspace has developed a solution to cater to the personalised need of their users by breaking down the structure into publishing, receiver, orchestration, and serving layers. It leverages the following technologies:
- Apache Spark Structured Streaming on Databricks
- AWS SQS
Headspace uses lightweight Lambda functions to pack and unpack data in appropriate formats and invoke Sagemaker endpoints to perform post-processing and persistence. The architecture overview of Headspace is as shown below:
The engineers explain that events generated by users on the Headspace app are forwarded to the company’s Kinesis streams in order to be processed by Spark Structured Streaming. The app then fetches predictions by making RESTful HTTP requests on its backend services. It also transfers user IDs and feature flags to indicate the machine learning recommendations that need to be sent back.
Headspace re-trains its models by leveraging AWS deployment patterns and updating the Sagemaker model.
Blue Green Architecture
To avoid any disruptions during updates, Headspace has built a blue-green deployment model. That is, it maintains two parallel infrastructures or copies of feature stores. In addition, it designated one production environment to route requests for features and predictions towards it via Headspace’s Lambda.
Every time Headspace has to update its model, it uses a script to update the complementary infrastructure (as denoted by the blue environment in the illustration above) with the latest features. Once the update is done, the team switches the Lambda to point towards the updated (blue) environment. The team thus keeps repeating the process every time it has to update the model.
Thus, by enabling real-time inference, wellness company Headspace is able to drastically reduce the end-to-end feedback loop between the user entering the action and the app providing personalised suggestions.
To know about how Indian startups are revolutionising the healthcare industry using artificial intelligence and machine learning, click here.
Artificial intelligence, machine learning, meditation app, wellness app, Headspace, machine learning models, healthcare and wellness industry