Sha256: 7cbd80a76fa581d1b48e8c7438a909cb9db32e3f4ed36a77cd600f575c12f074
Contents?: true
Size: 726 Bytes
Versions: 22
Compression:
Stored size: 726 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 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
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
everyday-cli-utils-0.4.0 | spec/everyday-cli-utils/kmeans_spec.rb |
everyday-cli-utils-0.3.0 | spec/everyday-cli-utils/kmeans_spec.rb |