@@ -29,7 +29,7 @@ def column_reshape(input_array: np.ndarray) -> np.ndarray:
29
29
30
30
31
31
def covariance_within_classes (
32
- features : np .ndarray , labels : np .ndarray , classes : int
32
+ features : np .ndarray , labels : np .ndarray , classes : int
33
33
) -> np .ndarray :
34
34
"""Function to compute the covariance matrix inside each class.
35
35
>>> features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
@@ -57,7 +57,7 @@ def covariance_within_classes(
57
57
58
58
59
59
def covariance_between_classes (
60
- features : np .ndarray , labels : np .ndarray , classes : int
60
+ features : np .ndarray , labels : np .ndarray , classes : int
61
61
) -> np .ndarray :
62
62
"""Function to compute the covariance matrix between multiple classes
63
63
>>> features = np.array([[9, 2, 3], [4, 3, 6], [1, 8, 9]])
@@ -121,7 +121,7 @@ def principal_component_analysis(features: np.ndarray, dimensions: int) -> np.nd
121
121
122
122
123
123
def linear_discriminant_analysis (
124
- features : np .ndarray , labels : np .ndarray , classes : int , dimensions : int
124
+ features : np .ndarray , labels : np .ndarray , classes : int , dimensions : int
125
125
) -> np .ndarray :
126
126
"""
127
127
Linear Discriminant Analysis.
@@ -186,9 +186,11 @@ def test_linear_discriminant_analysis() -> None:
186
186
def test_principal_component_analysis () -> None :
187
187
features = np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]])
188
188
dimensions = 2
189
- expected_output = np .array ([[6.92820323 , 8.66025404 , 10.39230485 ], [3. , 3. , 3. ]])
189
+ expected_output = np .array ([[6.92820323 , 8.66025404 , 10.39230485 ], [3.0 , 3.0 , 3.0 ]])
190
190
output = principal_component_analysis (features , dimensions )
191
- assert np .allclose (expected_output , output ), f"Expected { expected_output } , but got { output } "
191
+ assert np .allclose (
192
+ expected_output , output
193
+ ), f"Expected { expected_output } , but got { output } "
192
194
193
195
194
196
if __name__ == "__main__" :
0 commit comments