Faster Data Science

Faster Data ScienceSergei IzrailevBlockedUnblockFollowFollowingMay 14Business leaders often ask how to accelerate data science projects.

It is well established that data scientists spend as much as 80% of their time on data wrangling.

Reducing this time leads to faster data science project turnaround and allows data scientists to spend a larger fraction of their time on high-value activities that cannot be performed by others.

Economic and productivity benefits grow quickly with the size of the data science team.

This post makes a case for a moderate investment in data engineering that drastically reduces the time spent on interactive data exploration by satisfying the need for smaller representative data sets.

Reduce the turnaround time of analytics queriesThe key to reducing the time spent in data exploration and code development is minimizing the time it takes to get an answer to basic questions about the data.

The dynamics of the development process changes drastically when the typical run time of an analytics query goes from several hours to an hour to 10 minutes to under a minute to under 10 seconds.

Once the query response time gets into the range of a few seconds, one can and does ask many questions that test different hypotheses and ultimately arrives at a better result in a significantly shorter time.

Big Data is too bigDuring research projects as well as the development of data pipelines, data scientists necessarily run their queries multiple times, refining and improving them to get the data they need in the format they want.

However, working with Big Data is time-consuming because processing a large data set can take a long time whether you are using Hadoop or a modern distributed data warehouse such as Snowflake, Redshift, or Vertica.

This problem is often exacerbated by a pattern of using shared computational resources where interactive queries compete with larger batch processes.

Data scientists, frustrated by how long it takes to move their research forward, invent shortcuts that avoid long wait times and often sacrifice the accuracy or applicability of the results of their analyses.

For example, working with a single hour of log data makes the query time bearable so that one can make progress.

However, the results cannot be used to draw conclusions about the whole data set.

Data engineers can alleviate the pain of data wrangling by employing several simple approaches that reduce the query time with only a moderate amount of work and little extra cost.

These approaches, reviewed in detail below, aim at reducing the size and the scope of the data to a subset that is relevant to the questions asked.

Use columnar data storesThe way the data is stored makes a massive difference to how easily it is accessible for analysis.

Columnar data formats, such as Parquet, are widely used and provide many benefits.

In addition to limiting the data scans to just the columns that are present in the query and allowing better compression, these formats store the data in a binary format rather than text.

Even in a highly efficient CSV reader, parsing the text into binary data types can consume about 80% of the time needed to load the data into computer memory.

In addition, parsing text fields correctly can itself be a challenge.

Pre-processing once and storing the data in a binary format avoids the additional computation every time the data is accessed.

Data warehouses typically provide binary columnar data storage out-of-the-box.

Create always-on sampled data setsMany data questions can be answered by using a representative sample of the data.

Sampled data sets are much better than a small time slice of data because they are representative of the whole data set and are sufficient for answering a variety of questions.

Even though extracting and updating a sample is tedious, every data scientist sooner or later is enticed to do it merely to shorten the turnaround time of their queries.

A much more efficient solution that doesn’t cost much is providing an automatically generated sample of the data at regular intervals.

Generation of sampled data should ideally be tied to the pipeline that produces the full data set.

In a typical situation when the data represents some events (e.

g.

, ad impressions, purchase transactions, site visits, etc.

) related to some entities (e.

g.

, online users, companies, etc.

), it is beneficial to create data sets with different types of sampling.

An obvious one is sampling the events, where a given percentage of events is randomly chosen to be included in the data set.

Another sampling strategy, potentially more valuable and harder for a data scientist or analyst to implement, is covering all records related to a sample of entities.

For example, we may want to include all purchases for 5% of our site users.

Such a sample allows one to perform a user-based analysis efficiently.

Sampling strategies, including adaptive sampling, is a topic for another post.

Extract smaller sets of relevant dataWhen events of interest are rare, sampling may not be an option.

For example, in the digital advertising setting, one may be interested in extracting all available data for a specific advertising campaign within a limited time frame.

Such a data set, while complete with every necessary field, is a small subset of all of the data.

Analysts and data scientists interacting with this data are likely to issue hundreds of queries while they work on a project.

The process of extracting such a data set and keeping it up-to-date can be automated if the data engineering team builds tools that allow data scientists to create a query for the initial extract, with another query responsible for periodic updates.

After the project is complete, the data is no longer needed and can be archived or deleted.

Put smaller data sets in efficient SQL storesSQL is undoubtedly the most common language of data analytics.

Thus, making data sets available for querying using SQL is expanding the number of people that can interact with the data.

Democratization of the data aside, making smaller data sets available in efficient analytics SQL query engines further reduces the query time and, therefore, the wasted time for data scientists and analysts.

Such query engines range, depending on the size of the data and the requirements to infrastructure, from MySQL and PostgreSQL to Snowflake and Redshift to fully managed services such as Amazon’s Athena and Google’s BigQuery.

Provide dedicated computational resourcesOne of the biggest frustrations in data exploration is having to wait in a shared queue for results of a query that eventually runs in under a minute.

Separate high-priority resource pools for interactive queries on a shared cluster, possibly limited to business hours, go a long way in improving the overall query turnaround time.

In addition, providing data science and analytics teams with dedicated computational resources that have sufficient CPU and memory capacity allows loading of the smaller data sets into a tool of their choice to perform development and in-depth analyses.

The investment is worth it!Human time is an order of magnitude more expensive than computer time and data storage costs.

One can observe this easily by comparing an effective hourly rate of a data scientist to the hourly cost of a powerful computer.

Also, human time creates net new value for the company.

Thus, reducing the typical analytics query completion time to under a minute is likely the most impactful investment in technology available to accelerate data science and analytics projects.

Photos by Kelly Sikkema and Glen Noble on Unsplash combined by Sergei IzrailevThis post first appeared on the Life Around Data blog.

.

. More details

Leave a Reply