Skip to content

Commit 7484cda

Browse files
committed
ridge regression
1 parent 6fc134d commit 7484cda

File tree

1 file changed

+0
-14
lines changed
  • machine_learning/ridge_regression

1 file changed

+0
-14
lines changed

machine_learning/ridge_regression/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ def __init__(self, alpha:float=0.001, regularization_param:float=0.1, num_iterat
99
self.num_iterations:int = num_iterations
1010
self.theta:np.ndarray = None
1111

12-
<<<<<<< HEAD
1312

1413
def feature_scaling(self, X:np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
15-
=======
16-
def feature_scaling(self, X):
17-
>>>>>>> d4fc2bf852ec4a023380f4ef367edefa88fd6881
1814
mean = np.mean(X, axis=0)
1915
std = np.std(X, axis=0)
2016

@@ -43,13 +39,8 @@ def predict(self, X:np.ndarray) -> np.ndarray:
4339
X_scaled, _, _ = self.feature_scaling(X)
4440
return X_scaled.dot(self.theta)
4541

46-
<<<<<<< HEAD
4742
def compute_cost(self, X:np.ndarray, y:np.ndarray) -> float:
4843
X_scaled, _, _ = self.feature_scaling(X)
49-
=======
50-
def compute_cost(self, X, y):
51-
X_scaled, _, _ = self.feature_scaling(X)
52-
>>>>>>> d4fc2bf852ec4a023380f4ef367edefa88fd6881
5344
m = len(y)
5445

5546
predictions = X_scaled.dot(self.theta)
@@ -69,13 +60,8 @@ def mean_absolute_error(self, y_true:np.ndarray, y_pred:np.ndarray) -> float:
6960
y = df["ADR"].values
7061
y = (y - np.mean(y)) / np.std(y)
7162

72-
<<<<<<< HEAD
7363
# added bias term to the feature matrix
7464
X = np.c_[np.ones(X.shape[0]), X]
75-
=======
76-
# Add bias term (intercept) to the feature matrix
77-
X = np.c_[np.ones(X.shape[0]), X]
78-
>>>>>>> d4fc2bf852ec4a023380f4ef367edefa88fd6881
7965

8066
# initialize and train the ridge regression model
8167
model = RidgeRegression(alpha=0.01, regularization_param=0.1, num_iterations=1000)

0 commit comments

Comments
 (0)