[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-10-23 15:25:53 +00:00
parent 38764378d4
commit c76784e708

View File

@ -3,11 +3,12 @@ import pandas as pd
class RidgeRegression: class RidgeRegression:
def __init__(self, def __init__(
alpha: float = 0.001, self,
regularization_param: float = 0.1, alpha: float = 0.001,
num_iterations: int = 1000, regularization_param: float = 0.1,
) -> None: num_iterations: int = 1000,
) -> None:
self.alpha: float = alpha self.alpha: float = alpha
self.regularization_param: float = regularization_param self.regularization_param: float = regularization_param
self.num_iterations: int = num_iterations self.num_iterations: int = num_iterations
@ -49,10 +50,9 @@ class RidgeRegression:
m = len(y) m = len(y)
predictions = x_scaled.dot(self.theta) predictions = x_scaled.dot(self.theta)
cost = ( cost = (1 / (2 * m)) * np.sum((predictions - y) ** 2) + (
1 / (2 * m)) * np.sum((predictions - y) ** 2) + ( self.regularization_param / (2 * m)
self.regularization_param / (2 * m) ) * np.sum(self.theta**2)
) * np.sum(self.theta**2)
return cost return cost
def mean_absolute_error(self, y_true: np.ndarray, y_pred: np.ndarray) -> float: def mean_absolute_error(self, y_true: np.ndarray, y_pred: np.ndarray) -> float: