Creating three-dimensional scatter plots to present principal components
Principal components are nothing more than multidimensional vectors that we can use to transform our data. By finding the principal dimensions of our data, we can discover a different picture that our data paints.
Getting ready
To execute this recipe, you will need Matplotlib
with MPL Toolkits. These should come preinstalled if you are using the Anaconda distribution of Python. No other prerequisites are required.
How to do it…
To plot our three-dimensional data, we will use the plot_components(...)
method (the helper.py
file):
def plot_components(z, y, color_marker, **f_params): ''' Produce and save the chart presenting 3 principal components ''' # import necessary modules import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # convert the dependent into a Numpy array # this is done so z and y are in the same format ...