smash.Samples.to_numpy#
- Samples.to_numpy(axis=0)[source]#
Convert the Samples object to a
numpy.ndarray
.The attribute arrays are stacked along a user-specified axis of the resulting array.
- Parameters:
- axisint, default 0
The axis along which the generated samples of each rainfall-runoff parameter and/or initial state will be joined.
- Returns:
- res
numpy.ndarray
It returns the
Samples
object as anumpy.ndarray
.
- res
Examples
>>> from smash.factory import generate_samples >>> problem = {"num_vars": 2, "names": ["cp", "llr"], "bounds": [[1, 200], [1, 500]]}
Generate samples
>>> sample = generate_samples(problem, n=5, random_state=1)
Convert the result to a
numpy.ndarray
>>> sample.to_numpy(axis=-1) array([[ 83.98737894, 47.07695879], [144.34457419, 93.94384548], [ 1.02276059, 173.43480279], [ 61.16418195, 198.98696964], [ 30.20442227, 269.86955027]])