PCA Luluo achieves dimensionality reduction

PCA big job

 

A program running platform:

PCA is implemented in both matlab2016a and python software; word documents are attached to the source code

MATLAB:https://download.csdn.net/download/strive_0902/10282607

python:https://download.csdn.net/download/strive_0902/10282616

Two design ideas

   1. Read the data of Luluo, convert the content of the txt file into a 23073x6 matrix and save it in Data.

   2. Centralize the sample 

   3. Obtain new data and find the covariance matrix:

   4. Eigenvalue decomposition of Cx

   5. Calculate Y=PX . is obtained , where each vector is the data after PCA to dimensionality reduction.

 

Three code optimization

Since the data point of Luluo is 23073x6 , during the centralization operation, first set up a for loop to obtain the mean value of 6 columns in turn, and then subtract its corresponding mean value from each element. Such a loop takes time and increases the complexity of the algorithm; Here, we call the function C=bsxfun(fun,A,B) that comes with matlab, a binary operation that calculates the elements between two arrays A and B one by one, fun is the function handle or m file , that is: T = bsxfun( @minus, T, mean(T)) , which makes the computation faster.

 

4. Graph and analysis of experimental results 

   The experimental results are divided into two parts: one and two pivot diagrams after PCA dimensionality reduction and one, two and four pivot diagrams after PCA dimensionality reduction, each part has a rotated multi-angle image for comparison. As shown in the following figure: the first six are the result graphs realized by MATLAB; the last two are the result graphs realized by python




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325608525&siteId=291194637