k_means_pp 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c559a4b71f8e96d813e46b25c718956c209561e3
4
- data.tar.gz: fbf9650f96cffa2108bc10dbd687bd80318d992a
3
+ metadata.gz: ee4560276d76bfbbd4c0185ce2841dc63d58f691
4
+ data.tar.gz: be6e6af6d42800a6f7f8bf59ab590e8dc7de8318
5
5
  SHA512:
6
- metadata.gz: 33c2ec2d2ace4de6cad7752185fa0f5014a47c1e02b1f56571c75f03d8aa1b32940565ae2d2f10525879a50648f32b29331a8b81d1975567c975533ff44284d1
7
- data.tar.gz: 6e7cb457d33d97f3f7e331978e57781193a039b750c7e683908a536b9fe76670d048f84d6d0191f8a3de24d58d46aad05532d0babbdd3d32d91e5377fe151780
6
+ metadata.gz: b9637a304158454f25592ce2a7e3391a3beeb124c01b36ad140f8c94c6bdbe606318d14a260d795bca3e3983e73d53abd8ef4f5a56ab843cdfd9b32bae5fc6df
7
+ data.tar.gz: 53141d801f3a6ea60124d21b47448e258f4c9c62705601d6f03846009ca692fffed4b81b66c67bd39ceb0759ff9ff556f69881ccb49f6b6ede121527e026d339
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
- /*.gem
2
- /examples/report-*.*
1
+ *.gem
3
2
  /.bundle/
4
3
  /.yardoc
5
4
  /Gemfile.lock
@@ -9,8 +8,4 @@
9
8
  /pkg/
10
9
  /spec/reports/
11
10
  /tmp/
12
- *.bundle
13
- *.so
14
- *.o
15
- *.a
16
- mkmf.log
11
+ /examples/report-*.*
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.2.2
5
+ - 2.1.6
4
6
  - 2.0.0
5
- - 2.1.3
7
+ - 1.9.3
6
8
  - jruby-19mode
7
9
 
8
10
  branches:
@@ -15,4 +17,4 @@ notifications:
15
17
  on_failure: always
16
18
 
17
19
  install: "bundle --jobs 4"
18
- script: bundle exec rspec
20
+ script: "bundle exec rspec"
data/LICENSE.txt CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2014 Oldrich Vetesnik
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2014-2015 Oldrich Vetesnik
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # KMeansPP
2
-
3
- [![Build Status](https://travis-ci.org/ollie/k_means_pp.svg?branch=master)](https://travis-ci.org/ollie/k_means_pp)
1
+ # KMeansPP [![Build Status](https://img.shields.io/travis/ollie/k_means_pp/master.svg)](https://travis-ci.org/ollie/k_means_pp) [![Code Climate](https://img.shields.io/codeclimate/github/ollie/k_means_pp.svg)](https://codeclimate.com/github/ollie/k_means_pp) [![Gem Version](https://img.shields.io/gem/v/k_means_pp.svg)](https://rubygems.org/gems/k_means_pp)
4
2
 
5
3
  ## What's this?
6
4
 
@@ -149,6 +147,12 @@ Or install it yourself as:
149
147
 
150
148
  $ gem install k_means_pp
151
149
 
150
+ ## Development
151
+
152
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
153
+
154
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
155
+
152
156
  ## Contributing
153
157
 
154
158
  1. Fork it (https://github.com/ollie/k_means_pp/fork)
data/Rakefile CHANGED
@@ -11,8 +11,3 @@ desc 'Same as :combo but build a gem, too'
11
11
  task mega_combo: :combo do
12
12
  sh 'gem build k_means_pp.gemspec'
13
13
  end
14
-
15
- desc 'Start a console'
16
- task :console do
17
- sh 'bundle exec pry -I ./lib -r ./lib/k_means_pp.rb'
18
- end
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'k_means_pp'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/k_means_pp.gemspec CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = KMeansPP::VERSION
9
9
  spec.authors = ['Oldrich Vetesnik']
10
10
  spec.email = ['oldrich.vetesnik@gmail.com']
11
+
11
12
  spec.summary = 'K-means++ Algorithm Implementation.'
12
13
  spec.description = 'This is a Ruby implementation of the k-means++ ' \
13
14
  'algorithm for data clustering. In other words: ' \
@@ -15,24 +16,25 @@ Gem::Specification.new do |spec|
15
16
  spec.homepage = 'https://github.com/ollie/k_means_pp'
16
17
  spec.license = 'MIT'
17
18
 
18
- spec.files = `git ls-files -z`.split("\x0")
19
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ # rubocop:disable Metrics/LineLength
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ['lib']
22
24
 
23
25
  # System
24
26
  spec.add_development_dependency 'bundler', '~> 1.7'
25
27
 
26
28
  # Test
27
- spec.add_development_dependency 'rspec', '~> 3.1'
28
- spec.add_development_dependency 'simplecov', '~> 0.9'
29
+ spec.add_development_dependency 'rspec', '~> 3.2'
30
+ spec.add_development_dependency 'simplecov', '~> 0.10'
29
31
 
30
32
  # Code style, debugging, docs
31
- spec.add_development_dependency 'yard', '~> 0.8'
32
- spec.add_development_dependency 'rake', '~> 10.3'
33
- spec.add_development_dependency 'rubocop', '~> 0.26'
33
+ spec.add_development_dependency 'rubocop', '~> 0.31'
34
34
  spec.add_development_dependency 'pry', '~> 0.10'
35
- # spec.add_development_dependency 'pry-byebug', '~> 2.0'
35
+ spec.add_development_dependency 'yard', '~> 0.8'
36
+ spec.add_development_dependency 'rake', '~> 10.4'
37
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
36
38
  # spec.add_development_dependency 'ruby-prof', '~> 0.15'
37
39
  # spec.add_development_dependency 'gnuplot', '~> 2.6'
38
40
  end
@@ -1,4 +1,4 @@
1
1
  class KMeansPP
2
2
  # Version number, happy now?
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_means_pp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oldrich Vetesnik
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,84 +30,84 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.9'
47
+ version: '0.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.9'
54
+ version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: yard
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.8'
61
+ version: '0.31'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.8'
68
+ version: '0.31'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.3'
75
+ version: '0.10'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.3'
82
+ version: '0.10'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop
84
+ name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.26'
89
+ version: '0.8'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.26'
96
+ version: '0.8'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.10'
103
+ version: '10.4'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.10'
110
+ version: '10.4'
111
111
  description: 'This is a Ruby implementation of the k-means++ algorithm for data clustering.
112
112
  In other words: Grouping a bunch of X, Y points into K groups.'
113
113
  email:
@@ -124,6 +124,8 @@ files:
124
124
  - LICENSE.txt
125
125
  - README.md
126
126
  - Rakefile
127
+ - bin/console
128
+ - bin/setup
127
129
  - examples/common.rb
128
130
  - examples/example_block.rb
129
131
  - examples/example_csv.rb
@@ -136,9 +138,6 @@ files:
136
138
  - lib/k_means_pp/cluster.rb
137
139
  - lib/k_means_pp/point.rb
138
140
  - lib/k_means_pp/version.rb
139
- - spec/lib/k_means_pp_spec.rb
140
- - spec/resources/points.csv
141
- - spec/spec_helper.rb
142
141
  homepage: https://github.com/ollie/k_means_pp
143
142
  licenses:
144
143
  - MIT
@@ -159,12 +158,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
158
  version: '0'
160
159
  requirements: []
161
160
  rubyforge_project:
162
- rubygems_version: 2.4.1
161
+ rubygems_version: 2.4.6
163
162
  signing_key:
164
163
  specification_version: 4
165
164
  summary: K-means++ Algorithm Implementation.
166
- test_files:
167
- - spec/lib/k_means_pp_spec.rb
168
- - spec/resources/points.csv
169
- - spec/spec_helper.rb
165
+ test_files: []
170
166
  has_rdoc:
@@ -1,75 +0,0 @@
1
- require 'csv'
2
-
3
- RSpec.describe 'Superman' do
4
- it 'does it again' do
5
- raw_data = File.read('./spec/resources/points.csv')
6
- data = CSV.parse(raw_data).map do |row|
7
- [row[0].to_f, row[1].to_f]
8
- end
9
-
10
- clusters = KMeansPP.clusters(data, 3)
11
-
12
- clusters.each do |cluster|
13
- expect(cluster.points.size).to be > 0
14
- expect(cluster.centroid.x).to_not eq(0)
15
- expect(cluster.centroid.y).to_not eq(0)
16
- expect(cluster.to_s).to_not be_empty
17
- end
18
-
19
- expect(clusters.size).to eq(3)
20
- end
21
-
22
- it 'array of arrays' do
23
- data = [
24
- [0.3968, 1.9431],
25
- [9.3348, 6.7843],
26
- [9.2882, 8.1347],
27
- [7.6768, 2.7362],
28
- [3.4434, 4.1910],
29
- [1.8097, 5.0884],
30
- [7.0698, 3.9285],
31
- [9.3820, 7.6790],
32
- [8.6092, 0.9651],
33
- [9.1981, 7.7493]
34
- ]
35
-
36
- clusters = KMeansPP.clusters(data, 3)
37
- expect(clusters.size).to eq(3)
38
- expect(clusters.first.points.first).to be_a(Array)
39
- end
40
-
41
- it 'array of anything else with block' do
42
- data = [
43
- { x: 0.3968, y: 1.9431 },
44
- { x: 9.3348, y: 6.7843 },
45
- { x: 9.2882, y: 8.1347 },
46
- { x: 7.6768, y: 2.7362 },
47
- { x: 3.4434, y: 4.1910 },
48
- { x: 1.8097, y: 5.0884 },
49
- { x: 7.0698, y: 3.9285 },
50
- { x: 9.3820, y: 7.6790 },
51
- { x: 8.6092, y: 0.9651 },
52
- { x: 9.1981, y: 7.7493 }
53
- ]
54
-
55
- clusters = KMeansPP.clusters(data, 3) do |point|
56
- [point[:x], point[:y]]
57
- end
58
-
59
- expect(clusters.size).to eq(3)
60
- expect(clusters.first.points.first).to be_a(Hash)
61
- end
62
-
63
- it 'does not mutate original structure' do
64
- data = [
65
- [0.3968, 1.9431],
66
- [9.3348, 6.7843]
67
- ]
68
-
69
- backup = data.dup
70
- clusters = KMeansPP.clusters(data, 2)
71
-
72
- expect(data).to eq(backup)
73
- expect(clusters.size).to eq(2)
74
- end
75
- end
@@ -1,100 +0,0 @@
1
- 48.2641334571,86.4516903905
2
- 0.114004262656,35.8368597414
3
- 97.4319168245,92.8009240744
4
- 24.4614031388,18.3292584382
5
- 36.2367675367,32.8294024271
6
- 75.5836860736,68.30729977
7
- 38.6577034445,25.7701728584
8
- 28.2607136287,64.4493377817
9
- 61.5358486771,61.2195232194
10
- 1.52352224798,38.5083779618
11
- 11.6392182793,68.2369021579
12
- 53.9486870607,53.9136556533
13
- 14.6671651772,26.0132534731
14
- 65.9506725878,82.5639317581
15
- 58.3682872339,51.6414580337
16
- 12.6918921252,2.28888447759
17
- 31.7587852231,18.1368234166
18
- 63.6631115204,24.933301389
19
- 29.1652289905,34.456759171
20
- 44.3830953085,70.4813875779
21
- 47.0571691145,65.3507625811
22
- 74.0584537502,98.2271944247
23
- 55.8929146157,86.6196265477
24
- 20.4744253473,12.0025149302
25
- 14.2867767281,40.2850440995
26
- 40.43551369,94.5410407116
27
- 87.6178871195,12.4700151639
28
- 47.2703048197,93.0636237124
29
- 59.7895104175,69.2621288413
30
- 80.8612333922,42.9183411179
31
- 31.1271795535,55.6669044656
32
- 78.9671049353,65.833739365
33
- 39.8324533414,63.0343115139
34
- 79.126343548,14.9128874133
35
- 65.8152400306,77.5202358013
36
- 75.2762752704,42.4858435609
37
- 29.6475948493,61.2068411763
38
- 67.421857106,54.8955604259
39
- 10.4652931501,29.7954139372
40
- 32.0272462745,99.5422900971
41
- 80.1520927001,84.2710379142
42
- 2.27240208403,41.2138854089
43
- 44.4601509555,1.72563901513
44
- 16.8676021068,35.3415636277
45
- 58.1977544121,29.2752085455
46
- 24.6119080085,39.9440735137
47
- 63.0759798755,60.9841014448
48
- 30.9289119657,95.0173219502
49
- 8.54972950047,41.7384441737
50
- 61.2606910793,4.06738902059
51
- 83.2302091964,11.6373312879
52
- 89.4443065362,42.5694882801
53
- 24.5619318152,97.7947977804
54
- 50.3134024475,40.6429336223
55
- 58.1422402033,36.1112632557
56
- 32.0668520827,29.9924151435
57
- 89.6057447137,84.9532177777
58
- 9.8876440816,18.2540486261
59
- 17.9670383961,47.596032257
60
- 50.2977668282,93.6851189223
61
- 98.0700386253,86.5816924579
62
- 10.8175290981,26.4344732252
63
- 34.7463851288,24.4154447141
64
- 92.5470100593,17.3595513748
65
- 79.0426629356,4.59850018907
66
- 89.9791366918,29.523946842
67
- 3.89920214563,91.3650215111
68
- 35.4669861576,62.1865368798
69
- 2.78150918086,24.5280230552
70
- 50.0390951889,57.0414421682
71
- 64.4521660758,48.4962172448
72
- 94.4915452316,56.6508179406
73
- 47.1655534769,15.8292055671
74
- 94.2027011374,45.6802385454
75
- 30.5846324871,54.783635876
76
- 57.7043252948,0.286661610381
77
- 41.7908674949,14.7206014023
78
- 59.6689465934,64.8849831965
79
- 92.2553335495,55.9096460272
80
- 48.493467262,69.4766837809
81
- 23.1837859581,71.4406867443
82
- 29.0737623652,66.9391416961
83
- 95.7442323112,89.4677505059
84
- 68.7707275828,40.9900140055
85
- 84.5445737133,32.1707309618
86
- 67.4126251988,56.6710579117
87
- 10.688352016,28.1745892928
88
- 56.7620324155,18.3034334207
89
- 50.6751320678,86.6916908032
90
- 74.6185482896,34.022483532
91
- 20.7011996002,32.855295357
92
- 11.479054664,1.59204297586
93
- 51.6805387648,25.4063026358
94
- 84.4109522357,47.237632645
95
- 90.6395051745,57.7917166935
96
- 58.6159601042,84.1226173848
97
- 46.2184509277,28.559934585
98
- 97.0302485783,41.3135022812
99
- 31.3144587058,87.2459910122
100
- 5.93357833962,95.6812831872
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- require 'simplecov'
4
-
5
- # Coverage tool, needs to be started as soon as possible
6
- SimpleCov.start do
7
- add_filter '/spec/' # Ignore spec directory
8
- end
9
-
10
- require 'k_means_pp'