Last active
June 1, 2022 13:58
-
-
Save kozo496/8a557f520886dadb3aa43b3a03b9c6b4 to your computer and use it in GitHub Desktop.
Numpyを使った線形回帰
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 | |
def linear_regression(x,y): | |
A = np.vstack([x, np.ones(len(x))]).T | |
a, b = np.linalg.lstsq(A, y, rcond=None)[0] | |
return a, b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment