-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
added ridge regression #12250
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
added ridge regression #12250
Changes from 1 commit
1cb79bc
b72320b
d4fc2bf
a84d209
6fc134d
21fe32f
7484cda
b1353dd
2eeb450
1713cbe
3876437
c76784e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
for more information, see https://pre-commit.ci
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import numpy as np | ||
Check failure on line 1 in machine_learning/ridge_regression/model.py
|
||
import pandas as pd | ||
|
||
|
||
class RidgeRegression: | ||
def __init__(self, alpha:float=0.001, regularization_param:float=0.1, num_iterations:int=1000) -> None: | ||
self.alpha:float = alpha | ||
self.regularization_param:float = regularization_param | ||
self.num_iterations:int = num_iterations | ||
self.theta:np.ndarray = None | ||
|
||
<<<<<<< HEAD | ||
Check failure on line 12 in machine_learning/ridge_regression/model.py
|
||
|
||
def feature_scaling(self, X:np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]: | ||
Check failure on line 14 in machine_learning/ridge_regression/model.py
|
||
======= | ||
Check failure on line 15 in machine_learning/ridge_regression/model.py
|
||
def feature_scaling(self, X): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide descriptive name for the parameter: Please provide type hint for the parameter: |
||
>>>>>>> d4fc2bf852ec4a023380f4ef367edefa88fd6881 | ||
mean = np.mean(X, axis=0) | ||
|
@@ -45,7 +45,7 @@ | |
|
||
<<<<<<< HEAD | ||
def compute_cost(self, X:np.ndarray, y:np.ndarray) -> float: | ||
X_scaled, _, _ = self.feature_scaling(X) | ||
X_scaled, _, _ = self.feature_scaling(X) | ||
======= | ||
def compute_cost(self, X, y): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide descriptive name for the parameter: Please provide type hint for the parameter: Please provide descriptive name for the parameter: Please provide type hint for the parameter: |
||
X_scaled, _, _ = self.feature_scaling(X) | ||
|
@@ -71,7 +71,7 @@ | |
|
||
<<<<<<< HEAD | ||
# added bias term to the feature matrix | ||
X = np.c_[np.ones(X.shape[0]), X] | ||
X = np.c_[np.ones(X.shape[0]), X] | ||
======= | ||
# Add bias term (intercept) to the feature matrix | ||
X = np.c_[np.ones(X.shape[0]), X] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error occurred while parsing the file:
machine_learning/ridge_regression/model.py