3D Data Visualization in Data Science using Python | Sandeep P. | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

3D Data Visualization in Data Science using Python

teacher avatar Sandeep P.

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

6 Lessons (35m)
    • 1. Intro

      1:20
    • 2. Curriculum and Getting Started

      1:53
    • 3. 3dLine using Python

      7:22
    • 4. 3 D Scatter Plot using Python

      4:25
    • 5. 3D Data Visualization using 3d Bar Chart

      7:53
    • 6. 3D Data Visualization using 3d WireFrame

      11:55
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

9

Students

--

Projects

About This Class

This course is ranges for a beginner to an expert  data scientist that want to learn how to visualize the data in 3 dimensions space, with the popular data visualization library Matplotlib. There is absolutely no pre knowledge requirement for this course. The course starts from the basic 3d Line visualization and reaches to advanced concept such as 3d WireFrame

Meet Your Teacher

Teacher Profile Image

Sandeep P.

Teacher

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Intro: Hello and welcome to this course on three-dimensional data visualization using Python. Three-dimensional data visualization is very famous and highly effective in the field of data science and machine learning because it gives us the freedom to visualize the data in more informative way so that the data scientists can analyze the data more precisely and gain more insights from it. So considering the importance of this topic, this course has been designed in such a way that you can easily grab the concept of the three-dimensional data visualization. And if start implementing in your project, we will use the map plot lib library throughout this course, map plot lib is the most popular data visualization liability. The world of data science and machine learning. And it allows us to visualize not only the two-dimensional, but also the three-dimensional datas. So I am pretty excited to start this journey of the Data Visualization. And now I will see you in the course where we will start our journey of this three-dimensional data visualization. Apart from that, to submit the project, there is a project gelding. Just share the link over there. And also just don't forget if you stuck somewhere while working on the project and you need some help from outside, don't forget we are all in together and ready to help you out here. So thank you for your time and I will see you in the course. 2. Curriculum and Getting Started : Hello and welcome to this course on three-dimensional data visualization using Python. First of all, thank you for choosing this course and now let's see how we are going to proceed in this course. So we will start the course of the knowledge of three-dimensional line. Here we will see what is a three-dimensional line, how to create it and what is relevance in realtime project. Then after completing the three-dimensional line, we will move towards the next x, and that is three-dimensional scatter plot. Here we will see what they are and how to create them. We will also see that how can they be used in an unsupervised machine learning algorithm to get the different clusters of the data. And once we complete with the three-dimensional scatter plot, we will move towards the next action that is three-dimensional bar chart. Now trade honestly, bar chart is the one of the most important data visualization technique. And it is not only used by datacenter a two, but it is also used by the managers of the project to identify the kind of performance that project is delivering. That means how they are performing in a particular time with respect to some parameter. So we will see how to create a 3-dimensional a bar chart with some different different parameters. So once we complete the three-dimensional bar chart, then we will move towards the next section, that is our three-dimensional wireframe. Here we will see how to create it, what they are, and how they can be used in the real time machine learning project. Actually three demonstrate wireframe can be used in multiple ways to identify the local minimum and local maximum. In the case of gradient descent, gradient descent is basically a machine learning approach to identify the best combination of the different parameter. So lots of things is about to come. And I'm also pretty excited for that. And yes, this is up for this particular introduction section. And I will see you in the next section where we will start with the three-dimensional lane. 3. 3dLine using Python: Hello and welcome to this course on three-dimensional data visualization using Python. So from this lecture we are going to start with our actual content and dad with three-dimensional lane. So we will see how to create it using matplotlib. And for that, let's jump to my Python editor and start building it from scratch. So here I am in my Python editor. So foreign import all the packets that is required for this particular programs. So for that I will write from MPL toolkits dot m plot 3D. I need to import access 3D. Now this MPL toolkits is a lightweight 3D plotting tool that comes with matplotlib itself. That means you do not have to install it explicitly if you have Mac blurred cave in your icon environment. And this axis 3D is basically enables the 3D projection and allows us to create the 3D visualizations. Next, we need to import matplotlib pyplot as p and p. So as we have imported all the packets that is required for this particular program, now we can go ahead and take some data point that we will visualize in a 3D access. So for that I will dry it acts is my list of elements of 123456600, different different elements. Ye is another layer of, let's say, 245784. So again, why you also have six independent elements and chaired equal to, let say, not 37, then 2p, then six, then one, and finally nine. So we have three different, differently that consist of six elements. What we are going to do is that we are going to visualize them in a 3D access. Although we have our data point is that we will visualize in our 3D access, but still we do not have our 3D access. So let's create it. So in order to create it, I will write x equal to PNP dot access and pro projection equal to projection equal to three. Now this projection equal to 3D represents that you want to project our data in a 3D access. Now one most important pingers that this access 3D enables this 3D projection. And if we do not import our x's 3D in our program, then our program will throw an alert saying that a non-production td. So let's take our demo if we comment out this particular line and when we will try to execute the entire program, then we can clearly see that it is Saint value-added unknown projection 3D is just two because this axis 3D enables this particular projection td. That means if you want to have our data projected in a three-dimensional space with much tab access trade in our program. So if we remove this and let's re-execute it, then we can clearly see no added has been detected. It's judged because we have access 3D that allows this projection clearly. So now as we know the importance of this particular access 3-D. Now let's go ahead and visualize our TDD access. To visualize it, we need to write PLT dot show. Now what this function does is that it basically helps us to see the visualization made by our Python program. So let's execute it. Now here it is. Here we can see the 3D access created by our Python program. We can clearly see the three different, different axes, but again, there is a normal levels. So in that which axis is which one? That means which one is the x axis, which one is y axis, and which one is delta x's. So for that, we need to make the labels of this particular access. We need to say which one is x-axis, y-axis, and giant access. So for that, we need to set the levels. So for that I will write x dot set underscore x label as x level as Ax, x dot set, Y level as Y, and X dot set zed level as Jed. Now when we re-execute the entire program, then we can clearly see that each and every access is mentioned over here. We can see that x axis is mentioned over here. That means this particular axis is our x-axis. This one is our y-axis, and this one is our z-axis. Now one thing to note here is that we can clearly see direct randomly value has been initialized to each and every axis. That means each and every axis has a random value between 0 to one. But we need to include our data point in this particular access so forth that we just need to include all this data point in this particular excess. So for that we need to write x dot plot 3D, plot 3D. Now what this plot 3D does is that it basically helps us to visualize our data point in our 3D access. And it takes it forward argument. Folk three argument is the data point that we want to visualize in 3D access. And the last argument is the color of our line. That means which particular color we want to have our 3D line. So as we want, let say we want to have it in red colors, so we will mention red over there. And then when I re-execute this entire program, I can clearly see that it has created a three-dimensional line which is making, which is off color red. And we can clearly see that whatever the default value that was present before, between, between 0 to one is, it has been now replaced by what, an actual value of x-axis, y-axis, and z-axis. So that's how we create our 3D line using Python and matplotlib. So yes, this is a port, this particular tutorial, and I will see you in the next one. 4. 3 D Scatter Plot using Python: Hello and welcome to this course on data visualization. So in our previous tutorial vacated the entire idea about how we can draw a three-dimensional line using matplotlib. And now in this particular tutorial, we will see how we can create a three-dimensional scatter plot. A scatter plot is one of the most important and popular data visualization method that helps the data scientists to visualize the different collectors of the data in their dataset. And then after visualizing the different clusters, they perform multiple unsupervised machine learning algorithms on that particular data. So from point of view of the data science and machine learning, it is very much important to visualize a scatterplot is specifically in three dimensions so that we can easily grab the behavior of our data. So as we know the importance of our scatterplot, let see how we can build it. Now if the previous tutorial is quite clear to you, then you can easily grab the entire concept behind their scatter blot because most of the code will remain the same. The only change we need to perform is this one. Each teed off plot 3D, we will use a scattered and when I re-execute it, then, then I can see that Python program has created a three-dimensional scatter plot for us where each and every scatterplot point basically the presents a different, different value of x, y, and child x s. So if we take this particular scatterplot point, then I can see that the value of y is somewhere between the 54. The value of x, x is for this particular point is somewhere between 12 and the value of z and x is for this particular point is somewhere between 78. So this is how long each and every point can be represented for a particular value of x, y, and zed. And now we can create multiple clusters of the scatter plot. For that, we just need to add the data points of our new cluster. So let's do it. Now. Let's add some new data points. Let's copy this one. We will add X1, X1 with a value of one, Ford, 67, boo, and six. Then again y, y1 with a value of two, then 57, then the next say Ford, 69. And similarly gentleman with a value of three, and then let's say five, let's say 7619. So now as we have another three-dimensional data points and we can create another data collected using these points. So for that we just need to write x dot is scattered. And I want to have a scatter plot for X1, Y1, and Jed one. And I want to have the color of our cluster point as, let's say black or not, some blankets black. And here the color is equal to red. And when I re-execute the code, then we can clearly see that our Python program has created two different clusters. The first one is the collector with the red data points and the second one is the collector with the black data point. Yes, this is how we create the different, different cluster using matplotlib. And these techniques are basically implemented by most of the data scientists to visualize the different, different clusters among their data. And then after they perform different kind of unsupervised machine learning algorithm to segregate their entire data. So yes, disease or for this particular tutorial where we have seen how we can create the three-dimensionally scatterplot using matplotlib. And in our next tutorial, we will see how we can create a three-dimensional bar chart. 5. 3D Data Visualization using 3d Bar Chart : Hello and welcome to this course on three-dimensional data visualization. So in our previous tutorial, we are going to the overall idea about how we can create a three-dimensional scatter plot. And in this tutorial, we will see how we can create a three-dimensional bar chart. So three-dimensional bar charts looks something like this. And it is the one of the most informative way to represent the data and the get necessary insight out of it. It is mostly used by the business person to identify the different aspects of a project Lake, the profit of your project, but other kinds of inside of it. So it is a very informative structure that basically have four different values. X value, y value, jet value, and the depth value x value to presented the data point in X axis, Y value represents the datapoint in y-axis. Zed value represents the data point of the axis and depth to represent the depth of each and every data points. So if peat talk about the x axis, so this is how our x-axis is. If starting from the x data point, y-axis, zed x's. And again, each and every axis having a particular depth, this xs, xs having a particular depth, y axis having particular depth. And edX is having particular depth. That could basically represents how tick we warned our borrower would be. So if the depth is very less, then it would not be able to give the proper information and insight out of the data. And if the depth is very large, then it will be very difficult to represent high amount of data in a limited space. So we need to choose the depth of the BOD wisely so that we can get the most information and insight out of the data. So yes, this is pretty much today about our three-dimensional bar chart. And we will see how we can create it by jumping out to my Python editor. So here I am in my Python editor. So again, this is the program for our scatterplot where we have plotted the scatter value for x, y, and g. X is now again, the value would be the same. We will, we will have the same value of x, y, and Jed. And for that value, we are going to plot our three-dimensional bar chart. But as per our intuition, we know that we must have the depth of each and every x has suffered that. I need to have three different value to dx, which represent the depth of x, D, which represents the depth of y axis, and d z, that represent the debt of giant x's. Now it's completely depends upon us how much depth you want to have in our bar chart. That is how we want our BAD shouldn't be. So if we were working in a project, then you will get the guideline form your supervisor or client that that okay, this is the kind of thickness we want to have in our bar chart. But here, as I am giving an example, so I am taking the thickness of one unit for each data point. That means we have one unit of depth for each data point in x axis, y axis, as well as the GDX system. So for that I will write. 111111, as we have six different data points that, that is why I am taking six different, different ones. Not each of these ones represent that each point in x axis has a depth of one unit. That means this particular point or has a depth of one. Similarly, this data 0.2 has a depth of 1.3, has a depth of one, forward has a depth of 0.5 as a depth of 16 headed depth of one. That means we have 16 different different data points in x axis. That is why we have six different, different ones in this particular depth of X axis. Now we, as we have six different data points in the x axis, that is why we have six different ones in our dx. But if we have like three hundred, four hundred, five hundred different points in x axis, then if we follow this particular approach, then we have to manually write three hundred, four hundred, five hundred times ones. So in order to avoid debt VK and simply write np dot ones. And how much once we want, we want 16 different different ones. So for that we can simply write this and it will create a numpy array that will have 16 different, different ones. So again, similarly we can do for Y-axis. And again, if you want to have the same depth for Jack says then we can write np dot, dot six. Now we have the depth of each and every axis, x-axis, y-axis. And Jack says, so now we can directly go ahead and plot this chart, so forth that we can write it X dot BOD, POD. And we want to plot our x-axis, y-axis, z-axis with a depth of dx, dy by. And these are, and let's say the color is the, let's say the color is blue. Now let's execute it. So yes, so this is the bar chart that we have created. This is the permanent different, different x-axis, y-axis, and GALEX is. And I knew that it's looks some glitchy because it can be have a wierd kindof BAD chart where each and every body starting from a different different values of jet. It's just because we have different values of January and we get from three someone from seven to six, 19. So that is why we have different different kind of bar available over there. But if we take the G20 for each and every j value, then we will get with the sophisticated kind of BAD charter wadi or so for that I will write np dot zeros. And I want six zeros over here. And when I re-execute the entire program, then we can see that it is giving us the exact kind of bar chart. We are related to the VA or thinking about it. Because each and every body starting from a particular jacks is where it has value of the zed is equal to 0. So this is how we can create the bar chart. A different, different values, different x, y. You enjoyed where each and every bar chart has a particular depth. Again here we can say that dx over d value over the head and beside Ovadia. So if we choose the value of dx, d j and d j, let say, let's change the value of dx from np.log10, H2, np.zeros and d. And let's agree, execute the entire program. Then we can see that the depth in x axis has been reduced. And this is the reason why we are choosing a particular depth of each and every access. So again, we can see that it is not representing the exact information that our word bar chart represents when we have the depth equal to one. So that is why the depth is very important. That that couldn't basically helps us to get the mod insight from the data. So again, let me allocate np dot once and we execute the entire program. And now here we have the exact kind of BAD charter that we want to have in our program. So, so this is how we create the three-dimensional bar chart. And yes, this is a port, this particular tutorial. And I will see you in the next two Boolean, where we will see how to create a three-dimensional wireframe. 6. 3D Data Visualization using 3d WireFrame: Hello and welcome to this course on data visualization. So in our previous tutorial, regarded the idea about how we can create a three-dimensional bar chart. And in this particular tutorial, we will see how we can create a three-dimensional wireframe. So first let's see what is a wireframe, how it looks like and why they could be used for. So this is how our wireframe looks like. We can see it is a three-dimensional combined via Lachish structure to represent the data. And one of the possible application of this particular wireframe is two, is to represent the local and global minimum value in a technique like gradient descent in machine learning. So what is a gradient descent? Gradient descent is basically a way to identify the ideal value of the different parameters by reducing a particular known parameter, for instance, wet or loss value. So we can use the entire concept of the wireframe to identify at what point we have our global minimum value and wet what point we have our potential local minimum trap. So this is about the Curie part of our wireframe and where we can use it. And now let's see how we can build it to. For that, I need to jump out to my Python editor. So here I am in my Python editor, that is Python. And now let's import flush to the required package for that I will write from MPI or toolkits dot m blurred 3D. I need to import excess trading. Next, import matplotlib pyplot as PLD. So now as we have imported all the required packages in our program, now let's have some data that we will represent in the form of wireframes. So I will take the same data point that we had earlier. That is x equal to 123456, y equal to 24578 foot, NHGRI equal to 37261 name. Now let's create our 3D access for that, I will write AX equal to PLT dot axis. And I want to have my projects and in, in three-dimensional space for that I will write projection equal to 3D. And now after writing this line, we will have our three-dimensional axis. And now let's send the levels of our x's. For that, I will write x dot x label as x axis, AX. Lord said, Why level as y axis and x dot septa, jagged level as. Jet x's. So now as we have said, the levels of our exit, it's clear to the three-dimensional wireframe in our three-day access by considering how the data that we have support data, we will write 0x dot plot wireframe. And I need to provide all X, Y and a jet data. And now when I execute the entire program, it will give me an editor saying that lift element is not having the attribute ending. So let's see. So let's execute the entire program. And we can see that it is saying that lift object has no attribute and him. So what is this added meals Y of y, we are getting this edit. This is because plot wireframe expected to demonstrate NumPy array as an input of the data points, but via giving it the list of the data point. So that is why we are getting this editor that lift object has no attribute and dim because it, because our plot wireframe tries to identify the number of dimension, but as our leashed object does not have any attribute as n m. So that is why lot wireframe is not able to identify the number of times and using Andy my-attribute. So to overcome this problem, we need to convert the entire one-dimensional lifting to a two-dimensional NumPy array. A Numpy is basically a Python package that helps us to create multi-dimensional added that execute faster than the regular array or list. So let's do it. Let's convert the entire list two into a two diamonds not NumPy array. So for that I need to import the NumPy package pushed. So import numpy as np. And now to convert the leash dive in right? And p dot eddie, I want to convert the entire lecturing to edit. And then I will execute the entire code. That means for this particular x, it will convert the entire list into a one-dimensional lattice, but as we'd need a two-dimensional edit. So that's why we need to make, to brag covariate data good approaches to convert a single one-dimensional array into multiple demonstrated a light using reset method or something like that. But this is the most easiest method to create a Numpy array of two diamonds and just by putting two brackets over here. So I will do the same thing over here again. I had a and here it has been. So now as we have our x, y, and z data point in the form of to demonstrate NumPy array. So we are good to execute our entire program, so let's do it. But again, we need to use the plt.plot show so that we can see the captured created by hour. Matplotlib. And now let's execute it. And now as we can see, that it has created a three-dimensional wireframe, but, but it does not looks like a wireframe. It looked like a 3D line. It is just because the the data that we are using, it is not sufficient enough to give it a proper lookup wireframe. But the method that we have used to create this wireframe is exact same that could be used to. But as we are lacking of the data that we are having, we are not having the actual formatted data. That is why we are not able to see a wireframe structure. So, but again, we are going to overcome it. We are going to use some data that basically provides us the, the exact wireframe like scripture. So for that, we need to make a very long trial and patient lake approach. We need to have multiple data. We will see if it is giving us the proper wireframe Lakish structure or not. And again, if it is not, then we need to change it again and again. So it would have a very lean the pose as if we go by this particular approach. So that's why we are going to use a pre-built method by matplotlib that basically gives us the text to data for this wireframe data structure. And the method is called as get test data. This good test data is basically gives us the kind of data that we are requiring. That means the exact combination of x, y, and z access of data that will help us to create a wireframe like structure. So for that, we need to import one more library, that is our x's 3D. Now this x is 3D is not same as this axis 3D because it is starting with capital a and this is discarding Purim is more early that, that is that symbolize that both are completely a different package. And we're going to use this get cached data from this excess 3D only. So let's use it. We are going to recreate our x, y, and zed by using our access 3D dot get text to data. Now it takes one more argument. That is our delta value, which is equal to delta equal to 0.5. And now let's execute the entire quote and see if we are getting a wireframe like structure. So let's execute it. And here it is. We can clearly see that it is giving us the wireframe exempt wireframe lag structure because we are having the right value of x, y, and z axes. And yes, so this is how we create a wireframe Lachish structure if we are having exact value of X, Y Zed. But again, you would not have to worry about the actual value of x, y, z if you are working in a, a production environment because at that time you will get the X, Y, and Z value that is required to withdraw. You know, you're not the kind of data that you will get automatically from your production environment so that you can draw a wireframe likely structure. But as v, we have used small dataset, which is a kind of self-created dataset. That is why we are not getting the exact wireframe likely structure. But when we used the, the pre-built method, that is getText to data. And then we got the exact value of x, y, and z dx is that basically help us to create this three-dimensional wireframes. And now let's see what are the actual XY and jet values that basically helps us to create this while I'm liking structure. So for that I will write print x equal to x equal to x, y equal to y, and set it equal to zed. And when I execute it, then we can see that different, different value of x, y and zed is basically assigned by this particular kid tick data methods. So that is the different x. We can see the different value of x, y, as well as the value of jag. So that is pretty much it. We get to how we can create a three-dimensional wireframe using different, different value of x, y, and z. So this is it. And congratulations for completing the three-dimensional data visualization course. And now you would be more confident about the visualizing the data and gaining insights from it as you can represent the entire data and not only in the two-dimensional, but now you can visualize them in a three-dimensional space and you can gain more insight from it. So yes, this is it. And thanks again for choosing this course.