Skip to content

Fixes issue #12233: Avoid log(0) in KL, ruff and build checks #12263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1cb79bc
added ridge regression
ankana2113 Oct 23, 2024
b72320b
added ridge regression
ankana2113 Oct 23, 2024
d4fc2bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
a84d209
added ridge regression
ankana2113 Oct 23, 2024
6fc134d
added ridge regression
ankana2113 Oct 23, 2024
21fe32f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
7484cda
ridge regression
ankana2113 Oct 23, 2024
b1353dd
ridge regression
ankana2113 Oct 23, 2024
2eeb450
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
1713cbe
resolved errors
ankana2113 Oct 23, 2024
3876437
resolved conflicts
ankana2113 Oct 23, 2024
c76784e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
544a38b
resolved conflicts
ankana2113 Oct 23, 2024
d5963b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
b0255a8
added doctests
ankana2113 Oct 24, 2024
d8c0b7c
Merge branch 'main' of https://github.com/ankana2113/Python
ankana2113 Oct 24, 2024
59d3ceb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2024
83d7252
ruff and minor checks
ankana2113 Oct 24, 2024
1918aac
Merge branch 'main' of https://github.com/ankana2113/Python
ankana2113 Oct 24, 2024
f614b2e
minor chenges
ankana2113 Oct 24, 2024
254b9bf
minor checks
ankana2113 Oct 24, 2024
97eb853
minor checks
ankana2113 Oct 24, 2024
dcf47d4
minor changes
ankana2113 Oct 24, 2024
0ea341a
descriptive names
ankana2113 Oct 24, 2024
1ff7975
Fix ruff check in loss_functions.py
ankana2113 Oct 24, 2024
1459adf
fixed pre-commit issues
ankana2113 Oct 24, 2024
0c04372
Merge pull request #1 from ankana2113/main
ankana2113 Oct 24, 2024
5c2d1fe
added largest rectangle histogram function
ankana2113 Oct 24, 2024
50d5bb1
added largest rectangle histogram function
ankana2113 Oct 24, 2024
d029119
Merge branch 'master' of https://github.com/ankana2113/Python
ankana2113 Oct 24, 2024
b00284f
Merge branch 'largest_rect'
ankana2113 Oct 24, 2024
bfb8167
added kadane's algo
ankana2113 Oct 24, 2024
91f0395
Merge pull request #2 from ankana2113/kadane_algo
ankana2113 Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 24, 2024
commit 59d3ceba272d97616e0f10fbeac69b07b8610777
46 changes: 26 additions & 20 deletions machine_learning/ridge_regression/test_ridge_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,72 @@
python -m doctest test_ridge_regression.py -v
"""

import numpy as np

Check failure on line 14 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

machine_learning/ridge_regression/test_ridge_regression.py:14:17: F401 `numpy` imported but unused
from ridge_regression import RidgeRegression

Check failure on line 15 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

machine_learning/ridge_regression/test_ridge_regression.py:15:30: F401 `ridge_regression.RidgeRegression` imported but unused


def test_feature_scaling():
"""
Tests the feature_scaling function of RidgeRegression.
--------
>>> model = RidgeRegression()
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
>>> X_scaled, mean, std = model.feature_scaling(X)
>>> np.round(X_scaled, 2)
array([[-1.22, -1.22],
[ 0. , 0. ],
[ 1.22, 1.22]])
>>> np.round(mean, 2)
array([2., 3.])
>>> np.round(std, 2)
array([0.82, 0.82])
Tests the feature_scaling function of RidgeRegression.
--------
>>> model = RidgeRegression()
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
>>> X_scaled, mean, std = model.feature_scaling(X)
>>> np.round(X_scaled, 2)
array([[-1.22, -1.22],
[ 0. , 0. ],
[ 1.22, 1.22]])
>>> np.round(mean, 2)
array([2., 3.])
>>> np.round(std, 2)
array([0.82, 0.82])
"""
pass

Check failure on line 34 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PIE790)

machine_learning/ridge_regression/test_ridge_regression.py:34:5: PIE790 Unnecessary `pass` statement


def test_fit():
"""
Tests the fit function of RidgeRegression
--------
>>> model = RidgeRegression(alpha=0.01, regularization_param=0.1, num_iterations=1000)

Check failure on line 41 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

machine_learning/ridge_regression/test_ridge_regression.py:41:89: E501 Line too long (90 > 88)
>>> X = np.array([[1], [2], [3]])
>>> y = np.array([2, 3, 4])

# Adding a bias term
>>> X = np.c_[np.ones(X.shape[0]), X]

# Fit the model
>>> model.fit(X, y)

# Check if the weights have been updated
>>> np.round(model.theta, decimals=2)
array([0. , 0.79])
"""
pass

Check failure on line 55 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PIE790)

machine_learning/ridge_regression/test_ridge_regression.py:55:5: PIE790 Unnecessary `pass` statement


def test_predict():
"""
Tests the predict function of RidgeRegression
--------
>>> model = RidgeRegression(alpha=0.01, regularization_param=0.1, num_iterations=1000)

Check failure on line 62 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

machine_learning/ridge_regression/test_ridge_regression.py:62:89: E501 Line too long (90 > 88)
>>> X = np.array([[1], [2], [3]])
>>> y = np.array([2, 3, 4])

# Adding a bias term
>>> X = np.c_[np.ones(X.shape[0]), X]

# Fit the model
>>> model.fit(X, y)

# Predict with the model
>>> predictions = model.predict(X)
>>> np.round(predictions, decimals=2)
array([-0.97, 0. , 0.97])
"""
pass

Check failure on line 77 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PIE790)

machine_learning/ridge_regression/test_ridge_regression.py:77:5: PIE790 Unnecessary `pass` statement


def test_mean_absolute_error():
"""
Tests the mean_absolute_error function of RidgeRegression
Expand All @@ -84,8 +88,10 @@
>>> float(np.round(mae, 2))
0.07
"""
pass

Check failure on line 91 in machine_learning/ridge_regression/test_ridge_regression.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PIE790)

machine_learning/ridge_regression/test_ridge_regression.py:91:5: PIE790 Unnecessary `pass` statement


if __name__ == "__main__":
import doctest
doctest.testmod()

doctest.testmod()
Loading