smash.Samples.slice#
- Samples.slice(end, start=0)[source]#
Slice the Samples object.
The attribute arrays are sliced along a user-specified start and end index.
- Parameters:
- endint
The end index of the slice.
- startint, default 0
The start index of the slice. Must be lower than end.
- Returns:
- slice
Samples
The Samples object sliced according to start and end arguments.
- slice
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) >>> sample.to_dataframe() cp llr 0 83.987379 47.076959 1 144.344574 93.943845 2 1.022761 173.434803 3 61.164182 198.986970 4 30.204422 269.869550
Slice the first two sets
>>> sample_slice = sample.slice(2) >>> sample_slice.to_dataframe() cp llr 0 83.987379 47.076959 1 144.344574 93.943845
Slice between start and end indexes
>>> sample_slice = sample.slice(start=3, end=5) >>> sample_slice.to_dataframe() cp llr 0 61.164182 198.98697 1 30.204422 269.86955