INNER CODE UNIT · Ruby
sz_cluster
yoshoku/rumale · rumale-core/lib/rumale/dataset.rb:156
sz_cluster = [n_samples / n_centers] * n_centers
(n_samples % n_centers).times { |n| sz_cluster[n] += 1 }
x = ::Rumale::Utils.rand_normal([sz_cluster[0], n_features], rng, 0.0, cluster_std) + centers[0, true]
y = Numo::Int32.zeros(sz_cluster[0])
(1...n_centers).each do |n|
c = ::Rumale::Utils.rand_normal([sz_cluster[n], n_features], rng, 0.0, cluster_std) + centers[n, true]
x = Numo::DFloat.vstack([x, c])
y = y.concatenate(Numo::Int32.zeros(sz_cluster[n]) + n)
end
# shuffle data.
if shuffle
rand_ids = Array(0...n_samples).shuffle(random: rng.dup)
x = x[rand_ids, true].dup
y = y[rand_ids].dup
end
[x, y]
end