Skip to content

Commit 59d3ceb

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

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

Diff for: machine_learning/ridge_regression/test_ridge_regression.py

+26-20
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,69 @@
1414
import numpy as np
1515
from ridge_regression import RidgeRegression
1616

17+
1718
def test_feature_scaling():
1819
"""
19-
Tests the feature_scaling function of RidgeRegression.
20-
--------
21-
>>> model = RidgeRegression()
22-
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
23-
>>> X_scaled, mean, std = model.feature_scaling(X)
24-
>>> np.round(X_scaled, 2)
25-
array([[-1.22, -1.22],
26-
[ 0. , 0. ],
27-
[ 1.22, 1.22]])
28-
>>> np.round(mean, 2)
29-
array([2., 3.])
30-
>>> np.round(std, 2)
31-
array([0.82, 0.82])
20+
Tests the feature_scaling function of RidgeRegression.
21+
--------
22+
>>> model = RidgeRegression()
23+
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
24+
>>> X_scaled, mean, std = model.feature_scaling(X)
25+
>>> np.round(X_scaled, 2)
26+
array([[-1.22, -1.22],
27+
[ 0. , 0. ],
28+
[ 1.22, 1.22]])
29+
>>> np.round(mean, 2)
30+
array([2., 3.])
31+
>>> np.round(std, 2)
32+
array([0.82, 0.82])
3233
"""
3334
pass
3435

36+
3537
def test_fit():
3638
"""
3739
Tests the fit function of RidgeRegression
3840
--------
3941
>>> model = RidgeRegression(alpha=0.01, regularization_param=0.1, num_iterations=1000)
4042
>>> X = np.array([[1], [2], [3]])
4143
>>> y = np.array([2, 3, 4])
42-
44+
4345
# Adding a bias term
4446
>>> X = np.c_[np.ones(X.shape[0]), X]
45-
47+
4648
# Fit the model
4749
>>> model.fit(X, y)
48-
50+
4951
# Check if the weights have been updated
5052
>>> np.round(model.theta, decimals=2)
5153
array([0. , 0.79])
5254
"""
5355
pass
5456

57+
5558
def test_predict():
5659
"""
5760
Tests the predict function of RidgeRegression
5861
--------
5962
>>> model = RidgeRegression(alpha=0.01, regularization_param=0.1, num_iterations=1000)
6063
>>> X = np.array([[1], [2], [3]])
6164
>>> y = np.array([2, 3, 4])
62-
65+
6366
# Adding a bias term
6467
>>> X = np.c_[np.ones(X.shape[0]), X]
65-
68+
6669
# Fit the model
6770
>>> model.fit(X, y)
68-
71+
6972
# Predict with the model
7073
>>> predictions = model.predict(X)
7174
>>> np.round(predictions, decimals=2)
7275
array([-0.97, 0. , 0.97])
7376
"""
7477
pass
7578

79+
7680
def test_mean_absolute_error():
7781
"""
7882
Tests the mean_absolute_error function of RidgeRegression
@@ -86,6 +90,8 @@ def test_mean_absolute_error():
8690
"""
8791
pass
8892

93+
8994
if __name__ == "__main__":
9095
import doctest
91-
doctest.testmod()
96+
97+
doctest.testmod()

0 commit comments

Comments
 (0)