Skip to content

Commit d5963b2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 544a38b commit d5963b2

File tree

1 file changed

+9
-9
lines changed
  • machine_learning/ridge_regression

1 file changed

+9
-9
lines changed

machine_learning/ridge_regression/model.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44

55
class RidgeRegression:
6-
def __init__(self,
7-
alpha: float = 0.001,
8-
regularization_param: float = 0.1,
9-
num_iterations: int = 1000,
10-
) -> None:
6+
def __init__(
7+
self,
8+
alpha: float = 0.001,
9+
regularization_param: float = 0.1,
10+
num_iterations: int = 1000,
11+
) -> None:
1112
self.alpha: float = alpha
1213
self.regularization_param: float = regularization_param
1314
self.num_iterations: int = num_iterations
@@ -49,10 +50,9 @@ def compute_cost(self, x: np.ndarray, y: np.ndarray) -> float:
4950
m = len(y)
5051

5152
predictions = x_scaled.dot(self.theta)
52-
cost = (
53-
1 / (2 * m)) * np.sum((predictions - y) ** 2) + (
54-
self.regularization_param / (2 * m)
55-
) * np.sum(self.theta**2)
53+
cost = (1 / (2 * m)) * np.sum((predictions - y) ** 2) + (
54+
self.regularization_param / (2 * m)
55+
) * np.sum(self.theta**2)
5656
return cost
5757

5858
def mean_absolute_error(self, y_true: np.ndarray, y_pred: np.ndarray) -> float:

0 commit comments

Comments
 (0)