Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def least_square_estimator(X, Y):
- """
- Compute beta (minimum cost computation)
- --------------------------
- (((X^T)X)^-1)((X^T)Y)
- Order
- --------------------------
- First = (((X^T)X)^-1)
- Second = ((X^T)Y)
- Final = (((X^T)X)^-1)((X^T)Y)
- Type
- --------------------------
- X : ndarray, shape(m_number, n_features)
- Y : ndarray, shape(m_number, )
- """
- return np.dot(np.linalg.inv(np.dot(X.T, X)), np.dot(X.T, Y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement