How DASK can help your Data Science project? Pros of the framework in simple terms
Tags: datascience, bigdata, programming, database
Published: 2022-04-13 10:36:07



## Intro 

Working with Data Science you have to deal with huge amounts of unstructured information: for example, weather data for a certain period, query statistics in search engines, microorganism genome databases, and much more. Not only is the volume of data huge but it’s also unstructured, and the amount of it grows day by day. 

By 2025 the amount of Big Data will be about trillion gigabytes, as said in [the International Data Corporation research](https://www.import.io/wp-content/uploads/2017/04/Seagate-WP-DataAge2025-March-2017.pdf). 

Within just 10 years our society transformed from analog to digital. In the next decade, we will face the virtually limitless power of big data. With more technologies emerging today we receive data from countless channels. It’s not only your computer or smartphone. Dozens of social networks and services, like music, financial or sports apps, smartwatches and glasses, TV and game consoles, and even smart cars – all of them can collect and process data. That made Big Data show rapid growth in recent years. 

Once siloed, remote, inaccessible, and mostly underutilized, data has become essential to our society and our individual lives. By 2025 nearly 20% of the data in the global datasphere will be critical to our daily lives and nearly 10% of that will be hypercritical. A vital role in structuring Big Data and making it useful lies within a Data Scientist. With the help of his models, which can predict possible outcomes based on Big Data it becomes easier to make decisions in science, business, and everyday life. 

Data Scientist uses mathematical statistics and machine learning methods in his work. To simplify, he creates a software algorithm that [finds the optimal solution](https://kitrum.com/blog/steps-to-solve-data-science-projects/) to the problem. A Data Scientist can spend up to 80 percent of his time working with data, and only the remaining 20 percent is spent on running and tuning the model, evaluating the results. The main work is related to the collection of data, its transformation, cleaning, and writing pipelines. 
Taking into account all the above-mentioned, the crucial role of Big Data in everyday life, and its rapid growth, it’s important to evaluate the level of Data Scientists’ work. There are several tools that help a professional sort the data easier and process it faster. In this article, we will present one of the most current tools for working with Big Data – DASK, a flexible library for parallel computing in Python.

## What is DASK 
DASK is an open-source library that provides a framework for Python distributed computing. It processes large amounts of data and increases the speed of computations. Furthermore, DASK lets you scale out your computation to cloud platforms like AWS, Azure, and Google Cloud Platform through connecting to services like Kubernetes and Yarn. 

It’s easy to adopt DASK, as it works with a large number of data science libraries within Python: NumPy, Pandas, Xarray, and Scikit-learn. That means that you don’t have to learn a new set of arguments or restructure your code to start using it. 

DASK fulfills two main tasks: creating Big Data collections and Dynamic task scheduling. It makes it faster to process data, as it makes some functions run in parallel. One of the most revolutionary features is that it scales from a single node to many node clusters, which helps you analyze large-scale data. So basically DASK is a tool for improving your performance and scalability.

Let’s dive into the plot of how DASK works and how it assists a Data Scientist in dealing with a huge amount of data sets. 

## Work in parallel and process larger data sets than your RAM can handle

DASK consists of three pieces, which in combination make distributed code run with minimal effort. They are: 

– Collections
– Task Graph
– Schedulers

Collections such as Dataframes, Bags, and Arrays are the re-work of common Python data structures. These collections make it possible to compute in parallel larger data sets that your RAM can handle. Each of these collections uses data partitioned between RAM and a hard disk as well distributed across multiple nodes in a cluster. 



![dask](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7fmdp8x2a0wi37n4k7f.jpeg)



Collections create Task Graphs which organize tasks and enable optimization. They define how to perform the computation in parallel. Each node in the Task Graph is a normal Python function and edges between nodes are normal Python objects. You can view the Graph by calling visualize() on any collection object.

Then the actual computation takes place. The flow of work is managed by the Scheduler, which also decides which worker in a potentially many-node cluster gets which task. The task is passed on to the scheduler by a “client”, which is a place where you write your Python code. 

DASK implements blockwise operations so it can work on each block of data individually and then combines the results. Dealing with each kind of operation separately, providing only the final result, makes the computation faster than if there was only a single worker having to do it.

## Inspect the processes and optimize your code

DASK also contains an interactive dashboard. With its help, you can diagnose the state of your cluster. Plots and tables within the dashboard display live information, which you can use to inspect the process and optimize the code. The different plots and tables include status indicators, system information, logs, etc. It helps you to learn what makes the performance faster and what slows it down. 

The dashboard uses Bokeh plots, so with the help of its tools, such as hover, zoom, tap, pan, etc you can interact with the plot objects. You can also access the dashboard plots directly in JupyterLab using the dask-labextension. 

**Useful Plots:
**
Cluster Map – is a visualization map, which shows the interaction of the scheduler with the workers around it.

Task Steam – shows the tasks executed by workers in real-time. It saves the state of the workers, showing a history of the tasks performed at the end of the computation. It denotes idle time and communication. 

Progress Bar – shows the progress on each task during parallel execution. Each task has a different color and remains consistent throughout the dashboard. It helps you make inferences quickly.

## A wholesome tool for your data volume-heavy projects

To sum up, DASK is one of the most revolutionary tools for data processing. It’s easy to adopt as syntax is similar to the PyData ecosystem. But the most important is that with minimal code changes you can run code in parallel taking advantage of the processing power even on your laptop laptop, regardless of your RAM capacity. Processing data in parallel means less time to execute, less time to wait, and more time to analyze. Performance, scalability, familiarity, and the popular Python at the core, make DASK a wholesome tool for your data volume-heavy projects.