|
6 | 6 | Notes: |
7 | 7 | - Each column of the features matrix corresponds to a class item |
8 | 8 | """ |
9 | | - |
10 | 9 | """ |
11 | 10 | Implementation of dimensionality reduction algorithms. |
12 | 11 |
|
@@ -124,7 +123,7 @@ def covariance_between_classes( |
124 | 123 | def principal_component_analysis(features: np.ndarray, dimensions: int) -> np.ndarray: |
125 | 124 | """Principal Component Analysis (PCA). |
126 | 125 |
|
127 | | - For more details: https://en.wikipedia.org/wiki/Principal_component_analysis |
| 126 | + For more details: https://en.wikipedia.org/wiki/Principal_component_analysis |
128 | 127 |
|
129 | 128 | Args: |
130 | 129 | features: Input features matrix (n_features x n_samples). |
@@ -158,7 +157,7 @@ def linear_discriminant_analysis( |
158 | 157 | ) -> np.ndarray: |
159 | 158 | """Linear Discriminant Analysis (LDA). |
160 | 159 |
|
161 | | - For more details: https://en.wikipedia.org/wiki/Linear_discriminant_analysis |
| 160 | + For more details: https://en.wikipedia.org/wiki/Linear_discriminant_analysis |
162 | 161 |
|
163 | 162 | Args: |
164 | 163 | features: Input features matrix (n_features x n_samples). |
@@ -199,7 +198,7 @@ def locally_linear_embedding( |
199 | 198 | ) -> np.ndarray: |
200 | 199 | """Locally Linear Embedding (LLE). |
201 | 200 |
|
202 | | - For more details: https://en.wikipedia.org/wiki/Nonlinear_dimensionality_reduction |
| 201 | + For more details: https://en.wikipedia.org/wiki/Nonlinear_dimensionality_reduction |
203 | 202 |
|
204 | 203 | Args: |
205 | 204 | features: Input features matrix (shape: [n_features, n_samples]). |
@@ -284,7 +283,7 @@ def multidimensional_scaling( |
284 | 283 | ) -> np.ndarray: |
285 | 284 | """Multidimensional Scaling (MDS). |
286 | 285 |
|
287 | | - For more details: https://en.wikipedia.org/wiki/Multidimensional_scaling |
| 286 | + For more details: https://en.wikipedia.org/wiki/Multidimensional_scaling |
288 | 287 |
|
289 | 288 | Args: |
290 | 289 | features: Input features matrix (shape: [n_features, n_samples]). |
@@ -430,7 +429,9 @@ def test_principal_component_analysis() -> None: |
430 | 429 | """Test function for Principal Component Analysis.""" |
431 | 430 | features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) |
432 | 431 | dimensions = 2 |
433 | | - expected_output = np.array([[6.92820323, 8.66025404, 10.39230485], [3.0, 3.0, 3.0]]) |
| 432 | + expected_output = np.array( |
| 433 | + [[6.92820323, 8.66025404, 10.39230485], [3.0, 3.0, 3.0]] |
| 434 | + ) |
434 | 435 |
|
435 | 436 | output = principal_component_analysis(features, dimensions) |
436 | 437 | if not np.allclose(expected_output, output): |
|
0 commit comments