Skip to content

Instantly share code, notes, and snippets.

@kozo496
Last active June 1, 2022 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozo496/8a557f520886dadb3aa43b3a03b9c6b4 to your computer and use it in GitHub Desktop.
Save kozo496/8a557f520886dadb3aa43b3a03b9c6b4 to your computer and use it in GitHub Desktop.
Numpyを使った線形回帰
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