concept SVD in category data

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.
Scikit-Learn contains a dimension reduction class called
TruncatedSVD. The class is designed for optimal execution of SVD. Lets importTruncatedSVDfromsklearn.decomposition.Listing 14.56. Importing
TruncatedSVDfrom Scikit-Learnfrom sklearn.decomposition import TruncatedSVDApplying
TruncatedSVDto ourflower_measurementsdata is easy. First, we need to runTruncatedSVD(n_components=2). This will create ansvd_objectobject capable of reducing data to 2-dimensions. Afterwards, we can execute SVD by runningsvd_object.fit_predict(flower_measurements). That method-call will return a 2-dimensionalsvd_transformed_datamatrix. 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.