concept SVD in category data

appears as: SVD
Data Science Bookcamp: Five Python Projects

This is an excerpt from Manning's book Data Science Bookcamp: Five Python Projects.

Unlike PCA, SVD is not guaranteed to maximize the variance for each axis in the reduced output. However, in most real-world circumstances, SVD is able to dimensionally-reduce data to a very practical degree.

The mathematical properties of SVD are complicated. They lie beyond the scope of this book. Nonetheless, computer scientists can leverage these properties to execute SVD very efficiently. These optimizations have been incorporated into Scikit-Learn. In the next subsection, we’ll utilize Scikit-Learn’s optimized SVD implementation.

14.5  Efficient Dimension Reduction Using SVD and Scikit-Learn

Scikit-Learn contains a dimension reduction class called TruncatedSVD. The class is designed for optimal execution of SVD. Lets import TruncatedSVD from sklearn.decomposition.

Listing 14.56. Importing TruncatedSVD from Scikit-Learn
from sklearn.decomposition import TruncatedSVD

Applying TruncatedSVD to our flower_measurements data is easy. First, we need to run TruncatedSVD(n_components=2). This will create an svd_object object capable of reducing data to 2-dimensions. Afterwards, we can execute SVD by running svd_object.fit_predict(flower_measurements). That method-call will return a 2-dimensional svd_transformed_data matrix. Below, we’ll execute these steps, and then plot our results. The plot should resemble our custom SVD output, as seen in Figure 14.24.