Created
January 21, 2020 16:24
-
-
Save Daiver/84b0e1ab14c461d65b709c25b6c0a214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
X = np.array([ | |
[1, 1], | |
[1.5, 0], | |
[3, 3] | |
], dtype=np.float) | |
y = np.array([1, 2, 3], dtype=np.float) | |
transformation = np.array([ | |
[10, 0], | |
[0, 1] | |
], dtype=np.float) | |
clambda = 0.00 | |
H = X.T @ X + clambda * np.eye(X.shape[1]) | |
g = X.T @ y | |
weights = np.linalg.solve(H, g) | |
error = np.linalg.norm(X @ weights - y) | |
print(weights) | |
print(error) | |
X = X @ transformation | |
H = X.T @ X + clambda * np.eye(X.shape[1]) | |
g = X.T @ y | |
weights = np.linalg.solve(H, g) | |
error = np.linalg.norm(X @ weights - y) | |
print(weights) | |
print(weights.T @ transformation) | |
print(error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment