December 15, 2023
Decision Nodes

The DiCE Principle: Towards Reliable Data Analysis

Albert Lee
Staff Bioinformatics Scientist

Albert is a software, data, and machine learning engineer who loves crafting delightful solutions. He finds beauty in the structure and connections within systems, bringing together technical expertise and creative thinking. You can find more about him on LinkedIn and GitHub.


In data analysis, just like cooking, the right ingredients, a proven recipe, and a well-equipped kitchen are essential for success. To produce meaningful insights, data scientists (DS) or data analysts (DA) require these key elements:

  1. Reliable Data
  2. Robust Code
  3. Controlled analysis Environments

This trio is so fundamental that it's beneficial to consider them as a group, which I will refer to as DiCE 🎲 for mnemonic purposes. By adopting this perspective, a fundamental principle begins to reveal itself: Overlooking any of DiCE components can jeopardize the reliability of the analysis and its results, potentially leading to flawed decision-making, wasted resources, and even damage to a company's reputation.

The DiCE principle states that you must manage Data, Code, and Environment for reliable results. This principle mirrors the core tenets of the scientific method, which emphasizes the importance of isolating and manipulating one variable while keeping all other factors constant in order to establish cause-and-effect relationships and draw valid conclusions.

To ensure a fair comparison between analyses, it's imperative that at least two out of the three DiCE components (data, code, and environment) remain constant.
Open in Eraser

Consider a scenario where you wish to benchmark your model against a colleague's. A true performance comparison requires both models to utilize identical datasets, preprocessing steps, and library versions. Failure to do so can lead to results influenced by data or environmental variations, obscuring the model's genuine superiority.

Understanding how to uphold the DiCE principle involves a journey. Strategies for data, code, and environment management will naturally evolve alongside team size and project complexity. In this article, we will delve into this journey and discover scalable solutions across the three dimensions, being mindful of the trade-offs involved. But before we get into that, let's explore a pragmatic starting point: the 'Octopus Approach' – a model that naturally arises in small teams or early-stage projects.

Open in Eraser

Data Analysis in Small Teams: The Octopus Approach

When building a new data team (think of an early-stage lab or a team working on cutting edge industry R&D project), the "Octopus Approach" provides agility and adaptability. In this regime, analysts handle all aspects of the analysis pipeline, including gathering and cleaning data, writing and maintaining code, and managing their analysis environments.

Open in Eraser

While this breadth of responsibility might seem overwhelming, modern tools make it manageable:

  • Data Organization: DA/DS can use separate scripts for data extraction logic, build scripts (like Makefile or Justfile), and adopt simple folder structures to separate raw data, intermediate processing stages, and final analysis outputs.
  • Code Management: Git/GitHub can provide version control.
  • Environments: Workflows often center around Jupyter or Quarto notebooks, with dependencies managed via Conda, Python virtualenv, or renv (for R).


  • Speed and Agility: The Octopus Approach is ideal for quick exploration and iteration, and hence, it's a default mode for a data team at a start-up.
  • Individual Project Focus: This approach is also great especially for teams where analysts handle distinct datasets and unrelated projects.
  • Control: Analysts have control over their workflows and can optimize for their specific needs.


  • Potential Burnout: Wide responsibilities can dilute focus on core strengths, potentially leading to burnout.
  • Data Wrangling Overhead: Finding and cleaning data can be a large time investment, reducing time for analysis.
  • Individual Reliance: Data quality, code correctness, and environments depend heavily on personal diligence, creating potential for inconsistencies.
  • Scaling Challenges: Maintaining DiCE gets harder with growth, leading to duplication of effort.
  • Technical Debt: Prioritizing speed early on can impact maintainability later.

The Octopus Approach empowers small teams but scales poorly. For example, it can lead to 1) data silos, where data is isolated and difficult to access by others, and 2) duplicated efforts, as multiple analysts may unknowingly perform the same data cleaning or transformation steps. Additionally, the multiple octopi can start depending on each other, making it difficult to reproduce how the final data used for an analysis was generated.

Open in Eraser

As teams grow, let's explore how we can 'factor out' each element of Data, Code, and Environment for efficiency and reliability, starting with Data.

Centralizing Data Preparation: The Data Warehouse Advantage

As teams grow and projects become more complex, the Octopus Approach's data management workload can become unsustainable. This is where the benefits of a centralized data warehouse come into play.

A centralized data warehouse provides a scalable solution, applying data engineering principles to tackle the increasing volume and complexity of your data landscape.

A data warehouse is a large, centralized repository that aggregates data from various sources across your organization. Imagine it as the "single source of truth" for all data analyses in the organization. Popular cloud-based data warehouse solutions include Snowflake, Amazon Redshift, and Google BigQuery.

Open in Eraser

A dedicated team of data engineers (DE) is responsible for building and maintaining the data warehouse. They handle:

  • Data Sourcing & Cleaning: DE pulls source data from diverse systems, ensuring its quality, and resolving inconsistencies (using tools like Airflow or Fivetran).
  • Transformation: DE reshapes the data to align with your analysis needs (using tools such as dbt).
  • Governance: DE establishes standards for data security, quality, and definitions.

The following diagram illustrates a typical, cloud-based ELT (Extract, Load, Transform) process, which is a variant of the traditional ETL (Extract, Transform, Load) process.

Open in Eraser

Data is first extracted from various sources such as databases, spreadsheets, files, or web services. The raw data is then directly loaded into a storage system, such as S3, in the form of CSV files. Following the loading phase, the data is transformed within the storage environment itself, where "raw" tables are refined into "gold" tables for analytical purposes, with a data warehousing solution like Snowflake managing and serving the transformed data to the downstream dashboards or analysts.


  • Consistency: DS/DA works with the same reliable data.
  • Efficiency Gain: Data scientists focus on insights, not data preparation.
  • Scalability: The data warehouse is designed to handle growing data volumes.
  • Governance: Centralization enables the enforcement of data quality and security policies.
  • Reduced Duplication: this also eliminates redundant data cleaning efforts.


  • High initial investment: Setting up a data warehouse requires a significant initial investment.
  • Complexity: Design and implementation of the data warehouse require specialized data engineering skills.
  • Maintenance overhead: A data warehouse needs ongoing maintenance, updates, and performance tuning, which can be time-consuming and resource-intensive.
  • Potential inflexibility: The data warehouse's predefined data model might limit the flexibility of analysts to explore data in unique ways in some scenarios.
  • Dependency on Data Engineering Team: Analysts might become reliant on the data engineering team for their data needs, potentially creating bottlenecks if the team is under-resourced.

While a data warehouse addresses the data component of the DiCE principle, ensuring consistency and efficiency in code is equally crucial for reliable data analysis. Let's explore how code management strategies can support this goal.

Managing Code in DiCE

As projects mature, code reusability plays a crucial role in promoting reliability and efficiency. Also usage of central code repository (such as GitHub) becomes vital. A central code repository such as GitHub or GitLab becomes vital for collaboration and consistency. Shared code repositories ensure that all team members are working with the same codebase, reducing inconsistencies and promoting adherence to shared coding standards, such as code formatting and naming conventions. This helps maintain code quality, readability, and maintainability across different analyses.

Furthermore, your team can promote code reusability with common libraries or shared packages. This reduces duplication, encourages well-tested functions, and saves development time.

Consider these aspects:

  • Common Analysis Functions: Build a library of functions for tasks like data cleaning, feature engineering, or visualization, used across projects.
Open in Eraser
  • Code Review: Enforce code reviews to improve quality, catch potential errors, and spread knowledge across team members.
  • Unit Tests: Implement unit tests to ensure individual code components function correctly, preventing regressions as the codebase evolves.
  • Workflow Management: workflow tools like Snakemake or Nextflow streamline dataflow, enhance reproducibility, and foster collaboration by enabling clear definition of code module interactions and dependencies.


  • Consistency: Shared practices and code libraries promote reliable results across different analysts and projects.
  • Efficiency: Reduces redundant development efforts and speeds up project setup.
  • Quality: Code review, unit tests, and standardization enhance code correctness and readability.
  • Knowledge Sharing: Collaborative coding practices foster learning within the team.


  • Initial Investment: Establishing common libraries, templates, and test suites requires upfront effort and culture shift.
  • Maintenance: Requires ongoing updates and maintaining shared code elements.
  • Flexibility Limits: Strict standardization might sometimes constrain individual problem-solving approaches or might not cover all use cases.
  • Over-Engineering: Excessively complex code structures or overly-rigorous testing for small projects can be counterproductive.

With data and code management strategies in place, the final piece of the DiCE management is the environment. Introducing a centralized execution service can further streamline the analysis process and ensure reproducibility.

Factoring Out Environment: Centralized Execution Services

One effective strategy to control analysis environment is to introduce a centralized execution service. In this approach, my colleague and I can work in different python versions and use different versions of libraries. However, when evaluating our modifications to the production pipeline, we submit our changes to the execution service, which then runs the pipelines in isolated environments. Essentially, this mirrors DevOps principles (in particular, CI/CD) to the data analysis workflow.

Imagine you're tasked with improving a core data pipeline's classification model. Here's how the new process would work:

  • Submit Changes: You'd create a branch from the main pipeline codebase, implement your modifications, and then submit these changes to the service.
  • Automated Execution: The service takes care of setting up a controlled environment, running your pipeline, and providing you with results.
Open in Eraser


  • Analyst Focus: This frees developers from machine-specific issues and eases collaboration and comparison. By removing environment setup hassles, analysts can concentrate on their core strengths – data analysis and model improvement.
  • Reproducibility: Centralization guarantees everyone gets consistent results, regardless of their local machine setup.
  • Implicit Regression Testing: When data remains fixed, this approach ensures engineering changes (like refactoring) don't accidentally degrade model performance.


  • Iteration Speed: If the pipeline takes a long time to run, iterating and debugging using this framework can be challenging.
  • Bloated Output: If the pipeline generates numerous output files, this method may not be appropriate when you only need to see effect of changes on a few specific files.


We have explored various strategies for managing Data, Code, and Environment (DiCE) as teams grow and projects evolve. Again, managing DiCE effectively is crucial for reliable, reproducible, and impactful data analysis.

Small teams may benefit from the flexibility of the Octopus Approach, while larger teams with complex data landscapes may require the scalability and consistency provided by data warehousing and centralized execution services.

The following table summarizes key considerations for choosing the approach that best aligns with your team's size, needs, and resources.

By adhering to the DiCE principle—strategically managing Data, Code, and Environment through robust tools and scalable solutions—data scientists and analysts can confidently navigate the complex landscape of data analysis, ensuring that the outcomes of their experiments are not left to chance.  Just as a skilled dice player knows that success comes from strategy and control rather than mere luck, data teams who prioritize DiCE best practices based on their unique needs can consistently deliver reliable, reproducible results that drive sound decisions and business success.  In the high-stakes game of data analysis, mastering the DiCE principle is the the secret to loading the dice in your favor 🥁 🎲 😎.

Subscribe for Updates

Exploring forks in the road of software design with a weekly newsletter.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.