-
Notifications
You must be signed in to change notification settings - Fork 133
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
Multi-Resolution Time Series Analysis #2345
base: devel
Are you sure you want to change the base?
Multi-Resolution Time Series Analysis #2345
Conversation
Job Mingw Test on c2e8911 : invalidated by @GabrielSoto-INL Segmentation fault when activating raven_libraries, trying again? |
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.
Looks good to me, just a couple small comments.
def __init__(self): | ||
""" | ||
Constructor. | ||
@ In, kwargs, dict, initialization options |
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.
Method has no **kwargs
argument.
self._levels = settings['levels'] - 1 | ||
return settings | ||
|
||
def fit(self, signal, pivot, targets, settings, trainedParams=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.
Add trainedParams
to docstring
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.
good catch, found some other algos for which I forgot to add that docstring
@ In, settings, dict, additional settings specific to algorithm | ||
@ Out, residual, np.array, reduced signal shaped [pivotValues, targets] | ||
""" | ||
residual = np.zeros(initial.shape) |
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.
Would it be better to copy the initial
array instead of creating an array of zeros? That way any values in targets not in initial
are passed through.
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.
good point
plugins/HERON
Outdated
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.
Is this intentional?
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.
it... was not. a little unsure what's happening, on my local it says they're at the same commit as the plugins in the RAVEN repo... I'll dig in to it a little more.
@ In, skip, list, optional, unused (kept for compatability) | ||
@ Out, 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.
Is this function completely empty? even not an empty return or pass? Is it an abstract one that has to be there?
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.
I missed the return
statement. this one is empty for now, need to find an efficient way to print out XML meta
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.
I actually found an easy way of reporting back info, this method is now filled in!
plugins/TEAL
Outdated
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.
Same here?
@ In, pivot, np.1darray, time-like parameter values | ||
@ In, targets, list(str), names of targets in same order as signal | ||
@ In, settings, dict, additional settings specific to this algorithm | ||
@ Out, params, dict, characteristic parameters |
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.
@ In, trainedParams,...
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.
fixed!
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.
Some comments for you to consider, in addition, please fix the submodule issue also. @GabrielSoto-INL
self._globalROM = SyntheticHistory() | ||
self._decompParams = {} | ||
self.decompositionAlgorithm = 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.
It is better to provide some descriptions for the self
variables.
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.
fixed, actually realized I wasn't using _decompParams so it helped clean up the code!
""" | ||
super()._handleInput(paramInput) | ||
self._globalROM._handleInput(paramInput) | ||
self._dynamicHandling = True # This ROM is able to manage the time-series on its own. |
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.
I think this should be moved to init method.
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.
fixed
|
||
def __evaluateLocal__(self, featureVals): | ||
""" | ||
Evaluate algorithms for ROM generation |
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.
two extra spaces for this line.
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.
fixed, good catch!
### ESSENTIALLY UNUSED ### | ||
def _localNormalizeData(self,values,names,feat): | ||
""" | ||
Overwrites default normalization procedure, since we do not desire normalization in this implementation. | ||
@ In, values, unused | ||
@ In, names, unused | ||
@ In, feat, feature to normalize | ||
@ Out, None | ||
""" | ||
self.muAndSigmaFeatures[feat] = (0.0,1.0) | ||
|
||
def __confidenceLocal__(self,featureVals): | ||
""" | ||
This method is currently not needed for ARMA | ||
""" | ||
pass | ||
|
||
def __resetLocal__(self,featureVals): | ||
""" | ||
After this method the ROM should be described only by the initial parameter settings | ||
Currently not implemented for ARMA | ||
""" | ||
pass | ||
|
||
def __returnInitialParametersLocal__(self): | ||
""" | ||
there are no possible default parameters to report | ||
""" | ||
localInitParam = {} | ||
return localInitParam | ||
|
||
def __returnCurrentSettingLocal__(self): | ||
""" | ||
override this method to pass the set of parameters of the ROM that can change during simulation | ||
Currently not implemented for ARMA | ||
""" | ||
pass |
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.
Do you need to keep these methods? I assume they are also defined in the base class.
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.
it seems we didn't need _localNormalizeData
but the others are abstract methods in SupervisedLearning
so they need to be defined here
# dummy methods that are required by SVL and not generally used | ||
def __confidenceLocal__(self, featureVals): | ||
""" | ||
This should return an estimation of the quality of the prediction. | ||
This could be distance or probability or anything else, the type needs to be declared in the variable cls.qualityEstType | ||
@ In, featureVals, 2-D numpy array , [n_samples,n_features] | ||
@ Out, __confidenceLocal__, float, the confidence | ||
""" | ||
pass | ||
|
||
def __resetLocal__(self): | ||
""" | ||
Reset ROM. After this method the ROM should be described only by the initial parameter settings | ||
@ In, None | ||
@ Out, None | ||
""" | ||
pass | ||
|
||
def __returnCurrentSettingLocal__(self): | ||
""" | ||
Returns a dictionary with the parameters and their current values | ||
@ In, None | ||
@ Out, params, dict, dictionary of parameter names and current values | ||
""" | ||
return {} | ||
|
||
def __returnInitialParametersLocal__(self): | ||
""" | ||
Returns a dictionary with the parameters and their initial values | ||
@ In, None | ||
@ Out, params, dict, dictionary of parameter names and initial values | ||
""" | ||
return {} |
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.
Are these methods required?
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.
same as above^ these are abstract methods in the base class
""" | ||
# general infrastructure | ||
super().__init__(*args, **kwargs) | ||
self._levels = 1 |
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.
provide descriptions for self variables
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.
fixed
# determine maximum decomposition level | ||
max_level = pywt.dwt_max_level(len(pivot), family) | ||
if self._levels>max_level: | ||
print(f"Number of levels requested is larger than maximum DWT decomposition level, switching to maximum allowed: {max_level}") |
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 use message handler to raise messages.
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.
it looks like the base classes for the TSA algorithms do not inherit Message Handler at the moment. this may be a subject of future discussion?
<created>2021-01-08</created> | ||
<classesTested>SupervisedLearning.SyntheticHistory,TSA.Fourier</classesTested> | ||
<description> | ||
Tests the SyntheticHistory ROM using only the Fourier TimeSeriesAnalyzer algorithm. |
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.
I would suggest to add descriptions to reflect multi-resolution TSA
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.
fixed
<created>2021-01-08</created> | ||
<classesTested>SupervisedLearning.MultiResolutionTSA,TSA.FilterBankDWT</classesTested> | ||
<description> | ||
Tests the SyntheticHistory ROM using only the Fourier TimeSeriesAnalyzer algorithm. |
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.
I would suggest to add descriptions to reflect multi-resolution TSA
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.
fixed
@@ -0,0 +1,4001 @@ | |||
RAVEN_sample_ID,seconds,macro,scaling,signal0,PointProbability,prefix,ProbabilityWeight |
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.
Is it possible to reduce the size of this file? In addition, you do not need ProbabilityWeight, PointProbability in your output.
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.
I can reduce the number of levels requested per year and regold.
I'm unsure how to get rid of ProbabilityWeight and PointProbability.. I don't request those in the raven input XML, I wonder if they're there automatically because there are multiple target signals?
Job Test Ubuntu 18 PIP on 48c5e1b : invalidated by @GabrielSoto-INL |
Pull Request Description
What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)
#2128
What are the significant changes in functionality due to this change request?
Replaces #2129 .
New changes include introduction of multi-resolution time series analysis capabilities to RAVEN, particularly incorporated within the
ROMCollection
,SyntheticHistory
andTSA
module infrastructure. Multiresolution (MR) time series analysis algorithms are capable of investigating the inherent dynamics of time series at multiple timescales or frequencies. Decomposition of time series at multiple levels is a typical MR algorithm. These changes add the capability of decomposing time series signal(s) at different levels via a MR algorithm while still leveraging characterization, additional transformation, and generative algorithms within the currentTSA
library.A new algorithm was added to the
TSA
module which is a modified wavelet transform:FilterBankDWT
. This algorithm (and more in the future) will be compatible with a newMultiResolutionTSA
ROM subtype and aDecomposition
ROMCollection subtype. An example input script is shown below to help walk through the new additions:MultiResolutionTSA
has been added.SupervisedLearning
ROM class._interfaceROM
(for example, when using the standard TSA module, the_interfaceROM
is theSyntheticHistory
class).FilterBankDWT
, using thePyWavelets
python package, uses a filter bank discrete wavelet transform to decompose the original signal into various levels.TSA
algorithms can be used to modify or learn characteristics of the signal prior to this algorithm being used.ROMCollection
architecture is aDecomposition
class which inherits theSupervisedLearning
ROM class._segmentROM
(for example, previous instances useSegment
,Clusters
, orInterpolated
classes).SyntheticHistory
object. Any algorithms within the<Segment>
node of this input will be applied to each decomposition level (e.g., here, an ARMA model is trained per decomposition level).Other notes:
\tests
subdirectory.For Change Control Board: Change Request Review
The following review must be completed by an authorized member of the Change Control Board.
<internalParallel>
to True.raven/tests/framework/user_guide
andraven/docs/workshop
) have been changed, the associated documentation must be reviewed and assured the text matches the example.