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

Dr Richard Freeman
11 min readJan 8, 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 deep 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.

Kundalini yoga is aimed at helping you overcome physical challenges, transmute negativity, raise your life force and become much more grounded as a person. These are all skills that you need to be an efficient engineer and data scientist, which requires working long hours, evenings and sometimes weekends.

Back in the 4th century C.E. the author, mystic and philosopher Patanjali compiled the Yoga Sutras to make the path to bliss more accessible as the eight limbs of Yoga: yamas (abstinences), niyama (observances), asana (postures), pranayama (breathing), pratyahara (withdrawal), dharana (concentration), dhyana (meditation) and samadhi (absorption).

In this first post let’s explore the first two limbs of yoga along with my interpretation of how these link back to tech. After all Yoga does mean union so there should be a match!

1. YAMA — Restraints, moral disciplines or moral vows

Ahimsa (non-violence)

The non-violence can be to others but also to oneself and this can apply on every level thought, speech, behaviour, and decision we make.

Do not fight with others in your team, organisation or outside, everyone has a skill and can add value in some way, it is about respecting our differences. Yes, passive aggressiveness is also a form of violence and should be minimised. In addition, how you treat yourself (harmful thoughts, habits and weaknesses) can manifest in how you treat others, so be aware of that. Look at the subtle ways in which we might be violent or hard on ourselves. An example could be that we are stuck on a data problem and begin to consume more coffee, junk food, and start to think that you are not smart enough to be able to solve it or it’s too hard/complex/consuming (called Rumination in Psychology), when in reality this may not help your body and mind which are already overstimulated. In this scenario I may for example go back to a minimum working system and add back complexity progressive, or divide and conquer the problem.

We all can be partially wrong, or make mistakes. I love when rational arguments convince me that I am wrong about something, or that there is a better way to accomplish a task. I think that ignoring or being overly sensitive to constructive feedback will limit your growth and abilities and in some cases can touch narcissism. Sometimes it is a strength to work things out yourself but you also need to be put in check, get validation, and receive independent viewpoints to maintain balance.

For me the type of work arguments that are permissible are those that revolve around tech and are fact-based, these can actually be fun. In 2022, during Vamstar’s summit in Goa, I had a very spontaneous and fun tech fight between two passionate developer camps of Python and Node.js. We broke down the true weaknesses of both, one after the other, and what started as just two of us was joined by many more of the team and became unrivaled, respectful fun but with respect all along — this could have gone viral if we had captured it.

Satya (truthfulness)

Being truthful to others is about representing things the way they are. Being truthful can also be the decisions you make, such as not lying to yourself and trusting your gut feeling and intuition.

Speak out your truth but be ready to justify it with some facts and figures. Sometimes not everyone will agree and feelings may be hurt, but there is a constructive way to always provide feedback and express your views.

Truth could also be labeled as curiosity, asking questions to those more senior or knowledgeable than you. This is reflected in what you say as well as the actions you take and the thoughts that you have in and out of work. An example of speaking your truth could be:

  • Developer: Have I done my best to ensure the component works as per requirement, or have I taken short cuts. If so, did I express and document those short cuts to get the MVP out? Is this problem too hard for me, do I need help? Am I doing premature optimisations?
  • Data engineering: Have I tested all the big data edge case scenarios that have been observed? Have I checked if it will impact existing fields?
  • ML engineering: I don’t think the model the data scientist gave me will actually work? There is insufficient data and/or data preparation to make it work in a live environment.
  • Data analyst: Have I done quality assurance reporting at row level, data distribution, and time series before forming a hypothesis? Is there insufficient data for reporting? Will this analysis make sense from someone else’s perspective?
  • Data scientist: In time series forecasting, do I have data leakages? Have I ensured that the model will perform with real data and not just train/test/validation? Am I confident that the p-value has not been hacked? Is this inference task just not possible on the current or sampled data?

Also thinking about being truthful to yourself, know your weaknesses and strengths. Knowing how to express your truth is a strength, particularly when you have a novel ideal or disagree with another’s approach, idea or actions.

Asteya (non-stealing)

This can be non-stealing of physical items as well as time. Having unhealthy habits can result in stealing years from your life and affect those close to you.

Don’t get into the habit of stealing other people’s code, or taking others’ ideas without giving them credits. This has been a massive open source with many organisations taking but not giving back. It’s actually a strength to recognise the code, ideas, and work of others and extend it for your purpose.

Non-stealing is also about respecting the time of others and making the time with them meaningful. If you are interacting with a senior team member you should come prepared and avoid asking basic questions. Make yourself foundationally knowledgeable in order maximise these exchanges. It’s fine if you are from a different field, but for example as a junior data scientist avoid asking questions that you can easily answer yourself such as using Pandas + Scikit learn, it would be much more productive to have something up and running yourself before asking. That way you can ask about the challenges with the features in the provided dataset, low accuracy of model or how a fit() weighting parameter is not working — start the conversation at a fairly expert level.

In addition, I have seen experienced seniors providing tailored and valuable feedback about specific work to an external junior data scientist contractor, but the contractor was leaning back, not paying attention, and not taking any notes. This is a form of time stealing and even disrespectful.

Brahmacharya (right use of pure conduct/energy/non-excess)

One interpretation is about sexual conduct and celibacy but it can also be interpreted as the mastery of the kundalini energy from the sacral chakra. We all have a limited store of energy and ideally should be consciously aware where to direct that energy rather than having it consumed by the external environment (demands and expectations that dissipate your energy away). This is about practicing non-excess and keeping your life in balance between work, exercise, and sleep — enter each day with a sense of purpose and focus.

Focus on one area. When I go deep into complex Python development I need a continuous block of time, without interruptions (but I don’t mind chatter or music). Once you have done the right creative brainstorming, the energy and brain power is directed solely to finding and building a solution. For me I can have music and be in a loud open office space environment for development, but I know for others they need maximum silence with no distractions. So know yourself and be aware of your energy levels and what affects them.

The sacral energy can be wasted, or used to create something new and exciting. To stay true to one’s self and values is critical for building what you believe in.

As Joe Dispenza says “learn how to manage your energy, where you place your attention is where you place your energy”. And more along those lines, “thoughts and emotions” are what allow you to manifest and ground your ideas, inventions, and solutions into reality.

Aparigraha (non-greed or non-hoarding)

This is about reducing attachments and minimising possessions. Think about simplifying your life so your energy is not dispersed, being able to let go, and enjoying the present.

Practicing non-attachment simplifies the move from a job you might do only for the money and status, to a job that you enjoy, with positive people, and good engineering cases that are useful for humanity. For example, I was consciously working for six years in ML and data engineering in the tech sector for a good company, JustGiving. They are located in central London and focus on challenging use cases which seek to improve humanity. I did this instead of taking a job with a well paid investment bank that I would probably not enjoy.

Likewise, don’t take on too many tasks, know your limits based on experience, and become good at estimating the effort. There is no point being greedy if you are not able to deliver quality working solutions, it will be detrimental actually.

Also, do not be too possessive of your work, allow it to be shared, enhanced, and extended by others within the organisation or community you are working. In my view, knowledge should be freely passed on within your organisation and not held onto like a personal possession or secret. Never feel that sharing knowledge, wisdom, or experience is a weakness, it is a strength. Of course, this needs to be digested and communicated so that others can understand and follow too, and the recipients need to be open minded and see value.

I find that blogging is one way of sharing knowledge at scale,along with video courses and talking at conferences, but your way might be running knowledge sharing sessions internally or creating excellent documentation.

In addition, most of us are privileged to be where we are so why not help charities and non-profits by give back by technology for good. There are also many ‘hackathons for good’ with a massive sense of purpose.

I really enjoyed being part of a hackathon with the British Heart Foundation and AWS (credits Richard Freeman, PhD).

2. NIYAMA — Positive duties or observances

Saucha (cleanliness)

Is about having a clear environment, mind, body, thoughts. This includes the way we speak and the actions we take to gain more energy and become closer to our feelings and emotions.

Ensure you have lean and clean code, stop importing modules that are not needed if you write your own code. Understanding and writing your own modules allows you to make the code base lightweight and more important for you to understand what is happening under the hood.

There are many sources of inspiration too, talking about best practices such as Robert C. Martin’s Clean Code is a good place to start.

Also think about your environment and workspace. Is your desk clean? Can you brainstorm your ideas easily on paper or a whiteboard?

Santosha (contentment)

Accept and appreciate where you are, and be grateful for the journey so far and be content with discontentment, keep your heart open.

To be content and satisfied you need to know yourself and your effort and contributions. Do you take pride in your work? Do you need validation from others to be content? Do you depend on the external environment to be satisfied? Or are you satisfied that you know that you put your best into your work and used feedback to do the best job?

In my team for complex solutions I ask for no premature optimisations, and to start with getting a minimum viable product MVP out and iterate on it, find a way to complete a thin end-to-end implementation then build it up, rather than building the perfect system first time round. Knowing that this is a stepping stone to get a complete system is one way to be content. As nothing is static or permanent (anitya) especially in tech, so having this mindset of being content with where you are is valuable.

Tapas (discipline and burning desire, or conversely the burning of desire or transformation)

Self-discipline to power through the changes and challenges in your life. Through introspection and self-study you identify some bad habits through discipline. You can overcome them and create new patterns and habits through your transformational fire.

Software engineering should be seen as a discipline with engineering quality, meeting the business requirements and satisfying the customers. Some people think it is okay to always use code snippets from Stackoverflow, or other people’s modules, or pre-trained data science models, and simply applying some lightweight glue makes them amazing at what they do. But really they are fooling themselves with borrowed layers of imported code where they don’t understand the fundamentals of computer science and are missing the true nature of their fields. This leads to an impure, bloated codebase that will suffer from latency or security flaws. Be disciplined to view problem solving from many angles, weigh out the solutions and follow best practices to align with Tapas. You will benefit the most from taking on challenging problems, your perseverance in finding a solution where there might not have been one is hugely rewarding and will help you grow.

Be ready to think much wider than just code for example:

Svadhyaya (self-study or self-reflection, and study of spiritual texts)

Knowing yourself through self-study is important to understanding how we act, respond, and obtain awareness to better deal with any situation.

Don’t just rely on blog posts and Stackoverflow, think much bigger — keep learning, evolving, and be open to constructive feedback. There is so much content out there, including my own: eBooks, YouTube, Coursera, and Udemy. Things move fast and you have to keep up to date.

In addition, know yourself and recognise the gaps in your knowledge and experience. Your career goal could be to fill these gaps, or you can acquire this knowledge from within the organisation or work on projects related to this area. Don’t always expect to be told what to do or what your weaknesses are, especially as you grow in seniority. You should be the one identifying these proactively and have an action plan to grow.

Isvarapranidaha (surrender to a higher power)

Surrender to what a higher power will be for you. Be an active participant in your life, present in each moment and trust that things will work out.

Sometimes people will be more experienced in some areas, trust them but be ready to question in order to understand more and learn. With my 19 years of Architecture/AWS/data/ML engineering experience, anything I come up with as a solution has a rational foundation and I love having technical discussions with people that disagree. The higher powers or seniors need to always justify and explain their views.

Once you know what you are passionate about, and have started some ground work toward goal setting and study, get guidance from a senior on how to get these step by step and grow.

Everything we do is about communication theory and information which are both foundational general aspects, yet still abstract concepts. I encourage you to read more and broaden your knowledge.

The higher power could also be a bit more grounded as the organisation you work for. What is an organisation but a bunch or people brought together to solve a common goal as a unit.

Summary

We have seen the two limbs of yoga, 1st YAMA with the Restraints, moral disciplines and things that you should try to avoid, 2nd NIYAMA with the positive duties or things you should try to do as best practices, direct your energy and grow in your role. In part 2 of this blog we will go over the remaining 6 limbs of yoga linking them back to data science, technology and engineering, these you will see go much deeper and higher.

--

--

Dr Richard Freeman
Dr Richard Freeman

Written by Dr Richard Freeman

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