sklearn.utils.random.sample_without_replacement

sklearn.utils.random.sample_without_replacement()

采样整数而不进行替换。

从集合[0,n个总体]中选择n个样本整数,不进行替换。

参数 说明
n_population int,
样本集的大小。
n_samples int,
要采样的整数。
random_state int, RandomState instance or None, optional (default=None)
如果为int,则random_state是随机数生成器使用的种子;否则为false。 如果是RandomState实例,则random_state是随机数生成器; 如果为None,则随机数生成器是np.random使用的RandomState实例。
method “auto”, “tracking_selection”, “reservoir_sampling” or “pool”
如果method 为“ auto”,则使用n_samples / n_population的比率来确定要使用的算法:如果比率在0到0.01之间,则使用跟踪选择。 如果比率在0.01到0.99之间,则使用numpy.random.permutation。 如果比率大于0.99,则使用储层采样。 所选整数的顺序不确定。 如果需要随机顺序,则应将选定的子集混洗。
如果方法为“ tracking_selection”,则使用基于集合的实现,适用于n_samples <<< n_population。
如果方法为“ reservoir_sampling”,则使用适合于高内存约束或当O(n_samples)〜O(n_population)时使用的存储库采样算法。 所选整数的顺序不确定。 如果需要随机顺序,则应将选定的子集混洗。
如果method为“ pool”,则基于池的算法特别快,甚至比跟踪选择方法快。 但是,必须初始化包含整个总体的向量。 如果n_samples〜n_population,则储层采样方法更快。
返回值 说明
out array of size (n_samples, )
整数的采样子集。 所选整数的子集可能不会被随机化,请参见method参数。