Sha256: 7c029f8968bd7c04a338b59d8facd15cfa7b400101fb98c780449e24709dc241
Contents?: true
Size: 693 Bytes
Versions: 2
Compression:
Stored size: 693 Bytes
Contents
require_relative '../../lib/everyday-cli-utils/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 nmeans.count.should eq 3 nmeans.should 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) nmeans.count.should eq 5 nmeans = arr.nmeans(3) nmeans.count.should eq 3 end it 'finds outliers in simple data' do arr = [100, 200, 99, 400, 98, 201, 101, 405, 102] outliers = arr.outliers outliers.should eq [400.0, 405.0] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
everyday-cli-utils-0.1.0 | spec/everyday-cli-utils/kmeans_spec.rb |
everyday-cli-utils-0.0.2 | spec/everyday-cli-utils/kmeans_spec.rb |