-
- Notifications
You must be signed in to change notification settings - Fork 48.6k
Added ARIMA #13444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Added ARIMA #13444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| ||
| ||
class ARIMA: | ||
def __init__(self, p=1, d=1, q=1, lr=0.001, epochs=1000) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide type hint for the parameter: p
Please provide descriptive name for the parameter: p
Please provide type hint for the parameter: d
Please provide descriptive name for the parameter: d
Please provide type hint for the parameter: q
Please provide descriptive name for the parameter: q
Please provide type hint for the parameter: lr
Please provide type hint for the parameter: epochs
self.n_train: int | None = None | ||
self.sigma_err: float | None = None | ||
| ||
def difference(self, data) -> NDArray[np.float64]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function difference
Please provide type hint for the parameter: data
diff = np.diff(diff) # np.diff is a handy function that does exactly this. | ||
return diff | ||
| ||
def inverse_difference( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function inverse_difference
prev = next_val | ||
return forecast | ||
| ||
def _compute_residuals( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function _compute_residuals
diff_data: NDArray[np.float64], | ||
phi: NDArray[np.float64], | ||
theta: NDArray[np.float64], | ||
c: float, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: c
| ||
return preds, errors | ||
| ||
def fit(self, data: list[float] | NDArray[np.float64]) -> "ARIMA": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function fit
self.n_train = len(diff_data) # Assign n_train as an integer | ||
return self | ||
| ||
def _fit_gradient_descent(self, diff_data: NDArray[np.float64], start: int) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function _fit_gradient_descent
msg = f"Fitted params (GD): phi={self.phi},theta={self.theta},c={self.c:.6f}\n" | ||
print(msg) | ||
| ||
def forecast( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/arima.py
, please provide doctest for the function forecast
Describe your change:
Added the ARIMA Algorithm.
Checklist: