Skip to content
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

AutoARMA Algorithm for SyntheticHistory ROM #2309

Merged
merged 12 commits into from
May 13, 2024

Conversation

GabrielSoto-INL
Copy link
Collaborator

@GabrielSoto-INL GabrielSoto-INL commented Apr 23, 2024


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

#2307 #2308

What are the significant changes in functionality due to this change request?

This is a re-do of PR #2176

  • Adds an autoARMA algorithm to the list of TSA algorithms. This algorithm can only be used for global signals if we are using clustered ROMs.

Changes to the ARMA algorithm:

  • Allows the ARMA algorithm to receive trained parameters from the autoARMA algorithm.
  • Switches input name from SignalLag and NoiseLag back to P and Q for the ARMA algorithm
  • P and Q inputs now can also accept an Integer List with size equal to the number of targets (can still accept a single value as before)

For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

@GabrielSoto-INL GabrielSoto-INL marked this pull request as ready for review April 24, 2024 14:47
@moosebuild
Copy link

Job Test qsubs sawtooth on 1eb419e : invalidated by @joshua-cogliati-inl

restarted civet

fixes diff issue between Linux and Windows
"""
Determines the charactistics of the signal based on this algorithm.
@ In, signal, np.ndarray, time series with dims [time, target]
@ In, pivot, np.1darray, time-like parameter values
@ In, targets, list(str), names of targets in same order as signal
@ In, settings, dict, settings for this ROM
@ In, trainedParams, dict, running dict of trained algorithm params
@ Out, params, dict, characteristic parameters
"""
# lazy import statsmodels
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the fit function was called several times should we import each time? I am a little against having the import here. I know that this is not added by you, but do you think we'd better move it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python will only import it the first time, and after that the import is cached. imports inside of function means that the import only happens when the function is called, which can speed up RAVEN since otherwise the import needs to happen at the start of RAVEN even if statsmodels is never used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Josh. I am saying this to make you aware of it, as I have been directed not to do that before, but if you are aware of it, I am totally OK.

@ Out, segmentData, dict
"""
#
segmentNonFeatures = {}
Copy link
Collaborator

@Jimmy-INL Jimmy-INL May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to write a comment in line 326?

@@ -189,7 +189,7 @@ def train(self, tdict, metric=None):

## Check if a label feature is provided by the user and in the training data
if self.labelFeature in tdict:
self.labelValues = tidct[self.labelFeature]
self.labelValues = tdict[self.labelFeature]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this working? Did this if statement never get true in all the tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like the statement was not being hit in the tests, I stumbled upon that typo by chance

Copy link
Collaborator

@Jimmy-INL Jimmy-INL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GabrielSoto-INL, so far I have no issues with this PR, I will debug it locally and finalyze it. But one thing I noticed, ARMA doesn't have an xsd schema. Please refer to ./developer_tools/validate_xml.sh and validate_xml.py

<arma target="signal0, signal1" auto_select="True" seed='42'>
<P>1</P> <!-- NOTE: because `auto-select` is True, these are ignored -->
<Q>0</Q> <!-- NOTE: because `auto-select` is True, these are ignored -->
</arma>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest instead of ignoring the user-provided P and Q, if auto_select = "True", either to error out or to consider them as P_upper, or lower, and the same for Q.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P_upper and Q_upper are already used in the autoarma algorithm, so I think maybe I'll just have it error out if the user provides P and Q here when auto-select is True

regression; typically represented as $Q$ in literature."""))
specs.addParam('auto_select', param_type=InputTypes.BoolType, required=False,
descr=r""" """, default=False)
specs.addSub(InputData.parameterInputFactory('P', contentType=InputTypes.IntegerListType,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the description of auto_select? desc=r""" """

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I missed that!

@Jimmy-INL Jimmy-INL self-requested a review May 13, 2024 15:31
@Jimmy-INL Jimmy-INL merged commit 579eb05 into idaholab:devel May 13, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants