Repository navigation
ENH: improved of the ProcessMLE(loglike, score) class 16 times faster - #9264
Closed
quant12345 wants to merge 7 commits into
Closed
quant12345 wants to merge 7 commits into
quant12345 wants to merge 7 commits into
Conversation
loglike, score from class: ProcessMLE. Added methods jac_all (calculate all rows at once), added an option to get_cov (calculate all rows at once) and similar_code (same operations).
Contributor
Author
|
In LinuxTest python_312_pre -> Run tests (pip pre) I think the problem is here (from the documentation): Asked in numpy. The problem with numpy version --- 2.1.0.dev0 is solved. after: |
Removing a long line
|
Hello @quant12345! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-06-04 14:56:43 UTC |
Changes for np.linalg.solve in new numpy versions. Trying to remove trailing spaces.
code formatting
# Conflicts: # statsmodels/regression/process_regression.py
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NumPy's guide.
This PR reduces the calculation time of methods:
loglike,scorefrom the class:ProcessMLE. Speedup oftest_formulasis 16 times on average. To achieve this performance eliminated loops in which the methods are called:get_cov,jacfrom theGaussianCovarianceclass(these methods are also optimized).The main idea is this: take the
indindexes that were used in the loop and select the necessary elements using np.take. And usingnp.newaxisdo the calculation for each line.I added thejac_allmethod because thejacmethod is big enough and what I did inget_covwith theif time.ndim == 1check: would make it even bigger.To reduce the number of operations of the same type, a method has been added:
similar_code.There was a bug in:
LinuxTest python_312_pre, which has been fixed (see comment).Test times before and after.
before:
after:
What are the community's thoughts?
To compare performance, I created a separate
process_regression_file, which I have included in the attachment. It calls ProcessMLE_new and ProcessMLE for comparison. Placeprocess_regression_in the main directory and use the following code to test:test_processreg
Also in the attachment is the folder:
processreg_comparisonwith which you canrun the old and new versions and compare their values for equality (values are rounded to the fifth character after the point).process_regression_.zip
processreg_comparison.tar.gz
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels.