File: plot_visualize_input_output_sample.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (38 lines) | stat: -rw-r--r-- 1,296 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Visualize pairs between two samples
===================================
"""

# %%
# In this example we visualize the relationships between the marginal samples of two given samples.
# This is usual when we analyze the relationship of output sample of a model depending on input sample.
# This can be achieved by plotting the outputs versus the inputs.
# When there are several inputs (which is the most often encountered case) and several outputs (which is less often).
# The :meth:`~openturns.VisualTest.DrawPairsXY` method provides a tool to plot the pairs of input and output marginal samples and see the correlations graphically.

# %%
import openturns as ot
import openturns.viewer as otv


# %%
# Create the model
model = ot.SymbolicFunction(
    ["X0", "X1", "X2"],
    ["1.0 + 2.0 * X0 - 1.0 * X1 + 4.0 * X2", "-2.0 - 3.0 * X0 + 5.0 * X1 - 1.0 * X2"],
)

# %%
# Create the input data to visualize
distribution = ot.Normal(3)
distribution.setDescription(model.getInputDescription())
input_sample = distribution.getSample(100)

# %% Create the output data to visualize
output_sample = model(input_sample)

# %% Visualize the data
graph = ot.VisualTest.DrawPairsXY(input_sample, output_sample)
graph.setTitle("Clouds of input / output samples")
view = otv.View(graph)
otv.View.ShowAll()