Created
October 13, 2018 18:02
-
-
Save joaofig/fa8b0b341c887c76a44ae4ee54dbdd57 to your computer and use it in GitHub Desktop.
Calculates the estimated y values for a quadratic function
This file contains hidden or 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
| def calculate_y_hat(self, x, y): | |
| xx, yy = x, y | |
| if torch.is_tensor(x): | |
| xx = x.numpy() | |
| if torch.is_tensor(y): | |
| yy = y.numpy() | |
| coefficients = np.polyfit(xx, yy, 2) | |
| polynomial = np.poly1d(coefficients) | |
| y_hat = polynomial(xx) | |
| return y_hat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment