Comments (2)
Yes, the toolbox is usable with multiple model outputs. However, it does unfortunately not have direct support for this, you have to use a small trick. Uncertainpy by default only performs an uncertainty quantification of the first model output returned. But you can return the additional model outputs in the info dictionary, and then define new features that extract each model output from the info dictionary, and then returns the additional model output.
Here is an example that shows how to do this:
import uncertainpy as un
import chaospy as cp
# Example model with multiple outputs
def example_model(parameter_1, parameter_2):
# Perform all model calculations here
time = ...
model_output_1 = ...
model_output_2 = ...
model_output_3 = ...
# We can store the additional model outputs in an info
# dictionary
info = {"model_output_2": model_output_2,
"model_output_3": model_output_3}
# Return time, model output and info dictionary
# The first model output (model_output_1) is automatically used in the
# uncertainty quantification
return time, model_output_1, info
We can perform an uncertainty quantification of the other model outputs by creating a feature for each of the additional model outputs by extracting the output from the info dictionary and then return the output:
def model_output_2(time, model_output_1, info):
return time, info["model_output_2"]
def model_output_3(time, model_output_1, info):
return time, info["model_output_3"]
feature_list = [model_output_2, model_output_3]
# Define the parameter dictionary
parameters = {"parameter_1": cp.Uniform(),
"parameter_2": cp.Uniform()}
# Set up the uncertainty quantification
UQ = un.UncertaintyQuantification(model=example_model,
parameters=parameters,
features=feature_list)
# Perform the uncertainty quantification using
# polynomial chaos with point collocation (by default)
data = UQ.quantify()
Alternatively, we can directly return all model outputs, but you are then unable to use the built.in features in Uncertainpy.
# Example model with multiple outputs
def example_model(parameter_1, parameter_2):
# Perform all model calculations here
time = ...
model_output_1 = ...
model_output_2 = ...
model_output_3 = ...
# Return time, model output and info dictionary
# The first model output (model_output_1) is automatically used in the
# uncertainty quantification
return time, model_output_1, model_output_2, model_output_3
# We can perform an uncertainty quantification of the other model
# outputs by creating a feature for each of the additional
# model outputs by extracting the output from the info dictionary and
# then return the output
def model_output_2(time, model_output_1, model_output_2, model_output_3):
return time, model_output_2
def model_output_3(time, model_output_1, model_output_2, model_output_3):
return time, model_output_3
from uncertainpy.
Thanks for the quick response. I will try the workflow in the next days.
from uncertainpy.
Related Issues (20)
- Coffee cup notebook suggestion HOT 1
- Uncertainpy. for coupled differential equations HOT 3
- error: fit_regression() got an unexpected keyword argument 'rule' HOT 1
- Add uncertainpy to Open Neuroscience HOT 1
- Matplotlib dependency HOT 2
- AttributeError: module 'numpoly' has no attribute 'variable for the coffe cup example HOT 1
- Difficult during installation HOT 7
- use bayesian calibration and then apply uncertainpy to do a GSA? HOT 3
- Switch CI provider away from travis
- Univariate effects
- Number of collocation points for PCE
- chaospy.orth_ttr name is to be deprecated; Use chaospy.expansion.stieltjes instead
- Coffe cup example HOT 1
- Parameters class using 'distribution=' parameter results in an error
- Calculation stalls at 'Calculating Statistics from PCE' HOT 2
- Chaospy issue
- UQ.Quantify fails with scipy==1.9.1
- Conflict with firedrake import
- Using Uncertainty Quantification on a Uniform Distribution for Varying Data
- docs/source/features/efel_features.rst documentation needs update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uncertainpy.