Sha256: 8aea52d9a5180339a3b12cfbf7013ad936060fbdf1a16d854da3b96e4b6cb2ed
Contents?: true
Size: 746 Bytes
Versions: 7
Compression:
Stored size: 746 Bytes
Contents
require_relative '../../lib/everyday-cli-utils' include EverydayCliUtils import :kmeans describe EverydayCliUtils::Kmeans do it 'finds the right clusters in simple data' do arr = [100, 200, 99, 400, 98, 201, 101, 405, 102] nmeans = arr.nmeans expect(nmeans.count).to eq 3 expect(nmeans).to eq [100, 200.5, 402.5] end it 'limits number of clusters found' do arr = (1..50).to_a.map { |v| (v * (101-v)) ** 2 } nmeans = arr.nmeans(5) expect(nmeans.count).to eq 5 nmeans = arr.nmeans(3) expect(nmeans.count).to eq 3 end it 'finds outliers in simple data' do arr = [100, 200, 99, 400, 98, 201, 101, 405, 102] outliers = arr.outliers expect(outliers).to eq [400.0, 405.0] end end
Version data entries
7 entries across 7 versions & 1 rubygems