Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from sklearn.linear_model import LinearRegression
- def exponentialRegression(closing):
- x = np.arange(1,len(closing) + 1).reshape((-1, 1))
- y_normalized = np.divide(closing, closing[0])
- y_ln = np.log(y_normalized)
- model = LinearRegression()
- model.fit(x, y_ln)
- scalar = np.exp(model.intercept_) * closing[0]
- base = np.power(np.exp(model.coef_)[0], 252)
- rSquared = model.score(x, y_ln)
- return {
- "scalar": scalar,
- "roi": ((base - 1) * 100),
- "r2": rSquared
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement