Skip to content

Commit 55850d4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 85f1730 commit 55850d4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: machine_learning/dimensionality_reduction.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def column_reshape(input_array: np.ndarray) -> np.ndarray:
2929

3030

3131
def covariance_within_classes(
32-
features: np.ndarray, labels: np.ndarray, classes: int
32+
features: np.ndarray, labels: np.ndarray, classes: int
3333
) -> np.ndarray:
3434
"""Function to compute the covariance matrix inside each class.
3535
>>> features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
@@ -57,7 +57,7 @@ def covariance_within_classes(
5757

5858

5959
def covariance_between_classes(
60-
features: np.ndarray, labels: np.ndarray, classes: int
60+
features: np.ndarray, labels: np.ndarray, classes: int
6161
) -> np.ndarray:
6262
"""Function to compute the covariance matrix between multiple classes
6363
>>> 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
121121

122122

123123
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
125125
) -> np.ndarray:
126126
"""
127127
Linear Discriminant Analysis.
@@ -186,9 +186,11 @@ def test_linear_discriminant_analysis() -> None:
186186
def test_principal_component_analysis() -> None:
187187
features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
188188
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]])
190190
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}"
192194

193195

194196
if __name__ == "__main__":

0 commit comments

Comments
 (0)