-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bayesian analysis for calibration of input parameters #88
Comments
@WPringle based on the discussion we had today, we only need to run best track for a couple of storms and with a couple of different ensemble sizes with Korobov sampling right? |
@SorooshMani-NOAA because it is best track we should change how we do the ensemble perturbation. I think we need to work out that strategy first, then we do ensemble then check that the ensemble results encompass the observations. This paper is relevant which also look at best track: See section 4.2. In there they treat the errors as uniform random variables with some amplification factor which we can tune. I think we should follow their methodology for doing the track and intensity perturbations. |
@SorooshMani-NOAA You can see they also perturb manning's roughness too. |
Just for the sake of completeness of this discussion: Later we'll explore other parameter perturbations. |
@WPringle have you tried running KL-NN code on the sample data? During our meeting (and also in the slides) it says the data is time dependent. But looking at the I haven't tried running it yet. I was just reviewing the slides and the code. |
I did run the code using the sample data and the plots on the slides are the result of that execution. I wouldn't worry about whether it is "x" or "t", it is somewhat arbitrary and methodology can handle spatiotemporal in theory. But I am pretty sure "x" is referring to a time dimension here based on how it looks |
I see, thank you |
@WPringle I forgot to also ask, have you tried it on an ensemble too? Was there any issue I need to be aware of if I want to run this on combine maxelev ensemble dataset? |
No I did not. Just be aware of the dimensions of the data, number of parameters, number of nodes, and number of ensembles and how that fits into that code. It should be able to run through to the part where it requires the observations |
OK, thank you |
@WPringle I'm testing the KLNN (without MCMC part) on the same ensemble I used with your KLPC. I actually subsetted the maxelev dataset using your subsetting part of the KLPC script (from EnsemblePerturbation/ensembleperturbation/uncertainty_quantification/karhunen_loeve_expansion.py Line 39 in 33141b8
Out of curiosity, is there any reason behind using KLE/PCA for reducing dimensions? Why not use other methods? |
Yes, please use the PCA method we use in What other methods are there? For the KLPC we have an analytical solution to convert the KL fit surrogate back to the full-dimension surrogate, which is at least one advantage I can think of... |
OK thanks!
I was talking in general, I know there are a bunch of dimension reduction techniques which might be better than PCA based certain ways/applications; so I was wondering if there's any specific reason. e.g.: https://towardsdatascience.com/11-dimensionality-reduction-techniques-you-should-know-in-2021-dcb9500d388b
I see, I didn't really think about this part. It would still be interesting to see what other methods have to offer if we get the chance to explore |
yeah that's interesting! For sure explore them if you want to, we can have a meeting with Khachik sometime to discuss this, he might be able to say why we would prefer one type of method over another. |
Copying the email for future reference:
|
I tried using the |
@SorooshMani-NOAA Could you please share the code you have so far for the results we looked at yesterday with Khachik? |
@WPringle I uploaded the code on a private repo for now. I just added you and Saeed as collaborator. Note that the code must run on an already subsetted dataset. I tried to get it to work with minimum changes possible. |
@WPringle if I want to train on the whole model but only MCMC on the USGS HWM stations, what should the non-station dimension value be when transforming observations using PCA? Should it be 0? |
@SorooshMani-NOAA That's a good question. I suppose 0 makes sense because in the matrix multiplication zeros will add nothing. Or if it doesn't work then we need to probably do the MCMC on the full result, rather than the dimensionally reduced result. First let's try zero and see... Just to be clear, you are asking about what dummy value to put in |
@WPringle, sorry for late reply. Yes that's what I meant. I'll try and see how it goes |
Next
|
The result is not good for sure, but this time there seems to be a method to this madness! I mean there seems to be a bias involved here in the MCMC errorbar results. Still not sure how to interpret it, what do you think @WPringle ? Also please let me know how to share the Updated sizes |
I guess the bias mostly comes from the fact that model results are generally under predicted. But it's a bit weird we would think the MAP crosses should be closest to the observations, instead they are lower down on the error bars. |
@SorooshMani-NOAA I think we can use this function to transfer Gaussian to uniform https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr This will give you values of [0,1] then can rescale it to [-1,1] by multiply by 2 then subtract 1. |
@SorooshMani-NOAA I put my jupyter notebook and some modifications to |
@SorooshMani-NOAA Also check out https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html for trying to figure out best hyperparameters for the ANN model (used by this paper: https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2022JD037617) |
@WPringle I think we missed one point during our discussion about Physical vs KL space: When using Polynomial Chaos and we're in physical space, it's clear what is the input to the physical surrogate, but for the NN case, even if MCMC takes care of transforming back to physical, still we don't know what to pass to the NN in the first place. NN only accepts KL space input, so we still run into the same issue of transforming data from observation-points-only to KL space, to then pass it to NN. So we should find a way to "transform" the neural network to accept physical inputs. Does that make sense? |
No I think it is the same because the “input” to the surrogate is just the value of the set of parameters while the length of the surrogate is either the number of eigenmodes or number of physical nodes depending on if in KL space of physics space. Of course we need to also provide the observed data and the corresponding indices in the physical surrogate that map to the data.
…________________________________
From: Soroosh Mani ***@***.***>
Sent: Tuesday, January 31, 2023 12:39:44 PM
To: noaa-ocs-modeling/EnsemblePerturbation ***@***.***>
Cc: Pringle, William ***@***.***>; Mention ***@***.***>
Subject: Re: [noaa-ocs-modeling/EnsemblePerturbation] Bayesian analysis for calibration of input parameters (Issue #88)
@WPringle<https://github.com/WPringle> I think we missed one point during our discussion about Physical vs KL space:
When using Polynomial Chaos and we're in physical space, it's clear what is the input to the physical surrogate, but for the NN case, even if MCMC takes care of transforming back to physical, still we don't know what to pass to the NN in the first place.
NN only accepts KL space input, so we still run into the same issue of transforming data from observation-points-only to KL space, to then pass it to NN. So we should find a way to "transform" the neural network to accept physical inputs. Does that make sense?
—
Reply to this email directly, view it on GitHub<#88 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBHFHQL4EPL6RIG7KRZURTWVFL7BANCNFSM6AAAAAAQLUYNOU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Oh I see my mistake ... thanks! I'll just need to Apart from that, I'm not sure if I use cross validation term correctly. Based on the description here https://scikit-learn.org/stable/modules/grid_search.html, this term is used for hyperparameter tuning (e.g. number of hidden layers or neurons in case of NN) and not model parameter selection. What we're doing really is looking at train/test for tuning parameters. In the case of PC model, the existing code has: cross_validator = LeaveOneOut()
regression_model = ElasticNetCV(
fit_intercept=False,
cv=cross_validator,
l1_ratio=0.5,
selection='random',
random_state=666,
) based on https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNetCV.html my understanding is that cross validation is actually not used here, since |
Yep so it still is doing the CV for the |
Oh, yeah I missed it. In any case, what I'm trying to say is that unless we want to really find a good # of neurons or layers, CV approach might not make much sense for NN and we can do just the internal validation it already has for choosing parameters |
@SorooshMani-NOAA hmm I don't know about that. Maybe those CV functions aren't appropriate but I think it's important to do CV so we reduce the over training problem. |
There seems to be other methods to avoid overfitting, e.g.: And this is the observation vs ensemble (with dry node extrapolation): Also the results from SCHISM ensemble also improved by using physical-space-surrogate: |
Action items as of 2/21/23 meeting: Soroosh:
William:
What do we need for finalizing/publishing?
|
@SorooshMani-NOAA See these scripts and best_track and advisory files here for Florence: The |
Plumlee et al. - 2021 - High-fidelity hurricane surge forecasting using em.pdf |
Todo list:
William:
|
@WPringle when I download data for all the past storms from
What do you think of this approach? |
That sounds good to me @SorooshMani-NOAA. What do you mean by only two |
If I get the tracks using: tracks = stormevents.nhc.track.VortexTrack.from_storm_name('florence', 2018, file_deck='a') then this would be the result of
There's an |
yeah maybe that is being parsed incorrectly or the column in ALCF meant something else |
@WPringle following our discussion about getting forecast track this is where I am:
After this I still get a wrong central pressure and r-max for some of the entries; for example, this is one such output (before I set forecast hours to 0) for Florence 2018:
for reference, this is part of an actual best track from a previous successfully run ensemble:
I'm still investigating what is actually causing the error in SCHISM, but is there anything that you see in the above example? I'm assuming the wrong pressures would maybe sufficient to throw the simulation off! When you get a change, can you please review the correction done to the OFCL using CARQ here and see if it makes sense? Maybe we should review the UPDATE I just saw the issue in the logs of SCHISM from PAHM:
|
@SorooshMani-NOAA This looks very promising, nice job! In my methodology the initial Rmax, maybe this is from CARQ, is assumed for all forecast times in the advisory. |
@SorooshMani-NOAA This is one of big reasons why the Rmax methodology sucks because we although have a lot of information of Vmax and r34, r50, r64 we have no estimate of Rmax in the future. So better off to use r34, r50, r64 in a GAHM implementation |
@WPringle, thanks. Do you have any suggestion for how to resolve this issue based on what we get above? I looked at the CARQ for the same |
@SorooshMani-NOAA Do you get Rmax in the CARQ? I think I remember now that actually for the pressure at the 0-hr I used the pressure from the 3-hr in the previous advisory (3 hours prior). If that is too complicated then we can fill in 0-hr using same methodology as the forecast times. |
@WPringle I believe that should be what's happening. I'm just using I can manually modify some of the values in my workflow script to try different things., e.g. I can try setting it to 3-hr forecast pressure. Do you want us to change the logic in the |
Interesting ... I just noticed this in my dataframe, looking only at certain columns:
I think the logic in StormEvents gets the first entry meaning |
@SorooshMani-NOAA yes, what you just showed sounds good if that can be corrected |
@WPringle I just realized that in the original unprocessed ATCF files, the pressure fields are not Update
Update 2 The correction is calculated, but never stored. |
There's a package called
PyMC3
that can be used for Bayesian analysis.There's a good "hacker book" available at: https://nbviewer.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Prologue/Prologue.ipynb
Initial discussion:
The text was updated successfully, but these errors were encountered: