tangram 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +15 -0
  4. data/README.md +1 -1
  5. data/docs/Tangram.html +2 -2
  6. data/docs/Tangram/BagOfWordsFeatureContribution.html +2 -2
  7. data/docs/Tangram/Bigram.html +2 -2
  8. data/docs/Tangram/BinaryClassificationPredictOutput.html +2 -2
  9. data/docs/Tangram/FeatureContributions.html +2 -2
  10. data/docs/Tangram/IdentityFeatureContribution.html +2 -2
  11. data/docs/Tangram/LibTangram.html +2 -2
  12. data/docs/Tangram/LibTangram/TangramStringView.html +6 -6
  13. data/docs/Tangram/LoadModelOptions.html +2 -2
  14. data/docs/Tangram/Model.html +2 -2
  15. data/docs/Tangram/MulticlassClassificationPredictOutput.html +2 -2
  16. data/docs/Tangram/NormalizedFeatureContribution.html +2 -2
  17. data/docs/Tangram/OneHotEncodedFeatureContribution.html +2 -2
  18. data/docs/Tangram/PredictOptions.html +2 -2
  19. data/docs/Tangram/RegressionPredictOutput.html +2 -2
  20. data/docs/Tangram/Unigram.html +2 -2
  21. data/docs/Tangram/WordEmbeddingFeatureContribution.html +2 -2
  22. data/docs/_index.html +2 -2
  23. data/docs/file.README.html +3 -3
  24. data/docs/index.html +3 -3
  25. data/docs/top-level-namespace.html +2 -2
  26. data/lib/tangram/libtangram/aarch64-apple-darwin/libtangram.dylib +0 -0
  27. data/lib/tangram/libtangram/aarch64-unknown-linux-gnu/libtangram.so +0 -0
  28. data/lib/tangram/libtangram/aarch64-unknown-linux-musl/libtangram.so +0 -0
  29. data/lib/tangram/libtangram/x86_64-apple-darwin/libtangram.dylib +0 -0
  30. data/lib/tangram/libtangram/x86_64-pc-windows-msvc/tangram.dll +0 -0
  31. data/lib/tangram/libtangram/x86_64-unknown-linux-gnu/libtangram.so +0 -0
  32. data/lib/tangram/libtangram/x86_64-unknown-linux-musl/libtangram.so +0 -0
  33. data/lib/tangram/tangram.rb +56 -2
  34. data/scripts/dev +1 -0
  35. data/scripts/docs +2 -1
  36. data/scripts/release +5 -1
  37. data/tangram.gemspec +1 -1
  38. metadata +7 -4
  39. data/scripts/build +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e9ad90eec0aa379aa164d2e6afad538d26c7ad8dbfb1f83edac6fa98ffb7ef3
4
- data.tar.gz: 820062630f2882b1f399348073bcacc536ce4be3e691fb70a4d4ee0aa86b15f3
3
+ metadata.gz: bab4f830a6691879402e6bc63d0433c864fb02f0852c818b881857ebc2e0fb25
4
+ data.tar.gz: 0f7664501b24b5d87d55b593e57c90c8c59a3238cb59323152a4e6a1525be1b0
5
5
  SHA512:
6
- metadata.gz: 7a1ed9abef3cba7e3546763e4d7f0927617af3a361901cbc9cb7a9b080872c1b449c779fe80bef520b20ef973721cbf6bcbf0e4b5eef839ad19649f45cc3d6c5
7
- data.tar.gz: fe6666f9ff59015f47f5515afbfd30eabb794dba362d2b6cef56ac259840e542b34ecafe8711150ccdec5961c60b97c8fb39542ec4249c2f8807e99893b90391
6
+ metadata.gz: fd6b1409b94794dbc7c62d03650ac99fc4537f11f0a1b0422e9b1d6d6472e707ee0c9185f86e6e8ad058505d2efe3df46d8f0e7292afdd023949cab8a500adb7
7
+ data.tar.gz: f0c87e1c2e13f05b2bbdeeb909a8ee0e04b679036b11763da9eec6a40af981316d476500c684ccfa0d20caa974904a827c094a0050786577ca6be86abced8b0a
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'redcarpet'
3
+ gem 'yard'
data/Gemfile.lock ADDED
@@ -0,0 +1,15 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ redcarpet (3.5.1)
5
+ yard (0.9.26)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ redcarpet
12
+ yard
13
+
14
+ BUNDLED WITH
15
+ 1.17.2
data/README.md CHANGED
@@ -14,7 +14,7 @@ $ gem install tangram
14
14
  ```ruby
15
15
  require 'tangram'
16
16
 
17
- model = Tangram::Model.from_file('./heart_disease.tangram')
17
+ model = Tangram::Model.from_path('./heart_disease.tangram')
18
18
 
19
19
  input = {
20
20
  age: 63,
data/docs/Tangram.html CHANGED
@@ -117,9 +117,9 @@
117
117
  </div>
118
118
 
119
119
  <div id="footer">
120
- Generated on Fri Apr 23 15:50:02 2021 by
120
+ Generated on Wed May 12 10:45:10 2021 by
121
121
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
- 0.9.26 (ruby-3.0.1).
122
+ 0.9.26 (ruby-2.6.7).
123
123
  </div>
124
124
 
125
125
  </div>
@@ -497,9 +497,9 @@
497
497
  </div>
498
498
 
499
499
  <div id="footer">
500
- Generated on Fri Apr 23 15:50:02 2021 by
500
+ Generated on Wed May 12 10:45:10 2021 by
501
501
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
502
- 0.9.26 (ruby-3.0.1).
502
+ 0.9.26 (ruby-2.6.7).
503
503
  </div>
504
504
 
505
505
  </div>
@@ -353,9 +353,9 @@
353
353
  </div>
354
354
 
355
355
  <div id="footer">
356
- Generated on Fri Apr 23 15:50:02 2021 by
356
+ Generated on Wed May 12 10:45:10 2021 by
357
357
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
358
- 0.9.26 (ruby-3.0.1).
358
+ 0.9.26 (ruby-2.6.7).
359
359
  </div>
360
360
 
361
361
  </div>
@@ -483,9 +483,9 @@
483
483
  </div>
484
484
 
485
485
  <div id="footer">
486
- Generated on Fri Apr 23 15:50:02 2021 by
486
+ Generated on Wed May 12 10:45:10 2021 by
487
487
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
488
- 0.9.26 (ruby-3.0.1).
488
+ 0.9.26 (ruby-2.6.7).
489
489
  </div>
490
490
 
491
491
  </div>
@@ -425,9 +425,9 @@
425
425
  </div>
426
426
 
427
427
  <div id="footer">
428
- Generated on Fri Apr 23 15:50:02 2021 by
428
+ Generated on Wed May 12 10:45:10 2021 by
429
429
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
430
- 0.9.26 (ruby-3.0.1).
430
+ 0.9.26 (ruby-2.6.7).
431
431
  </div>
432
432
 
433
433
  </div>
@@ -425,9 +425,9 @@
425
425
  </div>
426
426
 
427
427
  <div id="footer">
428
- Generated on Fri Apr 23 15:50:02 2021 by
428
+ Generated on Wed May 12 10:45:10 2021 by
429
429
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
430
- 0.9.26 (ruby-3.0.1).
430
+ 0.9.26 (ruby-2.6.7).
431
431
  </div>
432
432
 
433
433
  </div>
@@ -150,9 +150,9 @@
150
150
  </div>
151
151
 
152
152
  <div id="footer">
153
- Generated on Fri Apr 23 15:50:02 2021 by
153
+ Generated on Wed May 12 10:45:10 2021 by
154
154
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
155
- 0.9.26 (ruby-3.0.1).
155
+ 0.9.26 (ruby-2.6.7).
156
156
  </div>
157
157
 
158
158
  </div>
@@ -163,12 +163,12 @@
163
163
  <pre class="lines">
164
164
 
165
165
 
166
- 742
167
- 743
168
- 744</pre>
166
+ 746
167
+ 747
168
+ 748</pre>
169
169
  </td>
170
170
  <td>
171
- <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 742</span>
171
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 746</span>
172
172
 
173
173
  <span class='kw'>def</span> <span class='id identifier rubyid_into_string'>into_string</span>
174
174
  <span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:ptr</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_read_string'>read_string</span><span class='lparen'>(</span><span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:len</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_force_encoding'>force_encoding</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>utf-8</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
@@ -183,9 +183,9 @@
183
183
  </div>
184
184
 
185
185
  <div id="footer">
186
- Generated on Fri Apr 23 15:50:02 2021 by
186
+ Generated on Wed May 12 10:45:10 2021 by
187
187
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
188
- 0.9.26 (ruby-3.0.1).
188
+ 0.9.26 (ruby-2.6.7).
189
189
  </div>
190
190
 
191
191
  </div>
@@ -281,9 +281,9 @@
281
281
  </div>
282
282
 
283
283
  <div id="footer">
284
- Generated on Fri Apr 23 15:50:02 2021 by
284
+ Generated on Wed May 12 10:45:10 2021 by
285
285
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
286
- 0.9.26 (ruby-3.0.1).
286
+ 0.9.26 (ruby-2.6.7).
287
287
  </div>
288
288
 
289
289
  </div>
@@ -1240,9 +1240,9 @@
1240
1240
  </div>
1241
1241
 
1242
1242
  <div id="footer">
1243
- Generated on Fri Apr 23 15:50:02 2021 by
1243
+ Generated on Wed May 12 10:45:10 2021 by
1244
1244
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1245
- 0.9.26 (ruby-3.0.1).
1245
+ 0.9.26 (ruby-2.6.7).
1246
1246
  </div>
1247
1247
 
1248
1248
  </div>
@@ -555,9 +555,9 @@
555
555
  </div>
556
556
 
557
557
  <div id="footer">
558
- Generated on Fri Apr 23 15:50:02 2021 by
558
+ Generated on Wed May 12 10:45:10 2021 by
559
559
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
560
- 0.9.26 (ruby-3.0.1).
560
+ 0.9.26 (ruby-2.6.7).
561
561
  </div>
562
562
 
563
563
  </div>
@@ -425,9 +425,9 @@
425
425
  </div>
426
426
 
427
427
  <div id="footer">
428
- Generated on Fri Apr 23 15:50:02 2021 by
428
+ Generated on Wed May 12 10:45:10 2021 by
429
429
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
430
- 0.9.26 (ruby-3.0.1).
430
+ 0.9.26 (ruby-2.6.7).
431
431
  </div>
432
432
 
433
433
  </div>
@@ -497,9 +497,9 @@
497
497
  </div>
498
498
 
499
499
  <div id="footer">
500
- Generated on Fri Apr 23 15:50:02 2021 by
500
+ Generated on Wed May 12 10:45:10 2021 by
501
501
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
502
- 0.9.26 (ruby-3.0.1).
502
+ 0.9.26 (ruby-2.6.7).
503
503
  </div>
504
504
 
505
505
  </div>
@@ -411,9 +411,9 @@
411
411
  </div>
412
412
 
413
413
  <div id="footer">
414
- Generated on Fri Apr 23 15:50:02 2021 by
414
+ Generated on Wed May 12 10:45:10 2021 by
415
415
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
416
- 0.9.26 (ruby-3.0.1).
416
+ 0.9.26 (ruby-2.6.7).
417
417
  </div>
418
418
 
419
419
  </div>
@@ -411,9 +411,9 @@
411
411
  </div>
412
412
 
413
413
  <div id="footer">
414
- Generated on Fri Apr 23 15:50:02 2021 by
414
+ Generated on Wed May 12 10:45:10 2021 by
415
415
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
416
- 0.9.26 (ruby-3.0.1).
416
+ 0.9.26 (ruby-2.6.7).
417
417
  </div>
418
418
 
419
419
  </div>
@@ -281,9 +281,9 @@
281
281
  </div>
282
282
 
283
283
  <div id="footer">
284
- Generated on Fri Apr 23 15:50:02 2021 by
284
+ Generated on Wed May 12 10:45:10 2021 by
285
285
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
286
- 0.9.26 (ruby-3.0.1).
286
+ 0.9.26 (ruby-2.6.7).
287
287
  </div>
288
288
 
289
289
  </div>
@@ -425,9 +425,9 @@
425
425
  </div>
426
426
 
427
427
  <div id="footer">
428
- Generated on Fri Apr 23 15:50:02 2021 by
428
+ Generated on Wed May 12 10:45:10 2021 by
429
429
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
430
- 0.9.26 (ruby-3.0.1).
430
+ 0.9.26 (ruby-2.6.7).
431
431
  </div>
432
432
 
433
433
  </div>
data/docs/_index.html CHANGED
@@ -300,9 +300,9 @@
300
300
  </div>
301
301
 
302
302
  <div id="footer">
303
- Generated on Fri Apr 23 15:50:02 2021 by
303
+ Generated on Wed May 12 10:45:10 2021 by
304
304
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
305
- 0.9.26 (ruby-3.0.1).
305
+ 0.9.26 (ruby-2.6.7).
306
306
  </div>
307
307
 
308
308
  </div>
@@ -73,7 +73,7 @@
73
73
 
74
74
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>tangram</span><span class='tstring_end'>&#39;</span></span>
75
75
 
76
- <span class='id identifier rubyid_model'>model</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Tangram.html" title="Tangram (module)">Tangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Tangram/Model.html" title="Tangram::Model (class)">Model</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_file'>from_file</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>./heart_disease.tangram</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
76
+ <span class='id identifier rubyid_model'>model</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Tangram.html" title="Tangram (module)">Tangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Tangram/Model.html" title="Tangram::Model (class)">Model</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_path'><span class='object_link'><a href="Tangram/Model.html#from_path-class_method" title="Tangram::Model.from_path (method)">from_path</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>./heart_disease.tangram</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
77
77
 
78
78
  <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='lbrace'>{</span>
79
79
  <span class='label'>age:</span> <span class='int'>63</span><span class='comma'>,</span>
@@ -118,9 +118,9 @@
118
118
  </div></div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Fri Apr 23 15:50:02 2021 by
121
+ Generated on Wed May 12 10:45:10 2021 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
- 0.9.26 (ruby-3.0.1).
123
+ 0.9.26 (ruby-2.6.7).
124
124
  </div>
125
125
 
126
126
  </div>
data/docs/index.html CHANGED
@@ -73,7 +73,7 @@
73
73
 
74
74
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>tangram</span><span class='tstring_end'>&#39;</span></span>
75
75
 
76
- <span class='id identifier rubyid_model'>model</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Tangram.html" title="Tangram (module)">Tangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Tangram/Model.html" title="Tangram::Model (class)">Model</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_file'>from_file</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>./heart_disease.tangram</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
76
+ <span class='id identifier rubyid_model'>model</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Tangram.html" title="Tangram (module)">Tangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Tangram/Model.html" title="Tangram::Model (class)">Model</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_path'><span class='object_link'><a href="Tangram/Model.html#from_path-class_method" title="Tangram::Model.from_path (method)">from_path</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>./heart_disease.tangram</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
77
77
 
78
78
  <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='lbrace'>{</span>
79
79
  <span class='label'>age:</span> <span class='int'>63</span><span class='comma'>,</span>
@@ -118,9 +118,9 @@
118
118
  </div></div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Fri Apr 23 15:50:02 2021 by
121
+ Generated on Wed May 12 10:45:10 2021 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
- 0.9.26 (ruby-3.0.1).
123
+ 0.9.26 (ruby-2.6.7).
124
124
  </div>
125
125
 
126
126
  </div>
@@ -100,9 +100,9 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Apr 23 15:50:02 2021 by
103
+ Generated on Wed May 12 10:45:10 2021 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.26 (ruby-3.0.1).
105
+ 0.9.26 (ruby-2.6.7).
106
106
  </div>
107
107
 
108
108
  </div>
@@ -187,6 +187,24 @@ module Tangram
187
187
  end
188
188
  end
189
189
 
190
+ # This describes the contribution of a feature from a bag of words cosine similarity feature group.
191
+ class BagOfWordsCosineSimilarityFeatureContribution
192
+ # This is the name of the source column a for the feature group.
193
+ attr_reader :column_name_a
194
+ # This is the name of the source column b for the feature group.
195
+ attr_reader :column_name_b
196
+ # This is the value of the feature.
197
+ attr_reader :feature_value
198
+ # This is the amount that the feature contributed to the output.
199
+ attr_reader :feature_contribution_value
200
+ def initialize(column_name_a:, column_name_b:, feature_contribution_value:, feature_value:)
201
+ @column_name_a = column_name_a
202
+ @column_name_b = column_name_b
203
+ @feature_contribution_value = feature_contribution_value
204
+ @feature_value = feature_value
205
+ end
206
+ end
207
+
190
208
  # This describes the contribution of a feature from a word embedding feature group.
191
209
  class WordEmbeddingFeatureContribution
192
210
  # This is the name of the source column for the feature group.
@@ -569,6 +587,8 @@ module Tangram
569
587
  get_one_hot_encoded_feature_contribution(c_feature_contribution)
570
588
  when LibTangram::TangramFeatureContributionEntryType[:bag_of_words]
571
589
  get_bag_of_words_feature_contribution(c_feature_contribution)
590
+ when LibTangram::TangramFeatureContributionEntryType[:bag_of_words_cosine_similarity]
591
+ get_bag_of_words_cosine_similarity_feature_contribution(c_feature_contribution)
572
592
  when LibTangram::TangramFeatureContributionEntryType[:word_embedding]
573
593
  get_word_embedding_feature_contribution(c_feature_contribution)
574
594
  end
@@ -626,9 +646,9 @@ module Tangram
626
646
  c_feature_contribution_value = FFI::MemoryPointer.new(:float)
627
647
  LibTangram.tangram_one_hot_encoded_feature_contribution_get_feature_contribution_value(c_one_hot_encoded_feature_contribution, c_feature_contribution_value)
628
648
  feature_contribution_value = c_feature_contribution_value.read(:float)
629
- c_feature_value = FFI::MemoryPointer.new(:float)
649
+ c_feature_value = FFI::MemoryPointer.new(:bool)
630
650
  LibTangram.tangram_one_hot_encoded_feature_contribution_get_feature_value(c_one_hot_encoded_feature_contribution, c_feature_value)
631
- feature_value = c_feature_value.read(:float)
651
+ feature_value = c_feature_value.read(:bool)
632
652
  c_variant = LibTangram::TangramStringView.new
633
653
  LibTangram.tangram_one_hot_encoded_feature_contribution_get_variant(c_one_hot_encoded_feature_contribution, c_variant)
634
654
  variant = c_variant[:ptr].null? ? nil : c_variant.into_string
@@ -665,6 +685,30 @@ module Tangram
665
685
  )
666
686
  end
667
687
 
688
+ def get_bag_of_words_cosine_similarity_feature_contribution(c_feature_contribution)
689
+ c_bag_of_words_cosine_similarity_feature_contribution = FFI::MemoryPointer.new(:pointer)
690
+ LibTangram.tangram_feature_contribution_entry_as_bag_of_words_cosine_similarity(c_feature_contribution, c_bag_of_words_cosine_similarity_feature_contribution)
691
+ c_bag_of_words_cosine_similarity_feature_contribution = c_bag_of_words_cosine_similarity_feature_contribution.read_pointer
692
+ c_column_name_a = LibTangram::TangramStringView.new
693
+ LibTangram.tangram_bag_of_words_feature_contribution_get_column_name_a(c_bag_of_words_cosine_similarity_feature_contribution, c_column_name_a)
694
+ column_name_a = c_column_name_a.into_string
695
+ c_column_name_b = LibTangram::TangramStringView.new
696
+ LibTangram.tangram_bag_of_words_feature_contribution_get_column_name_b(c_bag_of_words_cosine_similarity_feature_contribution, c_column_name_b)
697
+ column_name_b = c_column_name_b.into_string
698
+ c_feature_contribution_value = FFI::MemoryPointer.new(:float)
699
+ LibTangram.tangram_bag_of_words_cosine_similarity_feature_contribution_get_feature_contribution_value(c_bag_of_words_cosine_similarity_feature_contribution, c_feature_contribution_value)
700
+ feature_contribution_value = c_feature_contribution_value.read(:float)
701
+ c_feature_value = FFI::MemoryPointer.new(:float)
702
+ LibTangram.tangram_bag_of_words_cosine_similarity_feature_contribution_get_feature_value(c_bag_of_words_cosine_similarity_feature_contribution, c_feature_value)
703
+ feature_value = c_feature_value.read(:float)
704
+ BagOfWordsFeatureContribution.new(
705
+ column_name_a: column_name_a,
706
+ column_name_b: column_name_b,
707
+ feature_contribution_value: feature_contribution_value,
708
+ feature_value: feature_value
709
+ )
710
+ end
711
+
668
712
  def get_word_embedding_feature_contribution(c_feature_contribution)
669
713
  c_word_embedding_feature_contribution = FFI::MemoryPointer.new(:pointer)
670
714
  LibTangram.tangram_feature_contribution_entry_as_word_embedding(
@@ -726,8 +770,12 @@ module Tangram
726
770
  os = RbConfig::CONFIG['host_os']
727
771
  if (cpu == 'x86_64') && os =~ (/linux/)
728
772
  library_path = 'libtangram/x86_64-unknown-linux-gnu/libtangram.so'
773
+ elsif (cpu == 'aarch64') && os =~ (/linux/)
774
+ library_path = 'libtangram/aarch64-unknown-linux-gnu/libtangram.so'
729
775
  elsif (cpu == 'x86_64') && os =~ (/darwin/)
730
776
  library_path = 'libtangram/x86_64-apple-darwin/libtangram.dylib'
777
+ elsif (cpu == 'aarch64') && os =~ (/darwin/)
778
+ library_path = 'libtangram/aarch64-apple-darwin/libtangram.dylib'
731
779
  elsif (cpu == 'x86_64') && os =~ (/mingw/)
732
780
  library_path = 'libtangram/x86_64-pc-windows-msvc/tangram.dll'
733
781
  else
@@ -755,6 +803,7 @@ module Tangram
755
803
  :normalized,
756
804
  :one_hot_encoded,
757
805
  :bag_of_words,
806
+ :bag_of_words_cosine_similarity,
758
807
  :word_embedding
759
808
  )
760
809
 
@@ -815,6 +864,7 @@ module Tangram
815
864
  attach_function :tangram_feature_contribution_entry_as_normalized, [:pointer, :pointer], :void
816
865
  attach_function :tangram_feature_contribution_entry_as_one_hot_encoded, [:pointer, :pointer], :void
817
866
  attach_function :tangram_feature_contribution_entry_as_bag_of_words, [:pointer, :pointer], :void
867
+ attach_function :tangram_feature_contribution_entry_as_bag_of_words_cosine_similarity, [:pointer, :pointer], :void
818
868
  attach_function :tangram_feature_contribution_entry_as_word_embedding, [:pointer, :pointer], :void
819
869
  attach_function :tangram_identity_feature_contribution_get_column_name, [:pointer, TangramStringView.by_ref], :void
820
870
  attach_function :tangram_identity_feature_contribution_get_feature_value, [:pointer, :pointer], :void
@@ -834,6 +884,10 @@ module Tangram
834
884
  attach_function :tangram_unigram_get_token, [:pointer, TangramStringView.by_ref], :void
835
885
  attach_function :tangram_bigram_get_token_a, [:pointer, TangramStringView.by_ref], :void
836
886
  attach_function :tangram_bigram_get_token_b, [:pointer, TangramStringView.by_ref], :void
887
+ attach_function :tangram_bag_of_words_cosine_similarity_feature_contribution_get_column_name_a, [:pointer, TangramStringView.by_ref], :void
888
+ attach_function :tangram_bag_of_words_cosine_similarity_feature_contribution_get_column_name_b, [:pointer, TangramStringView.by_ref], :void
889
+ attach_function :tangram_bag_of_words_cosine_similarity_feature_contribution_get_feature_value, [:pointer, :pointer], :void
890
+ attach_function :tangram_bag_of_words_cosine_similarity_feature_contribution_get_feature_contribution_value, [:pointer, :pointer], :void
837
891
  attach_function :tangram_word_embedding_feature_contribution_get_column_name, [:pointer, TangramStringView.by_ref], :void
838
892
  attach_function :tangram_word_embedding_feature_contribution_get_value_index, [:pointer, :pointer], :void
839
893
  attach_function :tangram_word_embedding_feature_contribution_get_feature_contribution_value, [:pointer, :pointer], :void
data/scripts/dev CHANGED
@@ -1,3 +1,4 @@
1
+ bundle
1
2
  cargo build -p libtangram
2
3
  install -D ../../target/debug/libtangram.so lib/tangram/libtangram/x86_64-unknown-linux-gnu/libtangram.so
3
4
  scripts/build
data/scripts/docs CHANGED
@@ -1 +1,2 @@
1
- yard -m markdown -o docs
1
+ bundle
2
+ bundle exec yard -m markdown -o docs
data/scripts/release CHANGED
@@ -1 +1,5 @@
1
- gem publish dist/*
1
+ gem build tangram.gemspec
2
+ rm -rf dist
3
+ mkdir -p dist
4
+ mv *.gem dist
5
+ gem push dist/*
data/tangram.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "tangram"
3
- s.version = "0.3.0"
3
+ s.version = "0.4.0"
4
4
  s.summary = "Tangram for Ruby"
5
5
  s.description = "Make predictions with a Tangram model from your Ruby app. Learn more at https://www.tangram.xyz/."
6
6
  s.authors = ["Tangram"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tangram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tangram
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-23 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -31,6 +31,8 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - Gemfile
35
+ - Gemfile.lock
34
36
  - LICENSE
35
37
  - README.md
36
38
  - docs/Tangram.html
@@ -69,12 +71,13 @@ files:
69
71
  - examples/heart_disease.tangram
70
72
  - lib/tangram.rb
71
73
  - lib/tangram/libtangram/aarch64-apple-darwin/libtangram.dylib
74
+ - lib/tangram/libtangram/aarch64-unknown-linux-gnu/libtangram.so
75
+ - lib/tangram/libtangram/aarch64-unknown-linux-musl/libtangram.so
72
76
  - lib/tangram/libtangram/x86_64-apple-darwin/libtangram.dylib
73
77
  - lib/tangram/libtangram/x86_64-pc-windows-msvc/tangram.dll
74
78
  - lib/tangram/libtangram/x86_64-unknown-linux-gnu/libtangram.so
75
79
  - lib/tangram/libtangram/x86_64-unknown-linux-musl/libtangram.so
76
80
  - lib/tangram/tangram.rb
77
- - scripts/build
78
81
  - scripts/dev
79
82
  - scripts/docs
80
83
  - scripts/fmt
@@ -99,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
102
  - !ruby/object:Gem::Version
100
103
  version: '0'
101
104
  requirements: []
102
- rubygems_version: 3.2.15
105
+ rubygems_version: 3.2.16
103
106
  signing_key:
104
107
  specification_version: 4
105
108
  summary: Tangram for Ruby
data/scripts/build DELETED
@@ -1,3 +0,0 @@
1
- gem build tangram.gemspec
2
- mkdir -p dist
3
- mv *.gem dist