Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Key Takeaways
This video teaches how to use Datashader for big data visualization in Python, covering its workflow and speed advantages
Full Transcript
i'm trying to plot 11 million data points on my laptop it looks like a big blob and i can't extract any meaningful information from it what should i do let me just google it big data visualization python okay looks like i should use data shader let me give it a try wow oh my god it works like magic it is so fast and the plot is interactive let me show you what data shooter is and how data shooter works data shooter was developed by my anaconda colleagues philip rudiger john stevens and banner it is one of the seven libraries in the hall of face ecosystem if you'd like to learn more about holobas check out my previous video on how and why i love hallows so why is big data visualization so hard there are two main obstacles to visualize big data first is b if you were to plot big data using your regular python plotting libraries it could be extremely slow and your jupiter kernel could crash second is image quality even if it doesn't crash and you're willing to wait most plotting libraries will simply keep drawing each new data point as a circle or some other shape on top of each other which will result in over plotting even adding alpha transparency for over plotting points won't always help in the situation data shader provides elegant and seemingly magical solutions to those two obstacles next i will show you an example and peek into the magic involved first let's import needed packages in your contact environment i guess before that if you haven't installed anaconda or minicon already please first install those then you can create a new contact environment activate this environment and then install the packages we need now we can open up a jupyter notebook or jupyter lab and import the packages we need next let's reading some data from parquet files using the pandas read parquet function here we'll load two columns representing taxi drop-off locations for the very largest files you'll want to use a distributed processing library like desk with data shader but here we only have a prokaryote file with only 11 million records which datasheeter can easily handle on a laptop using pandas without any special computing resources then we can plot our data using data shader i only took four lines of code where we use the datasheet function to data shade all the points alternatively instead of using the datasheet function we can use hp plot with rasterize equals true to apply rasterization using data shader i highly recommend using hp plot it is super easy how does data shader work exactly data shader turns your data into a plot using a five step pipeline projection aggregation transformation color mapping and embedding i'm going to break down my example into those small steps so that you can see exactly what data shader is doing under the hood let's first install the underlying data shooter functions so that we can run through the individual steps the first step is projection we define a 2d canvas with width and height for the data to be projected onto the canvas defines how many pixels we would like to see in the final image but for speed each point is actually projected during the aggregation step next the second step is aggregation after we define the projected canvas we project each point into the two-dimensional output grid and aggregate the results per pixel data shader supports many options for such aggregation but in this exam we simply count how many data points are projected into each pixel by iterating through the data points and incrementing the pixels where the point lands the result in this case is a two-dimensional histogram counting drop-offs per pixel the third step is transformation once the data is in this grid we can do any kinds of transformations we like such as selecting on a certain range of accounts masking the data based on the results of other datasets or values and others here the drop of data ranges from zero in some pixels and tens of thousands in others and if we were to plot the grid directly we would only see a few hotspots to make all the different levels visible as in the image we showed you earlier the data is transformed using the image processing technique histogram equalization to reveal the distribution of the counts rather than their absolute values histogram equalization is actually folded into the color mapping steps but we can do explicit transformations at this stage if we want such as squaring the counts the fourth step is color mapping we can render the bend grid data into the corresponding pixels of an image each bin value is mapped into one of the 256 colors defined in a color map for example here it uses histogram equalization in this example we're using the fire color map from the color set which starts at black for the lowest values and goes up to red for higher values and then yellow for even higher values and finally white for the highest accounts per pixel which is tens of thousands in this case we set the background to black to better visualize this data the final step is embedding as you can see data shader only renders the data not any pixels color bars or similar features you would expect in a full plot to get those features that help you interpret the data we can embed this image generated by data shooter into a plot the easiest way is to use holoviews which is a high-level plotting api that provides the flexibility to use either matlab lib bokeh or poly as a back end here is an example of using hover views to define a points objects and then data shading all the points here we demonstrate an alternative method rasterize instead of data shade so that bokeh is in charge of the transformation and color mapping steps and allows hover and color bars to work you can also use rasterize with hp plot just like we showed in in the example earlier why is data shader crazy fast first we need to talk about the original data format data shooter is so fast that reading in data is usually the slowest step particularly if your original data is a bunch of json files or csv files the parquet data format is usually a good choice for the columnar data like the drop-off points we have here because it's compact quick do loading efficiently reads in only the columns and ranges you need and supports distributed and out of core operation when appropriate second with the right input file formatting we can investigate the next most expensive task which is the combined projection plus aggregation step the step requires calculating values for each of the millions of data points while all the subsequent calculations using the final fixed size grid and are that's much faster so what does data shooter do to make this step fast first data shaders aggregation calculations are written in python but then just in time compiled into the wicked fast machine code using number second data shooter plus number also supports cuda qdf data frames as a dropping replacement for pandas data frame that runs even faster if you have a gpu third datasheeter can also parallelize its pipelines so that it can make use of all the computing cores you have available scaling to even larger data sets and even faster results because datasheeter is so fast we can actually visualize big data interactively dynamically rejoin whenever we zoom or pan here is an example where you can view the nyc taxi data interactively in a panel dashboard my favorite example on ship traffic illustrates that even though all you see is the pixelated image the data shader renders you can still inspect individual data points and understand what they're saying the other examples at pivx.org show datasheeter for much larger files up to billions of points on an ordinary laptop if you'd like to learn more about data shader i highly recommend checking out the many great examples at datasheeter.org and our examples using datasheeter in a panel app in awesomepanel.org thank you hope you enjoy this video and i'll see you next time bye
Original Description
Dashshader is the big data visualization tool in the HoloViz family. I absolutely love Datashader and love how Datashader creates meaningful visualizations of large datasets very quickly. In this video, I am going to walk you through a simple Datashader example, explain how Datashader works, and why it is fast.
Github code: https://github.com/sophiamyang/datashader_example/blob/main/datashader.ipynb
Medium article: https://towardsdatascience.com/big-data-visualization-using-datashader-in-python-c3fd00b9b6fc
The example in the video comes from the NYC Taxi data example on pyviz.org. For the full example, please see https://examples.pyviz.org/nyc_taxi.
Check out my previous Python viz videos:
- Why I love Holoviz: https://www.youtube.com/watch?v=wlzkiGPIV3I
- Create an interactive dashboard: https://www.youtube.com/watch?v=tNAFtyjDPsI
To learn more about Datashader:
- https://datashader.org/
- https://www.youtube.com/watch?v=v0QiTptWt3w
- https://www.youtube.com/watch?v=t5oFw9NUhlQ
⭐ Stay in touch:
Medium: https://sophiamyang.medium.com/
Twitter: https://twitter.com/sophiamyang
Linkedin: https://www.linkedin.com/in/sophiamyang/
#visualization #python #bigdata #datascience #datascientist
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Sophia Yang · Sophia Yang · 14 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
▶
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Sophia Yang
Time series analysis using Prophet in Python — Math explained
Sophia Yang
Multiclass logistic/softmax regression from scratch
Sophia Yang
Deploy a Python Visualization Panel App to Google Cloud App Engine
Sophia Yang
Deploy a Python Visualization Panel App to Google Cloud Run
Sophia Yang
[Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
Sophia Yang
5-step data science workflow
Sophia Yang
Multi-armed bandit algorithms - ETC Explore then Commit
Sophia Yang
Multi-armed bandit algorithms - Epsilon greedy algorithm
Sophia Yang
User retention analysis framework | data science product sense
Sophia Yang
Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Sophia Yang
Multi-armed bandit algorithms: Thompson Sampling
Sophia Yang
The Easiest Way to Create an Interactive Dashboard in Python
Sophia Yang
Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Sophia Yang
Why do you want to be a data scientist? Don't be a data scientist if ...
Sophia Yang
Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Sophia Yang
How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
Sophia Yang
Designing Machine Learning Systems | book summary | Read a book with me
Sophia Yang
Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Sophia Yang
Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Sophia Yang
What's new in hvPlot releases 0.8.0 & 0.8.1?
Sophia Yang
Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Sophia Yang
Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Sophia Yang
How to solve data quality issues | Data Reliability | Meet the Author
Sophia Yang
Reliable Machine Learning author interview | DS/ML book club
Sophia Yang
Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Sophia Yang
TOP 6 tech news in 2022 #shorts
Sophia Yang
How to deploy a Panel app to Hugging Face using Docker?
Sophia Yang
Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Sophia Yang
🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
Sophia Yang
Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Sophia Yang
The story of Metaflow | Effective Data Science Infrastructure | Book author interview
Sophia Yang
Tech news this week #shorts
Sophia Yang
A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
Sophia Yang
Tech news this week #shorts
Sophia Yang
Explainable AI with Shapley Values (Part 1: Game Theory)
Sophia Yang
Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Sophia Yang
Explainable AI with Shapley Values (Part 3: KernelSHAP)
Sophia Yang
Tech news this week | AI search war between Microsoft and Google #shorts
Sophia Yang
The Story of ChatGPT's creator OpenAI | From Riches to Fame
Sophia Yang
Explainable AI for Practitioners | Must-read for XAI | author interview
Sophia Yang
Train your own language model with nanoGPT | Let’s build a songwriter
Sophia Yang
The easiest way to work with large language models | Learn LangChain in 10min
Sophia Yang
The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
Sophia Yang
startup scene in data | insights from 50+ data startups from Data Council
Sophia Yang
NLP with Transformers author interview with Lewis Tunstall from Hugging Face
Sophia Yang
4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
Sophia Yang
5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
Sophia Yang
4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
Sophia Yang
MiniGPT4: image understanding & open-source!
Sophia Yang
BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
Sophia Yang
Designing Machine Learning Systems author interview with Chip Huyen
Sophia Yang
Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Sophia Yang
🤗 Hugging Face Transformers Agent | LangChain comparisons
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
Sophia Yang
Tech news this week #shorts #short
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Sophia Yang
More on: Data Literacy
View skill →Related Reads
📰
📰
📰
📰
Star, Snowflake, or Galaxy? Choosing Your Data Warehouse Schema
Dev.to · grace wambua
DaDaDa: A Dataset for Data Pricing in Data Marketplaces
ArXiv cs.AI
I Tried to Predict the World Cup. What I Learned Had Nothing to Do with Football.
Medium · Data Science
Your Company Does Not Need More Dashboards. It Needs Better Decisions.
Medium · AI
🎓
Tutor Explanation
DeepCamp AI