sample_with_bias#
- obsidian.experiment.sampling.sample_with_bias(df, n, replace=False, seed=None, bias=None, enforce=False, plot_weights=False)[source]#
Returns a random Pandas DataFrame sample of data points from a population with or without bias.
df: DataFrame of candidates n: int, size of the design to pick replace: boolean, allow or disallow sampling from the same row more than once, default False bias: dictionary of biases in the format : {“column”: [lower_bound, upper_bound, relative_weight]}, default None
Weight >1 increases sampling probability for in-range rows.
Weight <1 decreases it.
Weight = 0 excludes those rows entirely.
enforce: boolean, whether to force biases, default False plot_weights: boolean, whether to plot distribution of weights, default False
Returns: Pandas DataFrame of sampled data points.