Lecture 19 : Graphics and Plots: Three Dimensional Plots, Star Plots and Chernoff Faces

IIT Kanpur July 201
20 followers
Jun 5, 2024
[Music]
hello friend welcome to the course
multivariate procedure with r so you can
recall that in the last couple of
lectures we have considered the
univariate and bivariate
Graphics which are essentially trying to
handle only two variables at a time and
in case if you want to consider more
than two variables then one option was
that try to consider them pair-wise that
means two variables at a time and this
is how you can do it but there are
options where you can consider the
graphics in
three-dimensional or you can
consider more number of variables
without increasing the dimension of the
graph traffic so in this lecture we are
going to consider s
topics uh for example we will be talking
about the three-dimensional plot and
then I will try to explain you how you
can use it for drawing different types
of statistical
inferences I will try to show you about
the the star plots and clof
faces and I will try to show you that
star plots and ten off faces they can
take care of more than three variable
also but in a two Dimension so okay so
let us begin our lecture and try to
understand these things okay so now if
you try to see what is a three dimension
three dimension mean it is like this x y
and here Z our eyes can see in only in
three dimensions not more than three
dimensions we can see but on our slides
we can make only the two Dimensions but
through some way I
can create here a
graphic which may look like a
three-dimension for example if you try
to see this is rectangle or
square now if I want to make it into
three dimension you can see here is
still I am in
the two Dimension but now if you try to
look at this graphic it looks like as if
you are viewing in the three dimension
so we are going to consider this type of
here using the command scatter plot 3D
and if you try to see here how I have
written here this is scatter plot 3D it
is s c a t r p l o t in lowercase
alphabets but now there is herea number
three and then lowercase alphabets D in
order to create such uh
three-dimensional scatter
plot we need to use a special package
which is scatter plot 3D so you know
that if you want to install a package
you can use the command here install.
packages and within the double codes
inside the parenthesis you can write
down scatter plot 3D and it will be
installed on your
computer after that you have to upload
it so you will write down here Library
scatter plot 3D and now I want to
illustrate here the creation of uh
picture in three
dimension so for that I try to create
here a data sets on say three variables
and I have artificially chosen them such
that they are interrelated for example
if I say age weight and height of a
person they are not independent as the
age increases the height and weight also
increases up to certain age so this type
of data I have considered here and I
want to create here a three-dimensional
plot so that I can see that how these
three variables are behaving
together so in order to create the uh
three-dimensional scatter plot the first
requirement is to express the data in a
combined way and for that we use here
the concept of data frame so we create
here a data frame by using the command
data. frame and inside the parenthesis
the three variable height weight and age
and I try to store it in a variable name
data
3D right so if you try to see here this
will look like this so now this is my
here data so now I use here the command
here is scatter plot 3D and inside the
parenthesis I try to use this uh data
frame name data 3D and inside the
brackets I try to write here comma and 1
colon 3 which is actually 1 2 3 all
right and if you see you will get here
this type of graphic you can see here
height is on this x is age is here
weight is here so there are basically
here three dimension one two and here
three right and if you try to see if you
visually try to inspect it these are the
points which are here right so you can
see that how the points are located in a
threedimensional
plane and similarly if you try to rotate
the angle so for that if I try to add
here an option here angle is equal to
120 so this graphic is rotated by 120°
so you can see here now this points are
lying here like
this right now the next question come
how you can modify it or how you can
think that this this will do do a good
job here I'm trying to give you one idea
now you can see here using this option
angle the three dimensional picture is
rotated now in case if you try to make
here a
loop and try to rotate
this picture by changing the angle so
now this picture can be rotated in
different directions etc etc and when
this picture is
revolving then possibly you try to see
that how these points which are lying
inside the three dimension
picture are changing and then you can
see that whether they are in a plane
looks like a straight line or they are
in some some nonlinear curve etc etc so
by experimenting on this type of three
dimension
plot you can get different type of
information in different ways but
definitely it uh depends on your
imaginative power that how would you
like to think to present the same
picture in a different way and how you
can retrieve different type of
information from
here right so now let me try to show you
this thing on the
our software so that you get here more
confident so if I try to see here that I
have
to first load here the library and I
already have copied this data height
weight and age and now I have to create
here a data frame right so if you try to
create it here it will look like data
3D right and now now in case if you try
to make this command well I can share
with you that I already had installed
this package skatter Pro 3D on my
computer that is why it is giving you
here only I'm using the command library
right so you can see here this type of
command is coming here now in case if
you want to change
it then it will be like here
this so now the angle is rotated by
120° so now if you try to rotate this
angle possibly this if you try to for
example if you try to make it say here
180° you can see here this is change if
you want to make it here say 280° it is
here change if you want to make it here
suppose here 320° it is a change so now
if you try to make it inside a loop then
possibly you will get a you can rotate
it in the desired Direction and can get
different type of information right so
let me close this thing clear the screen
for our next
command and we come back to our
slides okay so now the next uh plot
which we are going to consider is called
as star plots have you seen the
Stars like this
one so this type of picture will come
that is why it is called as start plot
and start plots are very useful when we
want to display the multivariate data
what is the difference between
multivariate data and multiple data
suppose if I say here I have the data on
say here
height
weight
AG on say person number one so if you
try to see now I'm trying to write down
here
the height weight and age on age on
person number one now I try to choose
another person here person number here
two I try to write down the height
weight and age of person number two so
this is my here data First Data this is
my here second data right so this is
actually multivariate data that means
you are trying to write down here uh
variable like as here
height
weight and here H so now this is a three
cross one vector okay we are going to
talk about this type of multivariate
random variable
soon right so this is the type of data
that on that one single data set consist
of more than one variable and when you
try to plot all of them together then
only the data set is complete so in Star
plots each star represents a single
observation for example if I say here
for person number one there will be one
star and person number two there will be
one more star
like
this and this type of plots are used to
examine the relative values of a single
data point and to locate similar point
or say dissimilar points you can think
that when you have multivariate data the
nature of the data depends on different
types of values and when you try to
inspected uh if you try to think about
different values it is very difficult to
conclude what we really want to do and
we always want to see okay what are the
points which are similar which are the
point which are
dissimilar and then we would like to see
that what is the relative values of a
single data point that how height weight
and age are placed for person number one
in comparison to the person number two
so these types of queries can be solved
from the start plots so these start
plots are generated in a multiplot
format and uh if you have more than one
observation so that many St s on are
plotted on each page and each star
represents one observation so if you
have 20 observation there will be 20
star plots on a one page right and uh
the construct of star plot is that a
star plot has got a radius and this
radius is actually a sequence of equ
angular spokes you know for example you
have seen the bicycle bicycle has a
wheel which has a
spokes right if you try to see the
bicycle look like this means like this
and you have here
spokes to maintain the
wheel so and each of this spoke
represent one of the
variables and this this spoke mean the
data values for each of the spoke they
are connected by a line and when you try
to for example if you try
to join these lines these are spokes if
you want to join this lines like this
one
like this one then it looks like a
star that is why it is a star- like
structure and this is called as a star
plots the data length of a Spoke is
proportional to the magnitude of the
variable for the data point related to
the maximum magnitude of the variable
across all data points so that is why by
looking at the size of the star plots
you can get an idea about the magnitude
also
so in our
software the star plots can be created
by using the command Stars s RS and
inside the parenthesis you have to give
the data the data can be here in The
Matrix format or data frame and the each
row of that uh Matrix or the data frame
will be will create one plot right so
each row of this data Matrix or data
frame of X will create one a star plot
and after that there are many options
here say full is equal to two scale is
equal to two radius labels locations X
limit y limit Etc so once again I would
request you that you please try to look
into your help menu and try to see how
you can do it so now let me try to take
an example to explain you here how the
star plots can be created I am
considering here the same example which
we considered
earlier and uh these variables are a
height weight and age the reason being I
want to create here the plots different
plots on the same data set so that you
can compare how are you going to get
different types of information from
different types of plot so I try to
create here the data frame of this
height weight and age which is here like
this data 3D now this is here the data
set right so now if you try to see here
I use here the command here Stars data
3D and you can see here you are getting
here this type of
graphic right so each of uh the
spoke that is trying to indicate one
variable for example this is one spoke
this is one is spoke this is one is
spoke and after that all such points
they are joined by these lines and that
is why they are trying to create a
starlike structure
right so this is how the Stars will look
like and uh yeah suppose now if I try to
add here you can see here there are here
three lines one two and three and
suppose here my data becomes here four
dimensional suppose I try to add here
one more variable here
income yes a hypothetical data so please
consider in that way way now I try to
create a modify my here data frame by
adding here height weight age and income
which is now here data 3d1 which looks
here like this now in case if you try to
plot make the the star plots this will
be your here STS data 3d1 and it will
look like here this you can see here
that this and this picture they are
different now you have here four spokes
1 2 3 and here four
four and this and these points they are
joined here by these lines so now if you
similarly start increasing the the
dimension of your data then you will get
different type of structure but they
will look more or less like the
stars so let me try to create here this
uh picture for you so if you see I
already had created this data frame on
my our
computer so you you can see here
data
3D right and now I try to create here my
stars you can see here these are
here and now in case if I try to add
here one more
variable see here income and I try to
create here this uh new data Vector here
so it will be modified here like this
you can see
here and now if I try to create here the
stars with data
3d1 it will look like this so you can
see here it's not a very difficult thing
to create this start plots but surely
interpreting it in the right way will
require some experience and practice
because you see as soon as you are
trying to change the dimension of the
data from 3 to 4 the structure is
completely changed and now you have to
see that how are you going to interpret
this structure and how are you going to
understand that for example if I try to
look into this graphic that how you can
how are you going to understand by
looking at this picture that what is the
interpretation and how it is going to
interpret the
data right so this requires some
experience
okay so now
we try to understand One More Concept
which is very
interesting first we try to understand
what are we trying to do well in case if
I try to create here two
faces suppose here like
this and here like
this you can see here they are the same
but now if I make here two uh two mines
here one is here like this and one here
is like here this what information do
you get if you try to
see Eyes Nose Etc they are the
same
and similarly if I try to create here
the same face which is here like
this and like this and like this you get
here a different type of information
here so now do you think that these
three faces they are trying to give you
a different type of
information answer is yes and how they
are
differing just by using different types
of structures of eyes nose mouth
Etc you can create different types of
expression if you try to see this
pH
this looks like a happy
face and this look like a sad face and
this possibly looks like a happiest
face so if you try to see if your data
is good as per your definition well in
control and if the same data set can be
expressed in a face structure like this
one and in case if the data is
bad it is not fulfilling your condition
then if the data can be represented in
this type of face which is showing a sad
face then do you think that just by
looking at the faces you can judge
whether the data is good or bad or even
what data is trying to inform
us and
in face we have different types of uh
mean parameters which can be controlled
by eyes nose mouth ears for example if I
make it ears like this one or this one
so they will give you different types of
information and the beauty is
that the way God has created us by
looking at the face we have the
capability or or inherent capability to
just many things you have seen that in
case you can very easily find uh whether
your friend is happy or not
today you can see and look at the faces
and can decide whether the person is
crying or person is laughing right so
this was the idea which was thought to
use to represent the multivari data
multiv data means each of the facial
expression can control one variable and
now face has so many
variables so at
least some finite number of uh variables
can be controlled just by plotting this
two-dimensional plot which is called as
turnoff faces why this is called like
this because actually these faces were
devised or proposed by Professor Heron
kof and he proposed to use this cartoon
like faces to represent the points in
the K dimension
definitely K is going to be some finite
value and he noted that the human mind's
ability to decode host of meaning from
people minutes expression so he thought
to leverage it to the incode data into
cartoon faces for statistical
visualization it is
correct means if you try to see that
human being can make various types of
faces and by looking at them we can
immediately judge what the person is
trying to think happy sad not so happy
etc etc and these expressions are given
only by the facial features like eyes
nose eyebrows ears Etc so if I try to
map the facial features to multiple
variables with size orientation shape
color placement possibly they can
potentially represent the different
attributes of a single observation right
for example if I take the example of
Health the Health depends on several
factors height weight age blood pressure
blood sugar different things so now if a
person is healthy do you think that the
face of the person should look like a
happy face and if the person is not
healthy then the face of the person
should look like a sad face so this is
how we can create the multivariate
graphics so the main use of this phase
graph is to enhance the user ability to
detect similarities between different
items why we sometime make a statement
okay his face is very similar to someone
for example his father's face or
mother's face how do you judge it you
just try to look uh at the two faces and
you immediately take a call that whether
the faces are similar or not so this is
our ability God has given us this
ability even the person is not so
qualified respective of the education
one can very easily identify the faces
and can judge what person is trying to
think and how the person is
feeling right so this concept is used to
detect the similarity or dissimilarity
among different data points in a
multivariate setup the another advantage
of faces is that isase of monitoring the
sensitivity of variables to each other
fast identification of key
differentiating dimensions and to detect
the longitudinal Trends right definitely
I'm not going to explain you each and
everything here but I will try to show
you here how you can create such faces
but after that if you try to create
different types of data set and try to
create different types of faces you can
very easily uh obtain them well means
you know that when we are going into the
multivariate direction the dimensions
are increasing so it is so the level of
difficulty is going to be more so
implementing the visualizations of this
kop is is challenging the data must be
normalized and often been in order to
convey meaning how to normalize the data
is an issue is a topic which we are
going to learn in the forthcoming
lectures and sometime if you see that
the data that there are some data set
which are very very close to each other
then we try to combine them in in the
single bin but how to do it that is also
a challenge but with an experience we
can always learn it right sometime the
scaling and normalization can be
complicated for example if there are
different variables of different kinds
of data some categorical variable some
continuous variable some discrete
variable but anyway when we are trying
to move into the multivariated direction
we should be mentally prepared to handle
such complications and such challenges
and I believe that as a human being if
we cannot do it then who else will do it
so now we learn how to create uh such
faces in the r software for that we need
a special package here APL P for that uh
you can use the command here install.
packages and it will be installed and
then you have to load it using the
library command and after that the
command is f AES faces and inside the
parenthesis you have to give the data
right so if if you try to go into the
help menu then you will find here
different types of options which are
available here and so like as scale buo
main color
eyes and then mean color hair color face
etc etc so I'm not going into these
details but I would uh request you all
to look into the help menu and try to
understand it and this data what you are
going to enter here it has to be in the
format of say metrix or data frame and
each row of the Matrix or data frame
will indicate one set of
variable right for example in this
offices you can use 15 variables at a
time and these variables are indicating
different parameters like as height of
face width of face shape of face height
of mouth width of mouth curve of a smile
height of eyes width of eyes height of
hair width of hair styling of hair
height of nose WID width of nose width
of ears and height of ears right so
these are the uh order in which you will
get the outcome so in case if you have
15 variables then there is no issue but
if you have say less number of variables
then the data is repeated for remaining
type of uh parameters so let me try to
take here the example so once again I
will try to take the same uh example of
height weight and age and this data has
been stored in our data frame name data
3D now I try to create here the uh this
uh I try to execute here the command
faces data 3D so as soon as you execute
it here you will get here uh this type
of outcome right so you can see here it
is trying to tell you here what are your
variables and how this command faces has
modify it for example height is now
modified to that is indicated by height
of face weight is indicated by the width
of phas age is indicated by the
structure of phas now because we have
not uh use all the 15 variables so now
this is getting
repeated right and all these different
uh feature facial expressions are being
reflected using the data what is stored
in height weight and age right so well
my objective was here to illustrate you
how to do it but definitely I would
request you to take a dat which has 15
such variables and try to create this uh
graph and after that you will see that
this type of picture will come you can
see here these are different types of
data sets different types of colors and
you can see here what is happening so
you have here you can see here these are
here five rows for 1 2 3 four five and
then you have here such five faces right
so let me try to show you this outcome
in
the our console so I already have uh
means U installed this package on my
laptop but you need to install it but I
need to upload it surely so if you try
to see here let me clear the screen so
you can see here I have uploaded this
package and if you try to see here this
is your here
data uh which you have stored here and
data 3D right so data 3D is here and
then I will say here faces data 3D so
data 3D is here already here now if I
see here
faces of uh data 3 so you can see here
there are five observation 1 2 3 four
five five sets of observation in five
rows and you can see here this type of
this outcome is here which I shown you
on the screen on the slides and these
are the uh different uh Graphics of
different faces which are coming here
and if you try to vary the data values
the structure of nose Etc there that
will also get actually changed right so
you can see that it is not very
difficult to create such Graphics in the
art software and beside those things
there are several other function like
contour lines dot chart image MOA plot
perspective plot there are many other
options in the our software
which are
available right so now we come to an end
to this lecture and we will also uh stop
here with the description of various
types of
Graphics so now you can see in this
lecture we have considered start plots
and this the off
faes which are capable of
handling more than three data
variables but once again I will say if
you try to increase the dimension of the
data different types of complexities
will automatically enter into your
analysis they will enter but it is not
difficult to understand them it is not
difficult to solve them the only thing
what you need is practice and experience
and experience can be gained only by
solving more number of issues more
number of problems and getting more
experience
you can see here now for example in the
case of CH of faces it is handling 15
variables now to understand that which
data is going to change how how the nose
is going to look like if I try to change
increase the data how the eyebrows are
going to look like in case if I reduce
the data how the hairs are going to look
like if I train try to increase the data
or decrease the data
these are different
aspects which you have to learn yourself
I can give you here this
guidance but unless and until you try to
create a data set and try to vary those
different values and try to compare how
the faces are changing and similarly how
the stars are
changing you will not be able to
understand the relationship between data
and the graphic
and finally what are you going to do in
real life you will have a huge data set
you will have no time or no capability
to look into the individual values but
you will try to create such plots like
as chof faces or Star plots now looking
at those faces or this star plots you
have to diagnose what your data is
trying to speak what your data is trying
to inform you and this is the beauty of
graphics
for example you can handle up to 15
variables without any problem just by
looking at the faces for which the God
has given us the inherent capability so
now towards the end of this chapter on
Graphics I would say that I have
considered here only a limited number of
Graphics but there are but there is a
long
list I cannot make you expert in all the
graphics in the given time but
surely I can help you in gaining the
confidence
so that now after this if you want to
learn any other Graphics you can look
into the help menu you can look into the
r software and then I'm sure that you
will be able to plot them successfully
and then you will have an expertise you
will develop an expertise to look into
the graphic and then retrieve the
information from the given set of data
so you try to take an example try to
practice it gain some experience and be
an expert data scientist and I will see
you in the next lecture till then
[Music]
[Music]
[Music]
goodbye
