mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
61945d03c6
commit
a2d07af8c1
@ -62,7 +62,9 @@ class RidgeRegression:
|
||||
>>> rr.theta is not None
|
||||
True
|
||||
"""
|
||||
features_scaled, mean, std = self.feature_scaling(features) # Normalize features
|
||||
features_scaled, mean, std = self.feature_scaling(
|
||||
features
|
||||
) # Normalize features
|
||||
m, n = features_scaled.shape
|
||||
self.theta = np.zeros(n) # Initialize weights to zeros
|
||||
|
||||
@ -90,7 +92,9 @@ class RidgeRegression:
|
||||
>>> predictions.shape == target.shape
|
||||
True
|
||||
"""
|
||||
features_scaled, _, _ = self.feature_scaling(features) # Scale features using training data
|
||||
features_scaled, _, _ = self.feature_scaling(
|
||||
features
|
||||
) # Scale features using training data
|
||||
return features_scaled.dot(self.theta)
|
||||
|
||||
def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
|
||||
@ -110,7 +114,9 @@ class RidgeRegression:
|
||||
>>> isinstance(cost, float)
|
||||
True
|
||||
"""
|
||||
features_scaled, _, _ = self.feature_scaling(features) # Scale features using training data
|
||||
features_scaled, _, _ = self.feature_scaling(
|
||||
features
|
||||
) # Scale features using training data
|
||||
m = len(target)
|
||||
predictions = features_scaled.dot(self.theta)
|
||||
cost = (1 / (2 * m)) * np.sum((predictions - target) ** 2) + (
|
||||
|
Loading…
x
Reference in New Issue
Block a user