Yoga Sutras 8 limbs linked to data science, development, and machine learning engineering [part II]

Dr Richard Freeman
10 min readJan 25, 2023

--

With a PhD in data science, 19 years on web scale AWS/data/ML/NLP solutions and ten years of experience with yoga, I thought it would be fun to map out the “eight limbs of yoga” against my passion of data/ML engineering, big data and data science.

Vamstar Team doing Yoga in Goa — Credits Dr Richard Freeman

I am into the practice and teaching of yoga, and when you dig deep into yoga you find that it is not just strength, flexibility and wellbeing, along with amazing poses, but a much deeper spiritual practice as described by author, mystic and philosopher Patanjali in the 4th century C.E.

In part one we saw the first two limbs of yoga, the 1st was the YAMA with the things not to do like being aggressive, lying, stealing, wasting energy/effort, greedy and the 2nd NIYAMA with the positive of cleaness, attitude, fire-powered transformation, self-study, and learning from seniors. Let’s now explore the remaining six limbs of yoga mapped to data/machine learning engineering and data science.

3. ASANA — Posture

In the West, yoga tends to skip the eight limbs and start with poses as is portrayed by the media and promoted for strength, flexibility and wellbeing. In my view, in asana you ground yourself in the present moment and you watch the thought patterns, emotions, and physical sensations in the body to eventually reach balance.

Do you have a good posture with a straight back, shoulders down, neck tucked in and straight neck right now? If not, why? There are good and bad postures at a desk. Or you can get a standing desk like we used at JustGiving and took turns with. Or perhaps put a cardboard box under your laptop to make a low budget standing desk or even use full cardboard boxes.

The parallel of technology with yoga are components, systems, modules and platforms that need to be well designed and architected for scale and reuse. Another similarity to good yoga asanas are ones that are secure, challenging, and adapted to the yogi.

Software design patterns are like blue prints that can help speed up your delivery and also speak the same language as other software engineers. For example, if I ask a developer to modify their code to use the “Singleton Pattern as your objects are taking up too much memory”, they will know exactly what I mean and make the changes.

As a data scientist you need to have the hypothesis testing mindset, and standard data exploration patterns. Think about how the model will be deployed and monitored, and return on investment. I talk about some of these in my posts on when and when not to use AI, and Recommendations for Working in Data Science, AI and Big Data Based on my Personal Experience.

Also, move beyond the code into full architecture, understanding areas like architecting non-functional properties such as performance, scalability, reliability, and security. This software architecture course for example covers some of the areas but there are many others, and the knowledge can only be acquired through experience and practice, not just theory.

Here are a few quick pointers to more asanas that you can lookup (each could be a blog post of their own): scale out architecture,
software design patterns and principles, microservices, microsites, model versioning and deployment, feature stores, Bayesian optimisation, Responsible AI, multi-armed bandit testing. distributed tracing, centralised logging and alerting, infrastructure as code, infrastructure/data/concept drift detection, service mesh, domain-driven design especially CQRS and bounded context. My video course, Implementing Serverless Microservices Architecture Patterns, covers some of these but you will find lots of content out there in blog posts, courses, books, and videos.

There is significant supporting science on the benefit of yoga such as on cancer, diabetes, and cardiovascular patients, and some interesting research on standing and treadmill desks

4. PRANAYAMA — Breathing Techniques

In yoga the breath is important and aligns with the asanas, whether it is in ashtanga and vinyasa where it flows, or a more yin posture where the breath is used to relax the body into a deep stretch. Breath is our life force energy which we cannot live without for more than a few minutes.

Working in tech is no different to yoga, breath is central. You will see that stressed people have shallow breath, so why not breathe using Ujjayi when you feel tension that causes impatience and stress? Also be aware that you can be stressed when problem solving or are under time constraints. You can also be affected by those around you who may be creating a tense environment. Be aware and use a pranayama technique.

There is scientific research around the effect of unilateral nostril breathing on the brain, which leads to a reduction on stress, regulation of the nervous system, and lowering of blood pressure. You have no excuses not to try it, there is plenty of scientific evidence based on measurable beneficial impacts on heart rate, brain waves, blood pressure, sleep, and galvanic skin resistance. So, if you feel stressed, just do some pranayama/breathing now!

5. PRATYAHARA — Sense withdrawal

Train yourself to look inwards. Instead of directing your senses to the outward environment, flip them to look in. In Kundalini yoga you will often have your eyes closed which helps you focus on your senses and body over comparing/competing with others. For example, close your eyes and see visions from inside yourself and observe your internal thought process. This is how Stephen Hawking visualised black holes, and Nikola Tesla saw inventions before creation. We choose where we direct and control our energy and attention rather than being pulled in many directions and being distracted.

Can you withdraw most of your senses to be focused on the project and problem solving? Can you become one with the computer and software?

In a similar way, whether you are writing code, doing data exploration, or architecting a solution, you should first think about the problem end-to-end. See how things fit together and anticipate any challenges. I will draw out diagrams, whether flows or relationship, logic first before looking at coding. Sometimes for simpler components I will outline the main logic flows in pseudo code as comments. In my view, it is critical to think through all areas so that when you discuss this with others you can ask the right questions.

Also, as a senior you are expected to take end-to-end ownership of a delivery, identifying all challenges, gaps, compromises, candidate solutions, estimates of resourcing time, and cost — even before coding or speaking with others.

Finally, withdrawing your senses could allow for better focus of time and mental power. This can allow for the minimisation of external distractions, thought fragmentation, and reduce multitasking as we have more control of where our energy goes.

There is scientific evidence that there is a neural-reorganisation following sensory loss, so why not use that extra power for problem solving, development and innovating.

6. DHARANA — Focused Concentration

Create a focus on a single point to hold the mind steady. In yoga this can be a candle, gaze, or breath, and see how you can hold the mind focused with energy and attention on where you want it to be. Do not get distracted with a jumping monkey mind. With practices like Trataka (point focus) and Dhishti (focused gaze), the saying is that “where the eyes go the mind goes”.

In my view multitasking is overrated, can you monotask with one task and full attention? Direct focused, outward energy to one task.

My mum used to say that because I had this massive ability to focus and concentrate, that I could do anything in life. It is true that focused concentration allows you to dive deeper in what you know from many angles, study what others have done, or even channel new ideas.

When I used to be a lead ML and Data Engineer in the tech for good company JustGiving, my team had a deep focus which was a challenge in an open WeWork environment. We sat next to the loud marketing and HR teams that worked from laptops, speaking across each others desks and desk phones, and used to talk to each other constantly. This was sometimes work related brainstorming but also much non-work talk. What was funny to observe was that my data science team had desktops PCs, hiding behind two big desktop screens and some of us (but not me) with noise canceling headphones. Some of the engineering and data problems are complex and need quiet time, inner reflection on your skills, experience, but also problem solving, especially if there is no known solution, API or modules you can leverage — particularly if you are the first to try and solve it.

If you put your scientific hat on, focused concentration has also supporting scientific evidence for example on meta analysis of brain regions and networks measured in MRI scans

7. DHYANA — Meditative Absorption

Meditative absorption is sustained attention on one chosen point in an uninterrupted train of thought. To get to inner stillness in yoga you first perform asanas, through our breath we regulate our energy, then anchor and focus our mind and slow the thoughts, sometimes with mantras to reach our inner wisdom and then beyond meditation to achieve bliss.

In yoga this is from meditation, but in technology you get so stuck with a complex problem you may at times believe there is no solution. At this point it is better to stop, meditate, or sleep on it. Or what I used to do at JustGiving, play table tennis to take your attention off the problem. Sometimes the right side of the creative brain needs to come back into focus from being stuck on the left side’s logic, which is limiting your problem solving and brainstorming skills.

Clear the mind using a silent or guided meditation to find a solution. In addition, based on your beliefs in that state of trance, you can ask the universe, source, God or your guides about the problem and await responses for guidance, signs, and synchronicities in stillness.

For the left-brain people the benefits of meditation are mainstream, there are over 16,000 publications and over 200 million people practicing, with sufficient scientific evidence around areas like brain activation during meditation including MRI scans — I think this helped the Mindfulness movement gain credibility.

8. SAMADHI — Bliss or Enlightenment

This eighth limb is related to union, awakening, and insight into a transcendental truth/reality. It is about bringing an end to suffering in the cycle of repeated reincarnation. Here I will bring samadhi up two layers and narrow it down to what you do as a job or role and the temporary happiness (over bliss) in this incarnation to keep it grounded. Other aspects are about oneness and union with everything around you, freedom from ego and judgements, focus in the present moment which are all good skills to have.

Say that the platform you have been working on goes live and it’s all coming together and all working. You have a great team, scaling under a heavy data load and the client is happy. This is happiness for a senior engineer or data scientist. It is really rewarding and a source of pride. True tech companies and leaders/CTOs will recognise this and the quality of the build but also so will you.

In my view as a developer or data scientist it is very simple: if after five years you don’t enjoy the challenge, problem solving, and learning, then find another job as this is probably not what you are meant to do. Find your true passion in life, or Dharma (life purpose). I always look for passionate people over people that are in it for the wrong reasons like money, job status, or as a stepping stone to non-tech roles.

  • Happiness for a data scientist will stem from how good the model works, making accurate predictions on complex problems and new use cases (see High Impact AI healthcare jobs from my experience), possibly also predicting something that has clear ROI and makes a difference to humanity.
  • For data engineers it will be seeing their components and platform scaling out beyond specification in the cloud, effortlessly. An example could be writing code that processes 1 billion rows in 2 minutes on 10 Spark nodes, scaling without changes to 1 trillion rows in 10 minutes but 1000 Spark nodes.
  • For any software engineer it will be elegant, functional, and minimalist code that is reusable, understandable, and well tested. Good code is like a well written book and it all just flows and makes sense to anyone that reads it.

Summary

In summary, I took on the challenge of mapping the eight limbs of yoga to data/machine learning engineering and data science by drawing parallels based on my deep experience of both. Yoga means union and we are all connected, with the aim to still the mind, witness consciousness and detach from suffering.

Whether work or hobby it’s very simple really, if you take pride in your work and enjoy it, then you are on the path. If not, find a new job that is challenging but makes a rightful difference in the world for you, regardless of pay or status. If you truly like your work, I am a strong believer that this then represents your Dharma (life purpose). Through any challenge, you will persevere because you love the work, the bigger vision, tech stack, and engineering challenge.

Likewise you will become an expert, so an important step is to not become arrogant with that knowledge but actually be open to sharing that knowledge with those who are starting or are less experienced. True mastery comes from then teaching others, this applies to any skill from yoga to data science. Being able to patiently teach, explain, and share is the pathway to happiness. Doing this in a scalable way will lead to you becoming a thought leader, but with the Dharma as a foundation you are sharing your passion — not just doing it for fame, status or money. That has been my career path since receiving my PhD. From working for global fortune 500 companies at Capgemini, to helping people find the right roles at PageGroup, to working on data science models in products that raised more for charities and non-profits at JustGiving, to co-founding Vamstar, a B2B healthcare marketplace powered by data science.

Really it’s about not doing what others tell you, or seeking status and money. It’s about finding challenges, doing what you love, teaching others, and sharing knowledge as widely as possible as you grow.

Be flexible in your body, mind and spirit like a Wolf Pack— Credits Dr Richard Freeman

Finally, remember the Brahmacharya and direction of your energy. In Kundalini Yoga terms, it’s about keeping this balanced by staying

  • Healthy: eat, drink, breath, sleep, exercise
  • Happy: positive, mentally balanced, stillness
  • Holy: sense of being connected to source, universe, bigger vision, actions

I passionately wish you to enjoy your life and tech journey.

Namaste

--

--

Dr Richard Freeman

Author, Advisor, Co-founder & CTO Data @ Vamstar, Series-A funded startup