Principal component analysis (PCA) implementation. Transforms a dataset of possibly correlated values into n linearly uncorrelated components. The components are ordered such that the first has the largest possible variance and each following component as the largest
(self, n_components, solver="svd")
| 13 | y_required = False |
| 14 | |
| 15 | def __init__(self, n_components, solver="svd"): |
| 16 | """Principal component analysis (PCA) implementation. |
| 17 | |
| 18 | Transforms a dataset of possibly correlated values into n linearly |
| 19 | uncorrelated components. The components are ordered such that the first |
| 20 | has the largest possible variance and each following component as the |
| 21 | largest possible variance given the previous components. This causes |
| 22 | the early components to contain most of the variability in the dataset. |
| 23 | |
| 24 | Parameters |
| 25 | ---------- |
| 26 | n_components : int |
| 27 | solver : str, default 'svd' |
| 28 | {'svd', 'eigen'} |
| 29 | """ |
| 30 | self.solver = solver |
| 31 | self.n_components = n_components |
| 32 | self.components = None |
| 33 | self.mean = None |
| 34 | |
| 35 | def fit(self, X, y=None): |
| 36 | self.mean = np.mean(X, axis=0) |
nothing calls this directly
no outgoing calls
no test coverage detected