tangram 0.1.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +15 -0
  4. data/LICENSE +1 -1
  5. data/README.md +8 -28
  6. data/docs/Tangram.html +127 -0
  7. data/docs/Tangram/BagOfWordsCosineSimilarityFeatureContribution.html +507 -0
  8. data/docs/Tangram/BagOfWordsFeatureContribution.html +507 -0
  9. data/docs/Tangram/Bigram.html +363 -0
  10. data/docs/Tangram/BinaryClassificationPredictOutput.html +493 -0
  11. data/docs/Tangram/FeatureContributions.html +435 -0
  12. data/docs/Tangram/IdentityFeatureContribution.html +435 -0
  13. data/docs/Tangram/LibTangram.html +161 -0
  14. data/docs/Tangram/LibTangram/TangramStringView.html +193 -0
  15. data/docs/Tangram/LoadModelOptions.html +291 -0
  16. data/docs/Tangram/Model.html +1250 -0
  17. data/docs/Tangram/MulticlassClassificationPredictOutput.html +565 -0
  18. data/docs/Tangram/NormalizedFeatureContribution.html +435 -0
  19. data/docs/Tangram/OneHotEncodedFeatureContribution.html +507 -0
  20. data/docs/Tangram/PredictOptions.html +421 -0
  21. data/docs/Tangram/RegressionPredictOutput.html +421 -0
  22. data/docs/Tangram/Unigram.html +291 -0
  23. data/docs/Tangram/WordEmbeddingFeatureContribution.html +435 -0
  24. data/docs/_index.html +317 -0
  25. data/docs/class_list.html +51 -0
  26. data/docs/css/common.css +1 -0
  27. data/docs/css/full_list.css +58 -0
  28. data/docs/css/style.css +497 -0
  29. data/docs/file.README.html +106 -0
  30. data/docs/file_list.html +56 -0
  31. data/docs/frames.html +17 -0
  32. data/docs/index.html +106 -0
  33. data/docs/js/app.js +314 -0
  34. data/docs/js/full_list.js +216 -0
  35. data/docs/js/jquery.js +4 -0
  36. data/docs/method_list.html +595 -0
  37. data/docs/top-level-namespace.html +110 -0
  38. data/examples/advanced/Gemfile +2 -0
  39. data/examples/advanced/Gemfile.lock +15 -0
  40. data/examples/advanced/README.md +14 -0
  41. data/examples/advanced/heart_disease.tangram +0 -0
  42. data/examples/advanced/main.rb +49 -0
  43. data/examples/basic/Gemfile +2 -0
  44. data/examples/basic/Gemfile.lock +15 -0
  45. data/examples/basic/README.md +10 -0
  46. data/examples/basic/heart_disease.tangram +0 -0
  47. data/examples/basic/main.rb +29 -0
  48. data/lib/tangram.rb +1 -1
  49. data/lib/tangram/libtangram/aarch64-apple-darwin/libtangram.dylib +0 -0
  50. data/lib/tangram/libtangram/aarch64-unknown-linux-gnu/libtangram.so +0 -0
  51. data/lib/tangram/libtangram/aarch64-unknown-linux-musl/libtangram.so +0 -0
  52. data/lib/tangram/libtangram/x86_64-apple-darwin/libtangram.dylib +0 -0
  53. data/lib/tangram/libtangram/x86_64-pc-windows-msvc/tangram.dll +0 -0
  54. data/lib/tangram/libtangram/x86_64-unknown-linux-gnu/libtangram.so +0 -0
  55. data/lib/tangram/libtangram/x86_64-unknown-linux-musl/libtangram.so +0 -0
  56. data/lib/tangram/tangram.rb +895 -0
  57. data/scripts/dev +5 -0
  58. data/scripts/docs +2 -0
  59. data/scripts/fmt +0 -0
  60. data/scripts/release +13 -0
  61. data/tangram.gemspec +10 -10
  62. metadata +64 -18
  63. data/examples/monitor/heart-disease.tangram +0 -0
  64. data/examples/monitor/main.rb +0 -52
  65. data/examples/predict/heart-disease.tangram +0 -0
  66. data/examples/predict/main.rb +0 -30
  67. data/lib/tangram/libtangram-0.1.3-linux-x86_64.so +0 -0
  68. data/lib/tangram/libtangram-0.1.3-macos-x86_64.dylib +0 -0
  69. data/lib/tangram/libtangram.rb +0 -24
  70. data/lib/tangram/model.rb +0 -133
  71. data/lib/tangram/tangram-0.1.3-windows-x86_64.dll +0 -0
  72. data/scripts/build +0 -5
@@ -0,0 +1,1250 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Tangram::Model
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Tangram::Model";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (M)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Tangram.html" title="Tangram (module)">Tangram</a></span></span>
41
+ &raquo;
42
+ <span class="title">Model</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Tangram::Model
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Tangram::Model</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/tangram/tangram.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p>Use this class to load a model, make predictions, and log events to the app.</p>
105
+
106
+
107
+ </div>
108
+ </div>
109
+ <div class="tags">
110
+
111
+
112
+ </div>
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ <h2>
121
+ Class Method Summary
122
+ <small><a href="#" class="summary_toggle">collapse</a></small>
123
+ </h2>
124
+
125
+ <ul class="summary">
126
+
127
+ <li class="public ">
128
+ <span class="summary_signature">
129
+
130
+ <a href="#from_bytes-class_method" title="from_bytes (class method)">.<strong>from_bytes</strong>(bytes, options: nil) &#x21d2; Model </a>
131
+
132
+
133
+
134
+ </span>
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ <span class="summary_desc"><div class='inline'><p>Load a model from bytes instead of a file.</p>
145
+ </div></span>
146
+
147
+ </li>
148
+
149
+
150
+ <li class="public ">
151
+ <span class="summary_signature">
152
+
153
+ <a href="#from_path-class_method" title="from_path (class method)">.<strong>from_path</strong>(path, options: nil) &#x21d2; Model </a>
154
+
155
+
156
+
157
+ </span>
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ <span class="summary_desc"><div class='inline'><p>Load a model from the <code>.tangram</code> file at <code>path</code>.</p>
168
+ </div></span>
169
+
170
+ </li>
171
+
172
+
173
+ </ul>
174
+
175
+ <h2>
176
+ Instance Method Summary
177
+ <small><a href="#" class="summary_toggle">collapse</a></small>
178
+ </h2>
179
+
180
+ <ul class="summary">
181
+
182
+ <li class="public ">
183
+ <span class="summary_signature">
184
+
185
+ <a href="#enqueue_log_prediction-instance_method" title="#enqueue_log_prediction (instance method)">#<strong>enqueue_log_prediction</strong>(identifier:, input:, output:, options: nil) &#x21d2; Object </a>
186
+
187
+
188
+
189
+ </span>
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ <span class="summary_desc"><div class='inline'><p>Add a prediction event to the queue.</p>
200
+ </div></span>
201
+
202
+ </li>
203
+
204
+
205
+ <li class="public ">
206
+ <span class="summary_signature">
207
+
208
+ <a href="#enqueue_log_true_value-instance_method" title="#enqueue_log_true_value (instance method)">#<strong>enqueue_log_true_value</strong>(identifier:, true_value:) &#x21d2; Object </a>
209
+
210
+
211
+
212
+ </span>
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+ <span class="summary_desc"><div class='inline'><p>Add a true value event to the queue.</p>
223
+ </div></span>
224
+
225
+ </li>
226
+
227
+
228
+ <li class="public ">
229
+ <span class="summary_signature">
230
+
231
+ <a href="#flush_log_queue-instance_method" title="#flush_log_queue (instance method)">#<strong>flush_log_queue</strong> &#x21d2; Object </a>
232
+
233
+
234
+
235
+ </span>
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+ <span class="summary_desc"><div class='inline'><p>Send all events in the queue to the app.</p>
246
+ </div></span>
247
+
248
+ </li>
249
+
250
+
251
+ <li class="public ">
252
+ <span class="summary_signature">
253
+
254
+ <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> &#x21d2; Object </a>
255
+
256
+
257
+
258
+ </span>
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+ <span class="summary_desc"><div class='inline'><p>Retrieve the model&#39;s id.</p>
269
+ </div></span>
270
+
271
+ </li>
272
+
273
+
274
+ <li class="public ">
275
+ <span class="summary_signature">
276
+
277
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(c_model, options: nil) &#x21d2; Model </a>
278
+
279
+
280
+
281
+ </span>
282
+
283
+
284
+ <span class="note title constructor">constructor</span>
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ <span class="summary_desc"><div class='inline'><p>A new instance of Model.</p>
294
+ </div></span>
295
+
296
+ </li>
297
+
298
+
299
+ <li class="public ">
300
+ <span class="summary_signature">
301
+
302
+ <a href="#log_prediction-instance_method" title="#log_prediction (instance method)">#<strong>log_prediction</strong>(identifier:, input:, output:, options: nil) &#x21d2; Object </a>
303
+
304
+
305
+
306
+ </span>
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <span class="summary_desc"><div class='inline'><p>Send a prediction event to the app.</p>
317
+ </div></span>
318
+
319
+ </li>
320
+
321
+
322
+ <li class="public ">
323
+ <span class="summary_signature">
324
+
325
+ <a href="#log_true_value-instance_method" title="#log_true_value (instance method)">#<strong>log_true_value</strong>(identifier:, true_value:) &#x21d2; Object </a>
326
+
327
+
328
+
329
+ </span>
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+ <span class="summary_desc"><div class='inline'><p>Send a true value event to the app.</p>
340
+ </div></span>
341
+
342
+ </li>
343
+
344
+
345
+ <li class="public ">
346
+ <span class="summary_signature">
347
+
348
+ <a href="#predict-instance_method" title="#predict (instance method)">#<strong>predict</strong>(input, options: nil) &#x21d2; Array&lt;RegressionPredictOutput, BinaryClassificationPredictOutput, MulticlassClassificationPredictOutput&gt;, ... </a>
349
+
350
+
351
+
352
+ </span>
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ <span class="summary_desc"><div class='inline'><p>Make a prediction!.</p>
363
+ </div></span>
364
+
365
+ </li>
366
+
367
+
368
+ </ul>
369
+
370
+
371
+ <div id="constructor_details" class="method_details_list">
372
+ <h2>Constructor Details</h2>
373
+
374
+ <div class="method_details first">
375
+ <h3 class="signature first" id="initialize-instance_method">
376
+
377
+ #<strong>initialize</strong>(c_model, options: nil) &#x21d2; <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
378
+
379
+
380
+
381
+
382
+
383
+ </h3><div class="docstring">
384
+ <div class="discussion">
385
+ <p>Returns a new instance of Model.</p>
386
+
387
+
388
+ </div>
389
+ </div>
390
+ <div class="tags">
391
+
392
+
393
+ </div><table class="source_code">
394
+ <tr>
395
+ <td>
396
+ <pre class="lines">
397
+
398
+
399
+ 257
400
+ 258
401
+ 259
402
+ 260
403
+ 261</pre>
404
+ </td>
405
+ <td>
406
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 257</span>
407
+
408
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_c_model'>c_model</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
409
+ <span class='ivar'>@tangram_url</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='op'>&amp;.</span><span class='id identifier rubyid_tangram_url'>tangram_url</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://app.tangram.xyz</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='id identifier rubyid_options'>options</span><span class='op'>&amp;.</span><span class='id identifier rubyid_tangram_url'>tangram_url</span>
410
+ <span class='ivar'>@log_queue</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
411
+ <span class='ivar'>@model</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>AutoPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_model'>c_model</span><span class='period'>.</span><span class='id identifier rubyid_read_pointer'>read_pointer</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:tangram_model_delete</span><span class='rparen'>)</span><span class='rparen'>)</span>
412
+ <span class='kw'>end</span></pre>
413
+ </td>
414
+ </tr>
415
+ </table>
416
+ </div>
417
+
418
+ </div>
419
+
420
+
421
+ <div id="class_method_details" class="method_details_list">
422
+ <h2>Class Method Details</h2>
423
+
424
+
425
+ <div class="method_details first">
426
+ <h3 class="signature first" id="from_bytes-class_method">
427
+
428
+ .<strong>from_bytes</strong>(bytes, options: nil) &#x21d2; <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
429
+
430
+
431
+
432
+
433
+
434
+ </h3><div class="docstring">
435
+ <div class="discussion">
436
+ <p>Load a model from bytes instead of a file. You should use this only if you already have a <code>.tangram</code> loaded into memory. Otherwise, use <code>Model.from_path</code>, which is faster because it memory maps the file.</p>
437
+
438
+
439
+ </div>
440
+ </div>
441
+ <div class="tags">
442
+ <p class="tag_title">Parameters:</p>
443
+ <ul class="param">
444
+
445
+ <li>
446
+
447
+ <span class='name'>bytes</span>
448
+
449
+
450
+ <span class='type'>(<tt>String</tt>)</span>
451
+
452
+
453
+
454
+ &mdash;
455
+ <div class='inline'><p>The bytes for the .tangram model.</p>
456
+ </div>
457
+
458
+ </li>
459
+
460
+ <li>
461
+
462
+ <span class='name'>options</span>
463
+
464
+
465
+ <span class='type'>(<tt><span class='object_link'><a href="LoadModelOptions.html" title="Tangram::LoadModelOptions (class)">LoadModelOptions</a></span></tt>)</span>
466
+
467
+
468
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
469
+
470
+
471
+ &mdash;
472
+ <div class='inline'><p>The options to use when loading the model.</p>
473
+ </div>
474
+
475
+ </li>
476
+
477
+ </ul>
478
+
479
+ <p class="tag_title">Returns:</p>
480
+ <ul class="return">
481
+
482
+ <li>
483
+
484
+
485
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>)</span>
486
+
487
+
488
+
489
+ </li>
490
+
491
+ </ul>
492
+
493
+ </div><table class="source_code">
494
+ <tr>
495
+ <td>
496
+ <pre class="lines">
497
+
498
+
499
+ 245
500
+ 246
501
+ 247
502
+ 248
503
+ 249
504
+ 250
505
+ 251
506
+ 252
507
+ 253
508
+ 254
509
+ 255</pre>
510
+ </td>
511
+ <td>
512
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 245</span>
513
+
514
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_bytes'>from_bytes</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
515
+ <span class='id identifier rubyid_c_model'>c_model</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>MemoryPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:pointer</span><span class='rparen'>)</span>
516
+ <span class='id identifier rubyid_c_err'>c_err</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_model_from_bytes'>tangram_model_from_bytes</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='comma'>,</span> <span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span> <span class='id identifier rubyid_c_model'>c_model</span><span class='rparen'>)</span>
517
+ <span class='kw'>unless</span> <span class='id identifier rubyid_err'>err</span><span class='period'>.</span><span class='id identifier rubyid_null?'>null?</span>
518
+ <span class='id identifier rubyid_c_err'>c_err</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>AutoPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_err'>c_err</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:tangram_error_delete</span><span class='rparen'>)</span><span class='rparen'>)</span>
519
+ <span class='id identifier rubyid_c_error_s'>c_error_s</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="LibTangram/TangramStringView.html" title="Tangram::LibTangram::TangramStringView (class)">TangramStringView</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
520
+ <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_error_get_message'>tangram_error_get_message</span><span class='lparen'>(</span><span class='id identifier rubyid_c_err'>c_err</span><span class='comma'>,</span> <span class='id identifier rubyid_c_error_s'>c_error_s</span><span class='rparen'>)</span>
521
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_into_string'>into_string</span>
522
+ <span class='kw'>end</span>
523
+ <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_model'>c_model</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
524
+ <span class='kw'>end</span></pre>
525
+ </td>
526
+ </tr>
527
+ </table>
528
+ </div>
529
+
530
+ <div class="method_details ">
531
+ <h3 class="signature " id="from_path-class_method">
532
+
533
+ .<strong>from_path</strong>(path, options: nil) &#x21d2; <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
534
+
535
+
536
+
537
+
538
+
539
+ </h3><div class="docstring">
540
+ <div class="discussion">
541
+ <p>Load a model from the <code>.tangram</code> file at <code>path</code>.</p>
542
+
543
+
544
+ </div>
545
+ </div>
546
+ <div class="tags">
547
+ <p class="tag_title">Parameters:</p>
548
+ <ul class="param">
549
+
550
+ <li>
551
+
552
+ <span class='name'>path</span>
553
+
554
+
555
+ <span class='type'>(<tt>String</tt>)</span>
556
+
557
+
558
+
559
+ &mdash;
560
+ <div class='inline'><p>The path to the <code>.tangram</code> file.</p>
561
+ </div>
562
+
563
+ </li>
564
+
565
+ <li>
566
+
567
+ <span class='name'>options</span>
568
+
569
+
570
+ <span class='type'>(<tt><span class='object_link'><a href="LoadModelOptions.html" title="Tangram::LoadModelOptions (class)">LoadModelOptions</a></span></tt>)</span>
571
+
572
+
573
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
574
+
575
+
576
+ &mdash;
577
+ <div class='inline'><p>The options to use when loading the model.</p>
578
+ </div>
579
+
580
+ </li>
581
+
582
+ </ul>
583
+
584
+ <p class="tag_title">Returns:</p>
585
+ <ul class="return">
586
+
587
+ <li>
588
+
589
+
590
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>)</span>
591
+
592
+
593
+
594
+ </li>
595
+
596
+ </ul>
597
+
598
+ </div><table class="source_code">
599
+ <tr>
600
+ <td>
601
+ <pre class="lines">
602
+
603
+
604
+ 229
605
+ 230
606
+ 231
607
+ 232
608
+ 233
609
+ 234
610
+ 235
611
+ 236
612
+ 237
613
+ 238
614
+ 239</pre>
615
+ </td>
616
+ <td>
617
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 229</span>
618
+
619
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_path'>from_path</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
620
+ <span class='id identifier rubyid_c_model'>c_model</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>MemoryPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:pointer</span><span class='rparen'>)</span>
621
+ <span class='id identifier rubyid_c_err'>c_err</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_model_from_path'>tangram_model_from_path</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_c_model'>c_model</span><span class='rparen'>)</span>
622
+ <span class='kw'>unless</span> <span class='id identifier rubyid_c_err'>c_err</span><span class='period'>.</span><span class='id identifier rubyid_null?'>null?</span>
623
+ <span class='id identifier rubyid_c_err'>c_err</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>AutoPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_err'>c_err</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:tangram_error_delete</span><span class='rparen'>)</span><span class='rparen'>)</span>
624
+ <span class='id identifier rubyid_c_error_s'>c_error_s</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="LibTangram/TangramStringView.html" title="Tangram::LibTangram::TangramStringView (class)">TangramStringView</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
625
+ <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_error_get_message'>tangram_error_get_message</span><span class='lparen'>(</span><span class='id identifier rubyid_c_err'>c_err</span><span class='comma'>,</span> <span class='id identifier rubyid_c_error_s'>c_error_s</span><span class='rparen'>)</span>
626
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_c_error_s'>c_error_s</span><span class='period'>.</span><span class='id identifier rubyid_into_string'>into_string</span>
627
+ <span class='kw'>end</span>
628
+ <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_model'>c_model</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
629
+ <span class='kw'>end</span></pre>
630
+ </td>
631
+ </tr>
632
+ </table>
633
+ </div>
634
+
635
+ </div>
636
+
637
+ <div id="instance_method_details" class="method_details_list">
638
+ <h2>Instance Method Details</h2>
639
+
640
+
641
+ <div class="method_details first">
642
+ <h3 class="signature first" id="enqueue_log_prediction-instance_method">
643
+
644
+ #<strong>enqueue_log_prediction</strong>(identifier:, input:, output:, options: nil) &#x21d2; <tt>Object</tt>
645
+
646
+
647
+
648
+
649
+
650
+ </h3><div class="docstring">
651
+ <div class="discussion">
652
+ <p>Add a prediction event to the queue. Remember to call <code>flush_log_queue</code> at a later point to send the event to the app.</p>
653
+
654
+
655
+ </div>
656
+ </div>
657
+ <div class="tags">
658
+ <p class="tag_title">Parameters:</p>
659
+ <ul class="param">
660
+
661
+ <li>
662
+
663
+ <span class='name'>identifier</span>
664
+
665
+
666
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
667
+
668
+
669
+
670
+ &mdash;
671
+ <div class='inline'><p>This is a unique identifier for the prediction, which will associate it with a true value event and allow you to look it up in the app.</p>
672
+ </div>
673
+
674
+ </li>
675
+
676
+ <li>
677
+
678
+ <span class='name'>input</span>
679
+
680
+
681
+ <span class='type'>(<tt>Hash{String, Symbol =&gt; String, Number}</tt>)</span>
682
+
683
+
684
+
685
+ &mdash;
686
+ <div class='inline'><p>A single <code>PredictInput</code>.</p>
687
+ </div>
688
+
689
+ </li>
690
+
691
+ <li>
692
+
693
+ <span class='name'>output</span>
694
+
695
+
696
+ <span class='type'>(<tt>PredictOutput</tt>)</span>
697
+
698
+
699
+
700
+ &mdash;
701
+ <div class='inline'><p>A single <code>PredictOutput</code>.</p>
702
+ </div>
703
+
704
+ </li>
705
+
706
+ <li>
707
+
708
+ <span class='name'>options</span>
709
+
710
+
711
+ <span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
712
+
713
+
714
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
715
+
716
+
717
+ &mdash;
718
+ <div class='inline'><p>This is the same <code>predictOptions</code> value that you passed to <code>predict</code>.</p>
719
+ </div>
720
+
721
+ </li>
722
+
723
+ </ul>
724
+
725
+
726
+ </div><table class="source_code">
727
+ <tr>
728
+ <td>
729
+ <pre class="lines">
730
+
731
+
732
+ 307
733
+ 308
734
+ 309
735
+ 310
736
+ 311
737
+ 312
738
+ 313
739
+ 314
740
+ 315</pre>
741
+ </td>
742
+ <td>
743
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 307</span>
744
+
745
+ <span class='kw'>def</span> <span class='id identifier rubyid_enqueue_log_prediction'>enqueue_log_prediction</span><span class='lparen'>(</span><span class='label'>identifier:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='comma'>,</span> <span class='label'>output:</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
746
+ <span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='id identifier rubyid_prediction_event'>prediction_event</span><span class='lparen'>(</span>
747
+ <span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
748
+ <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span>
749
+ <span class='label'>output:</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span>
750
+ <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span>
751
+ <span class='rparen'>)</span>
752
+ <span class='id identifier rubyid_log_queue'>log_queue</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
753
+ <span class='kw'>end</span></pre>
754
+ </td>
755
+ </tr>
756
+ </table>
757
+ </div>
758
+
759
+ <div class="method_details ">
760
+ <h3 class="signature " id="enqueue_log_true_value-instance_method">
761
+
762
+ #<strong>enqueue_log_true_value</strong>(identifier:, true_value:) &#x21d2; <tt>Object</tt>
763
+
764
+
765
+
766
+
767
+
768
+ </h3><div class="docstring">
769
+ <div class="discussion">
770
+ <p>Add a true value event to the queue. Remember to call <code>flush_log_queue</code> at a later point to send the event to the app.</p>
771
+
772
+
773
+ </div>
774
+ </div>
775
+ <div class="tags">
776
+ <p class="tag_title">Parameters:</p>
777
+ <ul class="param">
778
+
779
+ <li>
780
+
781
+ <span class='name'>identifier</span>
782
+
783
+
784
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
785
+
786
+
787
+
788
+ &mdash;
789
+ <div class='inline'><p>This is a unique identifier for the prediction, which will associate it with a true value event and allow you to look it up in the app.</p>
790
+ </div>
791
+
792
+ </li>
793
+
794
+ <li>
795
+
796
+ <span class='name'>true_value</span>
797
+
798
+
799
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
800
+
801
+
802
+
803
+ &mdash;
804
+ <div class='inline'><p>This is the true value for the prediction.</p>
805
+ </div>
806
+
807
+ </li>
808
+
809
+ </ul>
810
+
811
+
812
+ </div><table class="source_code">
813
+ <tr>
814
+ <td>
815
+ <pre class="lines">
816
+
817
+
818
+ 331
819
+ 332
820
+ 333
821
+ 334
822
+ 335
823
+ 336
824
+ 337</pre>
825
+ </td>
826
+ <td>
827
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 331</span>
828
+
829
+ <span class='kw'>def</span> <span class='id identifier rubyid_enqueue_log_true_value'>enqueue_log_true_value</span><span class='lparen'>(</span><span class='label'>identifier:</span><span class='comma'>,</span> <span class='label'>true_value:</span><span class='rparen'>)</span>
830
+ <span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='id identifier rubyid_true_value_event'>true_value_event</span><span class='lparen'>(</span>
831
+ <span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
832
+ <span class='label'>true_value:</span> <span class='id identifier rubyid_true_value'>true_value</span>
833
+ <span class='rparen'>)</span>
834
+ <span class='id identifier rubyid_log_queue'>log_queue</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
835
+ <span class='kw'>end</span></pre>
836
+ </td>
837
+ </tr>
838
+ </table>
839
+ </div>
840
+
841
+ <div class="method_details ">
842
+ <h3 class="signature " id="flush_log_queue-instance_method">
843
+
844
+ #<strong>flush_log_queue</strong> &#x21d2; <tt>Object</tt>
845
+
846
+
847
+
848
+
849
+
850
+ </h3><div class="docstring">
851
+ <div class="discussion">
852
+ <p>Send all events in the queue to the app.</p>
853
+
854
+
855
+ </div>
856
+ </div>
857
+ <div class="tags">
858
+
859
+
860
+ </div><table class="source_code">
861
+ <tr>
862
+ <td>
863
+ <pre class="lines">
864
+
865
+
866
+ 340
867
+ 341
868
+ 342
869
+ 343</pre>
870
+ </td>
871
+ <td>
872
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 340</span>
873
+
874
+ <span class='kw'>def</span> <span class='id identifier rubyid_flush_log_queue'>flush_log_queue</span>
875
+ <span class='id identifier rubyid_log_events'>log_events</span><span class='lparen'>(</span><span class='ivar'>@log_queue</span><span class='rparen'>)</span>
876
+ <span class='ivar'>@log_queue</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
877
+ <span class='kw'>end</span></pre>
878
+ </td>
879
+ </tr>
880
+ </table>
881
+ </div>
882
+
883
+ <div class="method_details ">
884
+ <h3 class="signature " id="id-instance_method">
885
+
886
+ #<strong>id</strong> &#x21d2; <tt>Object</tt>
887
+
888
+
889
+
890
+
891
+
892
+ </h3><div class="docstring">
893
+ <div class="discussion">
894
+ <p>Retrieve the model&#39;s id.</p>
895
+
896
+
897
+ </div>
898
+ </div>
899
+ <div class="tags">
900
+
901
+
902
+ </div><table class="source_code">
903
+ <tr>
904
+ <td>
905
+ <pre class="lines">
906
+
907
+
908
+ 264
909
+ 265
910
+ 266
911
+ 267
912
+ 268</pre>
913
+ </td>
914
+ <td>
915
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 264</span>
916
+
917
+ <span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span>
918
+ <span class='id identifier rubyid_c_id'>c_id</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="LibTangram/TangramStringView.html" title="Tangram::LibTangram::TangramStringView (class)">TangramStringView</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
919
+ <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_model_get_id'>tangram_model_get_id</span><span class='lparen'>(</span><span class='ivar'>@model</span><span class='comma'>,</span> <span class='id identifier rubyid_c_id'>c_id</span><span class='rparen'>)</span>
920
+ <span class='id identifier rubyid_c_id'>c_id</span><span class='period'>.</span><span class='id identifier rubyid_into_string'>into_string</span>
921
+ <span class='kw'>end</span></pre>
922
+ </td>
923
+ </tr>
924
+ </table>
925
+ </div>
926
+
927
+ <div class="method_details ">
928
+ <h3 class="signature " id="log_prediction-instance_method">
929
+
930
+ #<strong>log_prediction</strong>(identifier:, input:, output:, options: nil) &#x21d2; <tt>Object</tt>
931
+
932
+
933
+
934
+
935
+
936
+ </h3><div class="docstring">
937
+ <div class="discussion">
938
+ <p>Send a prediction event to the app. If you want to batch events, you can use <code>enqueue_log_prediction</code> instead.</p>
939
+
940
+
941
+ </div>
942
+ </div>
943
+ <div class="tags">
944
+ <p class="tag_title">Parameters:</p>
945
+ <ul class="param">
946
+
947
+ <li>
948
+
949
+ <span class='name'>identifier</span>
950
+
951
+
952
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
953
+
954
+
955
+
956
+ &mdash;
957
+ <div class='inline'><p>This is a unique identifier for the prediction, which will associate it with a true value event and allow you to look it up in the app.</p>
958
+ </div>
959
+
960
+ </li>
961
+
962
+ <li>
963
+
964
+ <span class='name'>input</span>
965
+
966
+
967
+ <span class='type'>(<tt>Hash{String, Symbol =&gt; String, Number}</tt>)</span>
968
+
969
+
970
+
971
+ &mdash;
972
+ <div class='inline'><p>A single <code>PredictInput</code>.</p>
973
+ </div>
974
+
975
+ </li>
976
+
977
+ <li>
978
+
979
+ <span class='name'>output</span>
980
+
981
+
982
+ <span class='type'>(<tt>PredictOutput</tt>)</span>
983
+
984
+
985
+
986
+ &mdash;
987
+ <div class='inline'><p>A single <code>PredictOutput</code>.</p>
988
+ </div>
989
+
990
+ </li>
991
+
992
+ <li>
993
+
994
+ <span class='name'>options</span>
995
+
996
+
997
+ <span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
998
+
999
+
1000
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1001
+
1002
+
1003
+ &mdash;
1004
+ <div class='inline'><p>This is the same <code>predictOptions</code> value that you passed to <code>predict</code>.</p>
1005
+ </div>
1006
+
1007
+ </li>
1008
+
1009
+ </ul>
1010
+
1011
+
1012
+ </div><table class="source_code">
1013
+ <tr>
1014
+ <td>
1015
+ <pre class="lines">
1016
+
1017
+
1018
+ 292
1019
+ 293
1020
+ 294
1021
+ 295
1022
+ 296
1023
+ 297
1024
+ 298
1025
+ 299
1026
+ 300</pre>
1027
+ </td>
1028
+ <td>
1029
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 292</span>
1030
+
1031
+ <span class='kw'>def</span> <span class='id identifier rubyid_log_prediction'>log_prediction</span><span class='lparen'>(</span><span class='label'>identifier:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='comma'>,</span> <span class='label'>output:</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1032
+ <span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='id identifier rubyid_prediction_event'>prediction_event</span><span class='lparen'>(</span>
1033
+ <span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
1034
+ <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span>
1035
+ <span class='label'>output:</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span>
1036
+ <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span>
1037
+ <span class='rparen'>)</span>
1038
+ <span class='id identifier rubyid_log_event'>log_event</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
1039
+ <span class='kw'>end</span></pre>
1040
+ </td>
1041
+ </tr>
1042
+ </table>
1043
+ </div>
1044
+
1045
+ <div class="method_details ">
1046
+ <h3 class="signature " id="log_true_value-instance_method">
1047
+
1048
+ #<strong>log_true_value</strong>(identifier:, true_value:) &#x21d2; <tt>Object</tt>
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+ </h3><div class="docstring">
1055
+ <div class="discussion">
1056
+ <p>Send a true value event to the app. If you want to batch events, you can use <code>enqueue_log_true_value</code> instead.</p>
1057
+
1058
+
1059
+ </div>
1060
+ </div>
1061
+ <div class="tags">
1062
+ <p class="tag_title">Parameters:</p>
1063
+ <ul class="param">
1064
+
1065
+ <li>
1066
+
1067
+ <span class='name'>identifier</span>
1068
+
1069
+
1070
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
1071
+
1072
+
1073
+
1074
+ &mdash;
1075
+ <div class='inline'><p>This is a unique identifier for the prediction, which will associate it with a true value event and allow you to look it up in the app.</p>
1076
+ </div>
1077
+
1078
+ </li>
1079
+
1080
+ <li>
1081
+
1082
+ <span class='name'>true_value</span>
1083
+
1084
+
1085
+ <span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
1086
+
1087
+
1088
+
1089
+ &mdash;
1090
+ <div class='inline'><p>This is the true value for the prediction.</p>
1091
+ </div>
1092
+
1093
+ </li>
1094
+
1095
+ </ul>
1096
+
1097
+
1098
+ </div><table class="source_code">
1099
+ <tr>
1100
+ <td>
1101
+ <pre class="lines">
1102
+
1103
+
1104
+ 320
1105
+ 321
1106
+ 322
1107
+ 323
1108
+ 324
1109
+ 325
1110
+ 326</pre>
1111
+ </td>
1112
+ <td>
1113
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 320</span>
1114
+
1115
+ <span class='kw'>def</span> <span class='id identifier rubyid_log_true_value'>log_true_value</span><span class='lparen'>(</span><span class='label'>identifier:</span><span class='comma'>,</span> <span class='label'>true_value:</span><span class='rparen'>)</span>
1116
+ <span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='id identifier rubyid_true_value_event'>true_value_event</span><span class='lparen'>(</span>
1117
+ <span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
1118
+ <span class='label'>true_value:</span> <span class='id identifier rubyid_true_value'>true_value</span>
1119
+ <span class='rparen'>)</span>
1120
+ <span class='id identifier rubyid_log_event'>log_event</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
1121
+ <span class='kw'>end</span></pre>
1122
+ </td>
1123
+ </tr>
1124
+ </table>
1125
+ </div>
1126
+
1127
+ <div class="method_details ">
1128
+ <h3 class="signature " id="predict-instance_method">
1129
+
1130
+ #<strong>predict</strong>(input, options: nil) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="RegressionPredictOutput.html" title="Tangram::RegressionPredictOutput (class)">RegressionPredictOutput</a></span>, <span class='object_link'><a href="BinaryClassificationPredictOutput.html" title="Tangram::BinaryClassificationPredictOutput (class)">BinaryClassificationPredictOutput</a></span>, <span class='object_link'><a href="MulticlassClassificationPredictOutput.html" title="Tangram::MulticlassClassificationPredictOutput (class)">MulticlassClassificationPredictOutput</a></span>&gt;</tt>, ...
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+ </h3><div class="docstring">
1137
+ <div class="discussion">
1138
+ <p>Make a prediction!</p>
1139
+
1140
+
1141
+ </div>
1142
+ </div>
1143
+ <div class="tags">
1144
+ <p class="tag_title">Parameters:</p>
1145
+ <ul class="param">
1146
+
1147
+ <li>
1148
+
1149
+ <span class='name'>input</span>
1150
+
1151
+
1152
+ <span class='type'>(<tt>Array&lt;Hash{String, Symbol =&gt; String, Number}&gt;</tt>, <tt>Hash{String, Symbol =&gt; String, Number}</tt>)</span>
1153
+
1154
+
1155
+
1156
+ &mdash;
1157
+ <div class='inline'><p>A predict input is either a single predict input which is a map from symbols or strings to strings or floats or an array of such maps. The keys should match the columns in the CSV file you trained your model with.</p>
1158
+ </div>
1159
+
1160
+ </li>
1161
+
1162
+ <li>
1163
+
1164
+ <span class='name'>options</span>
1165
+
1166
+
1167
+ <span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
1168
+
1169
+
1170
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1171
+
1172
+
1173
+ &mdash;
1174
+ <div class='inline'><p>These are the predict options.</p>
1175
+ </div>
1176
+
1177
+ </li>
1178
+
1179
+ </ul>
1180
+
1181
+ <p class="tag_title">Returns:</p>
1182
+ <ul class="return">
1183
+
1184
+ <li>
1185
+
1186
+
1187
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="RegressionPredictOutput.html" title="Tangram::RegressionPredictOutput (class)">RegressionPredictOutput</a></span>, <span class='object_link'><a href="BinaryClassificationPredictOutput.html" title="Tangram::BinaryClassificationPredictOutput (class)">BinaryClassificationPredictOutput</a></span>, <span class='object_link'><a href="MulticlassClassificationPredictOutput.html" title="Tangram::MulticlassClassificationPredictOutput (class)">MulticlassClassificationPredictOutput</a></span>&gt;</tt>, <tt><span class='object_link'><a href="RegressionPredictOutput.html" title="Tangram::RegressionPredictOutput (class)">RegressionPredictOutput</a></span></tt>, <tt><span class='object_link'><a href="BinaryClassificationPredictOutput.html" title="Tangram::BinaryClassificationPredictOutput (class)">BinaryClassificationPredictOutput</a></span></tt>, <tt><span class='object_link'><a href="MulticlassClassificationPredictOutput.html" title="Tangram::MulticlassClassificationPredictOutput (class)">MulticlassClassificationPredictOutput</a></span></tt>)</span>
1188
+
1189
+
1190
+
1191
+ &mdash;
1192
+ <div class='inline'><p>. Return a single output if <code>input</code> was a single input, or an array if <code>input</code> was an array of <code>input</code>s.</p>
1193
+ </div>
1194
+
1195
+ </li>
1196
+
1197
+ </ul>
1198
+
1199
+ </div><table class="source_code">
1200
+ <tr>
1201
+ <td>
1202
+ <pre class="lines">
1203
+
1204
+
1205
+ 274
1206
+ 275
1207
+ 276
1208
+ 277
1209
+ 278
1210
+ 279
1211
+ 280
1212
+ 281
1213
+ 282
1214
+ 283
1215
+ 284
1216
+ 285</pre>
1217
+ </td>
1218
+ <td>
1219
+ <pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 274</span>
1220
+
1221
+ <span class='kw'>def</span> <span class='id identifier rubyid_predict'>predict</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1222
+ <span class='id identifier rubyid_is_array'>is_array</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
1223
+ <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='id identifier rubyid_is_array'>is_array</span> <span class='op'>?</span> <span class='id identifier rubyid_input'>input</span> <span class='op'>:</span> <span class='lbracket'>[</span><span class='id identifier rubyid_input'>input</span><span class='rbracket'>]</span>
1224
+ <span class='id identifier rubyid_c_input_vec'>c_input_vec</span> <span class='op'>=</span> <span class='id identifier rubyid_new_predict_input_vec'>new_predict_input_vec</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
1225
+ <span class='id identifier rubyid_c_options'>c_options</span> <span class='op'>=</span> <span class='id identifier rubyid_new_predict_options'>new_predict_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1226
+ <span class='id identifier rubyid_c_output_vec'>c_output_vec</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>MemoryPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:pointer</span><span class='rparen'>)</span>
1227
+ <span class='id identifier rubyid_c_error'>c_error</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tangram_model_predict'>tangram_model_predict</span><span class='lparen'>(</span><span class='ivar'>@model</span><span class='comma'>,</span> <span class='id identifier rubyid_c_input_vec'>c_input_vec</span><span class='comma'>,</span> <span class='id identifier rubyid_c_options'>c_options</span><span class='comma'>,</span> <span class='id identifier rubyid_c_output_vec'>c_output_vec</span><span class='rparen'>)</span>
1228
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>tangram error</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_c_error'>c_error</span><span class='period'>.</span><span class='id identifier rubyid_null?'>null?</span>
1229
+ <span class='id identifier rubyid_c_output_vec'>c_output_vec</span> <span class='op'>=</span> <span class='const'>FFI</span><span class='op'>::</span><span class='const'>AutoPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_c_output_vec'>c_output_vec</span><span class='period'>.</span><span class='id identifier rubyid_read_pointer'>read_pointer</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="LibTangram.html" title="Tangram::LibTangram (module)">LibTangram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:tangram_predict_output_vec_delete</span><span class='rparen'>)</span><span class='rparen'>)</span>
1230
+ <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='id identifier rubyid_predict_output_vec_from_tangram_predict_output_vec'>predict_output_vec_from_tangram_predict_output_vec</span><span class='lparen'>(</span><span class='id identifier rubyid_c_output_vec'>c_output_vec</span><span class='rparen'>)</span>
1231
+ <span class='id identifier rubyid_is_array'>is_array</span> <span class='op'>?</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>:</span> <span class='id identifier rubyid_output'>output</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
1232
+ <span class='kw'>end</span></pre>
1233
+ </td>
1234
+ </tr>
1235
+ </table>
1236
+ </div>
1237
+
1238
+ </div>
1239
+
1240
+ </div>
1241
+
1242
+ <div id="footer">
1243
+ Generated on Thu Jul 15 14:34:34 2021 by
1244
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1245
+ 0.9.26 (ruby-2.7.3).
1246
+ </div>
1247
+
1248
+ </div>
1249
+ </body>
1250
+ </html>