|
8 | 8 | - Locally Linear Embedding (LLE) |
9 | 9 | - Multidimensional Scaling (MDS) |
10 | 10 | """ |
| 11 | + |
11 | 12 | """ |
12 | 13 | Requirements: |
13 | 14 | - numpy version 1.21 |
@@ -121,9 +122,7 @@ def covariance_between_classes( |
121 | 122 | return covariance_sum / features.shape[1] |
122 | 123 |
|
123 | 124 |
|
124 | | -def principal_component_analysis( |
125 | | - features: np.ndarray, dimensions: int |
126 | | -) -> np.ndarray: |
| 125 | +def principal_component_analysis(features: np.ndarray, dimensions: int) -> np.ndarray: |
127 | 126 | """Principal Component Analysis (PCA). |
128 | 127 |
|
129 | 128 | For more details: https://en.wikipedia.org/wiki/Principal_component_analysis |
@@ -424,16 +423,16 @@ def test_linear_discriminant_analysis() -> None: |
424 | 423 | features, labels, classes, dimensions |
425 | 424 | ) |
426 | 425 | if isinstance(projected_data, np.ndarray): |
427 | | - raise AssertionError("Did not raise AssertionError for dimensions > classes") |
| 426 | + raise AssertionError( |
| 427 | + "Did not raise AssertionError for dimensions > classes" |
| 428 | + ) |
428 | 429 |
|
429 | 430 |
|
430 | 431 | def test_principal_component_analysis() -> None: |
431 | 432 | """Test function for Principal Component Analysis.""" |
432 | 433 | features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) |
433 | 434 | dimensions = 2 |
434 | | - expected_output = np.array( |
435 | | - [[6.92820323, 8.66025404, 10.39230485], [3.0, 3.0, 3.0]] |
436 | | - ) |
| 435 | + expected_output = np.array([[6.92820323, 8.66025404, 10.39230485], [3.0, 3.0, 3.0]]) |
437 | 436 |
|
438 | 437 | output = principal_component_analysis(features, dimensions) |
439 | 438 | if not np.allclose(expected_output, output): |
|
0 commit comments