modelfox 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +15 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/docs/Tangram/BagOfWordsCosineSimilarityFeatureContribution.html +518 -0
- data/docs/Tangram/BagOfWordsFeatureContribution.html +518 -0
- data/docs/Tangram/Bigram.html +370 -0
- data/docs/Tangram/BinaryClassificationPredictOutput.html +502 -0
- data/docs/Tangram/FeatureContributions.html +444 -0
- data/docs/Tangram/IdentityFeatureContribution.html +444 -0
- data/docs/Tangram/LibTangram/TangramStringView.html +193 -0
- data/docs/Tangram/LibTangram.html +161 -0
- data/docs/Tangram/LoadModelOptions.html +296 -0
- data/docs/Tangram/Model.html +1290 -0
- data/docs/Tangram/MulticlassClassificationPredictOutput.html +576 -0
- data/docs/Tangram/NormalizedFeatureContribution.html +444 -0
- data/docs/Tangram/OneHotEncodedFeatureContribution.html +518 -0
- data/docs/Tangram/PredictOptions.html +428 -0
- data/docs/Tangram/RegressionPredictOutput.html +428 -0
- data/docs/Tangram/Unigram.html +296 -0
- data/docs/Tangram/WordEmbeddingFeatureContribution.html +444 -0
- data/docs/Tangram.html +128 -0
- data/docs/_index.html +317 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.README.html +107 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +107 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +595 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/modelfox/libmodelfox/aarch64-linux-gnu/libmodelfox.so +0 -0
- data/lib/modelfox/libmodelfox/aarch64-linux-musl/libmodelfox.so +0 -0
- data/lib/modelfox/libmodelfox/aarch64-macos/libmodelfox.dylib +0 -0
- data/lib/modelfox/libmodelfox/x86_64-linux-gnu/libmodelfox.so +0 -0
- data/lib/modelfox/libmodelfox/x86_64-linux-musl/libmodelfox.so +0 -0
- data/lib/modelfox/libmodelfox/x86_64-macos/libmodelfox.dylib +0 -0
- data/lib/modelfox/libmodelfox/x86_64-windows-msvc/modelfox.dll +0 -0
- data/lib/modelfox/modelfox.rb +895 -0
- data/lib/modelfox.rb +1 -0
- data/modelfox.gemspec +15 -0
- data/scripts/build +11 -0
- data/scripts/dev +6 -0
- data/scripts/docs +2 -0
- data/scripts/fmt +0 -0
- data/scripts/release +1 -0
- metadata +109 -0
@@ -0,0 +1,1290 @@
|
|
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
|
+
— 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> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Tangram.html" title="Tangram (module)">Tangram</a></span></span>
|
41
|
+
»
|
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
|
+
|
105
|
+
<p>Use this class to load a model, make predictions, and log events to the app.</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Class Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#from_bytes-class_method" title="from_bytes (class method)">.<strong>from_bytes</strong>(bytes, options: nil) ⇒ Model </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'>
|
146
|
+
<p>Load a model from bytes instead of a file.</p>
|
147
|
+
</div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
<li class="public ">
|
153
|
+
<span class="summary_signature">
|
154
|
+
|
155
|
+
<a href="#from_path-class_method" title="from_path (class method)">.<strong>from_path</strong>(path, options: nil) ⇒ Model </a>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
</span>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<span class="summary_desc"><div class='inline'>
|
170
|
+
<p>Load a model from the <code>.tangram</code> file at <code>path</code>.</p>
|
171
|
+
</div></span>
|
172
|
+
|
173
|
+
</li>
|
174
|
+
|
175
|
+
|
176
|
+
</ul>
|
177
|
+
|
178
|
+
<h2>
|
179
|
+
Instance Method Summary
|
180
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
181
|
+
</h2>
|
182
|
+
|
183
|
+
<ul class="summary">
|
184
|
+
|
185
|
+
<li class="public ">
|
186
|
+
<span class="summary_signature">
|
187
|
+
|
188
|
+
<a href="#enqueue_log_prediction-instance_method" title="#enqueue_log_prediction (instance method)">#<strong>enqueue_log_prediction</strong>(identifier:, input:, output:, options: nil) ⇒ Object </a>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
</span>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
<span class="summary_desc"><div class='inline'>
|
203
|
+
<p>Add a prediction event to the queue.</p>
|
204
|
+
</div></span>
|
205
|
+
|
206
|
+
</li>
|
207
|
+
|
208
|
+
|
209
|
+
<li class="public ">
|
210
|
+
<span class="summary_signature">
|
211
|
+
|
212
|
+
<a href="#enqueue_log_true_value-instance_method" title="#enqueue_log_true_value (instance method)">#<strong>enqueue_log_true_value</strong>(identifier:, true_value:) ⇒ Object </a>
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
</span>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
<span class="summary_desc"><div class='inline'>
|
227
|
+
<p>Add a true value event to the queue.</p>
|
228
|
+
</div></span>
|
229
|
+
|
230
|
+
</li>
|
231
|
+
|
232
|
+
|
233
|
+
<li class="public ">
|
234
|
+
<span class="summary_signature">
|
235
|
+
|
236
|
+
<a href="#flush_log_queue-instance_method" title="#flush_log_queue (instance method)">#<strong>flush_log_queue</strong> ⇒ Object </a>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
</span>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
<span class="summary_desc"><div class='inline'>
|
251
|
+
<p>Send all events in the queue to the app.</p>
|
252
|
+
</div></span>
|
253
|
+
|
254
|
+
</li>
|
255
|
+
|
256
|
+
|
257
|
+
<li class="public ">
|
258
|
+
<span class="summary_signature">
|
259
|
+
|
260
|
+
<a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ Object </a>
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
</span>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
<span class="summary_desc"><div class='inline'>
|
275
|
+
<p>Retrieve the model's id.</p>
|
276
|
+
</div></span>
|
277
|
+
|
278
|
+
</li>
|
279
|
+
|
280
|
+
|
281
|
+
<li class="public ">
|
282
|
+
<span class="summary_signature">
|
283
|
+
|
284
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(c_model, options: nil) ⇒ Model </a>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
</span>
|
289
|
+
|
290
|
+
|
291
|
+
<span class="note title constructor">constructor</span>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
<span class="summary_desc"><div class='inline'>
|
301
|
+
<p>A new instance of Model.</p>
|
302
|
+
</div></span>
|
303
|
+
|
304
|
+
</li>
|
305
|
+
|
306
|
+
|
307
|
+
<li class="public ">
|
308
|
+
<span class="summary_signature">
|
309
|
+
|
310
|
+
<a href="#log_prediction-instance_method" title="#log_prediction (instance method)">#<strong>log_prediction</strong>(identifier:, input:, output:, options: nil) ⇒ Object </a>
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
</span>
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
<span class="summary_desc"><div class='inline'>
|
325
|
+
<p>Send a prediction event to the app.</p>
|
326
|
+
</div></span>
|
327
|
+
|
328
|
+
</li>
|
329
|
+
|
330
|
+
|
331
|
+
<li class="public ">
|
332
|
+
<span class="summary_signature">
|
333
|
+
|
334
|
+
<a href="#log_true_value-instance_method" title="#log_true_value (instance method)">#<strong>log_true_value</strong>(identifier:, true_value:) ⇒ Object </a>
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
</span>
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
<span class="summary_desc"><div class='inline'>
|
349
|
+
<p>Send a true value event to the app.</p>
|
350
|
+
</div></span>
|
351
|
+
|
352
|
+
</li>
|
353
|
+
|
354
|
+
|
355
|
+
<li class="public ">
|
356
|
+
<span class="summary_signature">
|
357
|
+
|
358
|
+
<a href="#predict-instance_method" title="#predict (instance method)">#<strong>predict</strong>(input, options: nil) ⇒ Array<RegressionPredictOutput, BinaryClassificationPredictOutput, MulticlassClassificationPredictOutput>, ... </a>
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
</span>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
<span class="summary_desc"><div class='inline'>
|
373
|
+
<p>Make a prediction!.</p>
|
374
|
+
</div></span>
|
375
|
+
|
376
|
+
</li>
|
377
|
+
|
378
|
+
|
379
|
+
</ul>
|
380
|
+
|
381
|
+
|
382
|
+
<div id="constructor_details" class="method_details_list">
|
383
|
+
<h2>Constructor Details</h2>
|
384
|
+
|
385
|
+
<div class="method_details first">
|
386
|
+
<h3 class="signature first" id="initialize-instance_method">
|
387
|
+
|
388
|
+
#<strong>initialize</strong>(c_model, options: nil) ⇒ <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
</h3><div class="docstring">
|
395
|
+
<div class="discussion">
|
396
|
+
|
397
|
+
<p>Returns a new instance of Model.</p>
|
398
|
+
|
399
|
+
|
400
|
+
</div>
|
401
|
+
</div>
|
402
|
+
<div class="tags">
|
403
|
+
|
404
|
+
|
405
|
+
</div><table class="source_code">
|
406
|
+
<tr>
|
407
|
+
<td>
|
408
|
+
<pre class="lines">
|
409
|
+
|
410
|
+
|
411
|
+
257
|
412
|
+
258
|
413
|
+
259
|
414
|
+
260
|
415
|
+
261</pre>
|
416
|
+
</td>
|
417
|
+
<td>
|
418
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 257</span>
|
419
|
+
|
420
|
+
<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>
|
421
|
+
<span class='ivar'>@tangram_url</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='op'>&.</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'>'</span><span class='tstring_content'>https://app.tangram.dev</span><span class='tstring_end'>'</span></span> <span class='op'>:</span> <span class='id identifier rubyid_options'>options</span><span class='op'>&.</span><span class='id identifier rubyid_tangram_url'>tangram_url</span>
|
422
|
+
<span class='ivar'>@log_queue</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
423
|
+
<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>
|
424
|
+
<span class='kw'>end</span></pre>
|
425
|
+
</td>
|
426
|
+
</tr>
|
427
|
+
</table>
|
428
|
+
</div>
|
429
|
+
|
430
|
+
</div>
|
431
|
+
|
432
|
+
|
433
|
+
<div id="class_method_details" class="method_details_list">
|
434
|
+
<h2>Class Method Details</h2>
|
435
|
+
|
436
|
+
|
437
|
+
<div class="method_details first">
|
438
|
+
<h3 class="signature first" id="from_bytes-class_method">
|
439
|
+
|
440
|
+
.<strong>from_bytes</strong>(bytes, options: nil) ⇒ <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
</h3><div class="docstring">
|
447
|
+
<div class="discussion">
|
448
|
+
|
449
|
+
<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>
|
450
|
+
|
451
|
+
|
452
|
+
</div>
|
453
|
+
</div>
|
454
|
+
<div class="tags">
|
455
|
+
<p class="tag_title">Parameters:</p>
|
456
|
+
<ul class="param">
|
457
|
+
|
458
|
+
<li>
|
459
|
+
|
460
|
+
<span class='name'>bytes</span>
|
461
|
+
|
462
|
+
|
463
|
+
<span class='type'>(<tt>String</tt>)</span>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
—
|
468
|
+
<div class='inline'>
|
469
|
+
<p>The bytes for the .tangram model.</p>
|
470
|
+
</div>
|
471
|
+
|
472
|
+
</li>
|
473
|
+
|
474
|
+
<li>
|
475
|
+
|
476
|
+
<span class='name'>options</span>
|
477
|
+
|
478
|
+
|
479
|
+
<span class='type'>(<tt><span class='object_link'><a href="LoadModelOptions.html" title="Tangram::LoadModelOptions (class)">LoadModelOptions</a></span></tt>)</span>
|
480
|
+
|
481
|
+
|
482
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
483
|
+
|
484
|
+
|
485
|
+
—
|
486
|
+
<div class='inline'>
|
487
|
+
<p>The options to use when loading the model.</p>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
</li>
|
491
|
+
|
492
|
+
</ul>
|
493
|
+
|
494
|
+
<p class="tag_title">Returns:</p>
|
495
|
+
<ul class="return">
|
496
|
+
|
497
|
+
<li>
|
498
|
+
|
499
|
+
|
500
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>)</span>
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
</li>
|
505
|
+
|
506
|
+
</ul>
|
507
|
+
|
508
|
+
</div><table class="source_code">
|
509
|
+
<tr>
|
510
|
+
<td>
|
511
|
+
<pre class="lines">
|
512
|
+
|
513
|
+
|
514
|
+
245
|
515
|
+
246
|
516
|
+
247
|
517
|
+
248
|
518
|
+
249
|
519
|
+
250
|
520
|
+
251
|
521
|
+
252
|
522
|
+
253
|
523
|
+
254
|
524
|
+
255</pre>
|
525
|
+
</td>
|
526
|
+
<td>
|
527
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 245</span>
|
528
|
+
|
529
|
+
<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>
|
530
|
+
<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>
|
531
|
+
<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>
|
532
|
+
<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>
|
533
|
+
<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>
|
534
|
+
<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>
|
535
|
+
<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>
|
536
|
+
<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>
|
537
|
+
<span class='kw'>end</span>
|
538
|
+
<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>
|
539
|
+
<span class='kw'>end</span></pre>
|
540
|
+
</td>
|
541
|
+
</tr>
|
542
|
+
</table>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
<div class="method_details ">
|
546
|
+
<h3 class="signature " id="from_path-class_method">
|
547
|
+
|
548
|
+
.<strong>from_path</strong>(path, options: nil) ⇒ <tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
</h3><div class="docstring">
|
555
|
+
<div class="discussion">
|
556
|
+
|
557
|
+
<p>Load a model from the <code>.tangram</code> file at <code>path</code>.</p>
|
558
|
+
|
559
|
+
|
560
|
+
</div>
|
561
|
+
</div>
|
562
|
+
<div class="tags">
|
563
|
+
<p class="tag_title">Parameters:</p>
|
564
|
+
<ul class="param">
|
565
|
+
|
566
|
+
<li>
|
567
|
+
|
568
|
+
<span class='name'>path</span>
|
569
|
+
|
570
|
+
|
571
|
+
<span class='type'>(<tt>String</tt>)</span>
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
—
|
576
|
+
<div class='inline'>
|
577
|
+
<p>The path to the <code>.tangram</code> file.</p>
|
578
|
+
</div>
|
579
|
+
|
580
|
+
</li>
|
581
|
+
|
582
|
+
<li>
|
583
|
+
|
584
|
+
<span class='name'>options</span>
|
585
|
+
|
586
|
+
|
587
|
+
<span class='type'>(<tt><span class='object_link'><a href="LoadModelOptions.html" title="Tangram::LoadModelOptions (class)">LoadModelOptions</a></span></tt>)</span>
|
588
|
+
|
589
|
+
|
590
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
591
|
+
|
592
|
+
|
593
|
+
—
|
594
|
+
<div class='inline'>
|
595
|
+
<p>The options to use when loading the model.</p>
|
596
|
+
</div>
|
597
|
+
|
598
|
+
</li>
|
599
|
+
|
600
|
+
</ul>
|
601
|
+
|
602
|
+
<p class="tag_title">Returns:</p>
|
603
|
+
<ul class="return">
|
604
|
+
|
605
|
+
<li>
|
606
|
+
|
607
|
+
|
608
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Tangram::Model (class)">Model</a></span></tt>)</span>
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
</li>
|
613
|
+
|
614
|
+
</ul>
|
615
|
+
|
616
|
+
</div><table class="source_code">
|
617
|
+
<tr>
|
618
|
+
<td>
|
619
|
+
<pre class="lines">
|
620
|
+
|
621
|
+
|
622
|
+
229
|
623
|
+
230
|
624
|
+
231
|
625
|
+
232
|
626
|
+
233
|
627
|
+
234
|
628
|
+
235
|
629
|
+
236
|
630
|
+
237
|
631
|
+
238
|
632
|
+
239</pre>
|
633
|
+
</td>
|
634
|
+
<td>
|
635
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 229</span>
|
636
|
+
|
637
|
+
<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>
|
638
|
+
<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>
|
639
|
+
<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>
|
640
|
+
<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>
|
641
|
+
<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>
|
642
|
+
<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>
|
643
|
+
<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>
|
644
|
+
<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>
|
645
|
+
<span class='kw'>end</span>
|
646
|
+
<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>
|
647
|
+
<span class='kw'>end</span></pre>
|
648
|
+
</td>
|
649
|
+
</tr>
|
650
|
+
</table>
|
651
|
+
</div>
|
652
|
+
|
653
|
+
</div>
|
654
|
+
|
655
|
+
<div id="instance_method_details" class="method_details_list">
|
656
|
+
<h2>Instance Method Details</h2>
|
657
|
+
|
658
|
+
|
659
|
+
<div class="method_details first">
|
660
|
+
<h3 class="signature first" id="enqueue_log_prediction-instance_method">
|
661
|
+
|
662
|
+
#<strong>enqueue_log_prediction</strong>(identifier:, input:, output:, options: nil) ⇒ <tt>Object</tt>
|
663
|
+
|
664
|
+
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
</h3><div class="docstring">
|
669
|
+
<div class="discussion">
|
670
|
+
|
671
|
+
<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>
|
672
|
+
|
673
|
+
|
674
|
+
</div>
|
675
|
+
</div>
|
676
|
+
<div class="tags">
|
677
|
+
<p class="tag_title">Parameters:</p>
|
678
|
+
<ul class="param">
|
679
|
+
|
680
|
+
<li>
|
681
|
+
|
682
|
+
<span class='name'>identifier</span>
|
683
|
+
|
684
|
+
|
685
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
—
|
690
|
+
<div class='inline'>
|
691
|
+
<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>
|
692
|
+
</div>
|
693
|
+
|
694
|
+
</li>
|
695
|
+
|
696
|
+
<li>
|
697
|
+
|
698
|
+
<span class='name'>input</span>
|
699
|
+
|
700
|
+
|
701
|
+
<span class='type'>(<tt>Hash{String, Symbol => String, Number}</tt>)</span>
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
—
|
706
|
+
<div class='inline'>
|
707
|
+
<p>A single <code>PredictInput</code>.</p>
|
708
|
+
</div>
|
709
|
+
|
710
|
+
</li>
|
711
|
+
|
712
|
+
<li>
|
713
|
+
|
714
|
+
<span class='name'>output</span>
|
715
|
+
|
716
|
+
|
717
|
+
<span class='type'>(<tt>PredictOutput</tt>)</span>
|
718
|
+
|
719
|
+
|
720
|
+
|
721
|
+
—
|
722
|
+
<div class='inline'>
|
723
|
+
<p>A single <code>PredictOutput</code>.</p>
|
724
|
+
</div>
|
725
|
+
|
726
|
+
</li>
|
727
|
+
|
728
|
+
<li>
|
729
|
+
|
730
|
+
<span class='name'>options</span>
|
731
|
+
|
732
|
+
|
733
|
+
<span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
|
734
|
+
|
735
|
+
|
736
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
737
|
+
|
738
|
+
|
739
|
+
—
|
740
|
+
<div class='inline'>
|
741
|
+
<p>This is the same <code>predictOptions</code> value that you passed to <code>predict</code>.</p>
|
742
|
+
</div>
|
743
|
+
|
744
|
+
</li>
|
745
|
+
|
746
|
+
</ul>
|
747
|
+
|
748
|
+
|
749
|
+
</div><table class="source_code">
|
750
|
+
<tr>
|
751
|
+
<td>
|
752
|
+
<pre class="lines">
|
753
|
+
|
754
|
+
|
755
|
+
307
|
756
|
+
308
|
757
|
+
309
|
758
|
+
310
|
759
|
+
311
|
760
|
+
312
|
761
|
+
313
|
762
|
+
314
|
763
|
+
315</pre>
|
764
|
+
</td>
|
765
|
+
<td>
|
766
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 307</span>
|
767
|
+
|
768
|
+
<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>
|
769
|
+
<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>
|
770
|
+
<span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
|
771
|
+
<span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span>
|
772
|
+
<span class='label'>output:</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span>
|
773
|
+
<span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span>
|
774
|
+
<span class='rparen'>)</span>
|
775
|
+
<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>
|
776
|
+
<span class='kw'>end</span></pre>
|
777
|
+
</td>
|
778
|
+
</tr>
|
779
|
+
</table>
|
780
|
+
</div>
|
781
|
+
|
782
|
+
<div class="method_details ">
|
783
|
+
<h3 class="signature " id="enqueue_log_true_value-instance_method">
|
784
|
+
|
785
|
+
#<strong>enqueue_log_true_value</strong>(identifier:, true_value:) ⇒ <tt>Object</tt>
|
786
|
+
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
</h3><div class="docstring">
|
792
|
+
<div class="discussion">
|
793
|
+
|
794
|
+
<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>
|
795
|
+
|
796
|
+
|
797
|
+
</div>
|
798
|
+
</div>
|
799
|
+
<div class="tags">
|
800
|
+
<p class="tag_title">Parameters:</p>
|
801
|
+
<ul class="param">
|
802
|
+
|
803
|
+
<li>
|
804
|
+
|
805
|
+
<span class='name'>identifier</span>
|
806
|
+
|
807
|
+
|
808
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
809
|
+
|
810
|
+
|
811
|
+
|
812
|
+
—
|
813
|
+
<div class='inline'>
|
814
|
+
<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>
|
815
|
+
</div>
|
816
|
+
|
817
|
+
</li>
|
818
|
+
|
819
|
+
<li>
|
820
|
+
|
821
|
+
<span class='name'>true_value</span>
|
822
|
+
|
823
|
+
|
824
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
—
|
829
|
+
<div class='inline'>
|
830
|
+
<p>This is the true value for the prediction.</p>
|
831
|
+
</div>
|
832
|
+
|
833
|
+
</li>
|
834
|
+
|
835
|
+
</ul>
|
836
|
+
|
837
|
+
|
838
|
+
</div><table class="source_code">
|
839
|
+
<tr>
|
840
|
+
<td>
|
841
|
+
<pre class="lines">
|
842
|
+
|
843
|
+
|
844
|
+
331
|
845
|
+
332
|
846
|
+
333
|
847
|
+
334
|
848
|
+
335
|
849
|
+
336
|
850
|
+
337</pre>
|
851
|
+
</td>
|
852
|
+
<td>
|
853
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 331</span>
|
854
|
+
|
855
|
+
<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>
|
856
|
+
<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>
|
857
|
+
<span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
|
858
|
+
<span class='label'>true_value:</span> <span class='id identifier rubyid_true_value'>true_value</span>
|
859
|
+
<span class='rparen'>)</span>
|
860
|
+
<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>
|
861
|
+
<span class='kw'>end</span></pre>
|
862
|
+
</td>
|
863
|
+
</tr>
|
864
|
+
</table>
|
865
|
+
</div>
|
866
|
+
|
867
|
+
<div class="method_details ">
|
868
|
+
<h3 class="signature " id="flush_log_queue-instance_method">
|
869
|
+
|
870
|
+
#<strong>flush_log_queue</strong> ⇒ <tt>Object</tt>
|
871
|
+
|
872
|
+
|
873
|
+
|
874
|
+
|
875
|
+
|
876
|
+
</h3><div class="docstring">
|
877
|
+
<div class="discussion">
|
878
|
+
|
879
|
+
<p>Send all events in the queue to the app.</p>
|
880
|
+
|
881
|
+
|
882
|
+
</div>
|
883
|
+
</div>
|
884
|
+
<div class="tags">
|
885
|
+
|
886
|
+
|
887
|
+
</div><table class="source_code">
|
888
|
+
<tr>
|
889
|
+
<td>
|
890
|
+
<pre class="lines">
|
891
|
+
|
892
|
+
|
893
|
+
340
|
894
|
+
341
|
895
|
+
342
|
896
|
+
343</pre>
|
897
|
+
</td>
|
898
|
+
<td>
|
899
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 340</span>
|
900
|
+
|
901
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_flush_log_queue'>flush_log_queue</span>
|
902
|
+
<span class='id identifier rubyid_log_events'>log_events</span><span class='lparen'>(</span><span class='ivar'>@log_queue</span><span class='rparen'>)</span>
|
903
|
+
<span class='ivar'>@log_queue</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
904
|
+
<span class='kw'>end</span></pre>
|
905
|
+
</td>
|
906
|
+
</tr>
|
907
|
+
</table>
|
908
|
+
</div>
|
909
|
+
|
910
|
+
<div class="method_details ">
|
911
|
+
<h3 class="signature " id="id-instance_method">
|
912
|
+
|
913
|
+
#<strong>id</strong> ⇒ <tt>Object</tt>
|
914
|
+
|
915
|
+
|
916
|
+
|
917
|
+
|
918
|
+
|
919
|
+
</h3><div class="docstring">
|
920
|
+
<div class="discussion">
|
921
|
+
|
922
|
+
<p>Retrieve the model's id.</p>
|
923
|
+
|
924
|
+
|
925
|
+
</div>
|
926
|
+
</div>
|
927
|
+
<div class="tags">
|
928
|
+
|
929
|
+
|
930
|
+
</div><table class="source_code">
|
931
|
+
<tr>
|
932
|
+
<td>
|
933
|
+
<pre class="lines">
|
934
|
+
|
935
|
+
|
936
|
+
264
|
937
|
+
265
|
938
|
+
266
|
939
|
+
267
|
940
|
+
268</pre>
|
941
|
+
</td>
|
942
|
+
<td>
|
943
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 264</span>
|
944
|
+
|
945
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span>
|
946
|
+
<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>
|
947
|
+
<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>
|
948
|
+
<span class='id identifier rubyid_c_id'>c_id</span><span class='period'>.</span><span class='id identifier rubyid_into_string'>into_string</span>
|
949
|
+
<span class='kw'>end</span></pre>
|
950
|
+
</td>
|
951
|
+
</tr>
|
952
|
+
</table>
|
953
|
+
</div>
|
954
|
+
|
955
|
+
<div class="method_details ">
|
956
|
+
<h3 class="signature " id="log_prediction-instance_method">
|
957
|
+
|
958
|
+
#<strong>log_prediction</strong>(identifier:, input:, output:, options: nil) ⇒ <tt>Object</tt>
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
|
964
|
+
</h3><div class="docstring">
|
965
|
+
<div class="discussion">
|
966
|
+
|
967
|
+
<p>Send a prediction event to the app. If you want to batch events, you can use <code>enqueue_log_prediction</code> instead.</p>
|
968
|
+
|
969
|
+
|
970
|
+
</div>
|
971
|
+
</div>
|
972
|
+
<div class="tags">
|
973
|
+
<p class="tag_title">Parameters:</p>
|
974
|
+
<ul class="param">
|
975
|
+
|
976
|
+
<li>
|
977
|
+
|
978
|
+
<span class='name'>identifier</span>
|
979
|
+
|
980
|
+
|
981
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
982
|
+
|
983
|
+
|
984
|
+
|
985
|
+
—
|
986
|
+
<div class='inline'>
|
987
|
+
<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>
|
988
|
+
</div>
|
989
|
+
|
990
|
+
</li>
|
991
|
+
|
992
|
+
<li>
|
993
|
+
|
994
|
+
<span class='name'>input</span>
|
995
|
+
|
996
|
+
|
997
|
+
<span class='type'>(<tt>Hash{String, Symbol => String, Number}</tt>)</span>
|
998
|
+
|
999
|
+
|
1000
|
+
|
1001
|
+
—
|
1002
|
+
<div class='inline'>
|
1003
|
+
<p>A single <code>PredictInput</code>.</p>
|
1004
|
+
</div>
|
1005
|
+
|
1006
|
+
</li>
|
1007
|
+
|
1008
|
+
<li>
|
1009
|
+
|
1010
|
+
<span class='name'>output</span>
|
1011
|
+
|
1012
|
+
|
1013
|
+
<span class='type'>(<tt>PredictOutput</tt>)</span>
|
1014
|
+
|
1015
|
+
|
1016
|
+
|
1017
|
+
—
|
1018
|
+
<div class='inline'>
|
1019
|
+
<p>A single <code>PredictOutput</code>.</p>
|
1020
|
+
</div>
|
1021
|
+
|
1022
|
+
</li>
|
1023
|
+
|
1024
|
+
<li>
|
1025
|
+
|
1026
|
+
<span class='name'>options</span>
|
1027
|
+
|
1028
|
+
|
1029
|
+
<span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
|
1030
|
+
|
1031
|
+
|
1032
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1033
|
+
|
1034
|
+
|
1035
|
+
—
|
1036
|
+
<div class='inline'>
|
1037
|
+
<p>This is the same <code>predictOptions</code> value that you passed to <code>predict</code>.</p>
|
1038
|
+
</div>
|
1039
|
+
|
1040
|
+
</li>
|
1041
|
+
|
1042
|
+
</ul>
|
1043
|
+
|
1044
|
+
|
1045
|
+
</div><table class="source_code">
|
1046
|
+
<tr>
|
1047
|
+
<td>
|
1048
|
+
<pre class="lines">
|
1049
|
+
|
1050
|
+
|
1051
|
+
292
|
1052
|
+
293
|
1053
|
+
294
|
1054
|
+
295
|
1055
|
+
296
|
1056
|
+
297
|
1057
|
+
298
|
1058
|
+
299
|
1059
|
+
300</pre>
|
1060
|
+
</td>
|
1061
|
+
<td>
|
1062
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 292</span>
|
1063
|
+
|
1064
|
+
<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>
|
1065
|
+
<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>
|
1066
|
+
<span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
|
1067
|
+
<span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span>
|
1068
|
+
<span class='label'>output:</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span>
|
1069
|
+
<span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span>
|
1070
|
+
<span class='rparen'>)</span>
|
1071
|
+
<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>
|
1072
|
+
<span class='kw'>end</span></pre>
|
1073
|
+
</td>
|
1074
|
+
</tr>
|
1075
|
+
</table>
|
1076
|
+
</div>
|
1077
|
+
|
1078
|
+
<div class="method_details ">
|
1079
|
+
<h3 class="signature " id="log_true_value-instance_method">
|
1080
|
+
|
1081
|
+
#<strong>log_true_value</strong>(identifier:, true_value:) ⇒ <tt>Object</tt>
|
1082
|
+
|
1083
|
+
|
1084
|
+
|
1085
|
+
|
1086
|
+
|
1087
|
+
</h3><div class="docstring">
|
1088
|
+
<div class="discussion">
|
1089
|
+
|
1090
|
+
<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>
|
1091
|
+
|
1092
|
+
|
1093
|
+
</div>
|
1094
|
+
</div>
|
1095
|
+
<div class="tags">
|
1096
|
+
<p class="tag_title">Parameters:</p>
|
1097
|
+
<ul class="param">
|
1098
|
+
|
1099
|
+
<li>
|
1100
|
+
|
1101
|
+
<span class='name'>identifier</span>
|
1102
|
+
|
1103
|
+
|
1104
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
—
|
1109
|
+
<div class='inline'>
|
1110
|
+
<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>
|
1111
|
+
</div>
|
1112
|
+
|
1113
|
+
</li>
|
1114
|
+
|
1115
|
+
<li>
|
1116
|
+
|
1117
|
+
<span class='name'>true_value</span>
|
1118
|
+
|
1119
|
+
|
1120
|
+
<span class='type'>(<tt>String</tt>, <tt>Number</tt>)</span>
|
1121
|
+
|
1122
|
+
|
1123
|
+
|
1124
|
+
—
|
1125
|
+
<div class='inline'>
|
1126
|
+
<p>This is the true value for the prediction.</p>
|
1127
|
+
</div>
|
1128
|
+
|
1129
|
+
</li>
|
1130
|
+
|
1131
|
+
</ul>
|
1132
|
+
|
1133
|
+
|
1134
|
+
</div><table class="source_code">
|
1135
|
+
<tr>
|
1136
|
+
<td>
|
1137
|
+
<pre class="lines">
|
1138
|
+
|
1139
|
+
|
1140
|
+
320
|
1141
|
+
321
|
1142
|
+
322
|
1143
|
+
323
|
1144
|
+
324
|
1145
|
+
325
|
1146
|
+
326</pre>
|
1147
|
+
</td>
|
1148
|
+
<td>
|
1149
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 320</span>
|
1150
|
+
|
1151
|
+
<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>
|
1152
|
+
<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>
|
1153
|
+
<span class='label'>identifier:</span> <span class='id identifier rubyid_identifier'>identifier</span><span class='comma'>,</span>
|
1154
|
+
<span class='label'>true_value:</span> <span class='id identifier rubyid_true_value'>true_value</span>
|
1155
|
+
<span class='rparen'>)</span>
|
1156
|
+
<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>
|
1157
|
+
<span class='kw'>end</span></pre>
|
1158
|
+
</td>
|
1159
|
+
</tr>
|
1160
|
+
</table>
|
1161
|
+
</div>
|
1162
|
+
|
1163
|
+
<div class="method_details ">
|
1164
|
+
<h3 class="signature " id="predict-instance_method">
|
1165
|
+
|
1166
|
+
#<strong>predict</strong>(input, options: nil) ⇒ <tt>Array<<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>></tt>, ...
|
1167
|
+
|
1168
|
+
|
1169
|
+
|
1170
|
+
|
1171
|
+
|
1172
|
+
</h3><div class="docstring">
|
1173
|
+
<div class="discussion">
|
1174
|
+
|
1175
|
+
<p>Make a prediction!</p>
|
1176
|
+
|
1177
|
+
|
1178
|
+
</div>
|
1179
|
+
</div>
|
1180
|
+
<div class="tags">
|
1181
|
+
<p class="tag_title">Parameters:</p>
|
1182
|
+
<ul class="param">
|
1183
|
+
|
1184
|
+
<li>
|
1185
|
+
|
1186
|
+
<span class='name'>input</span>
|
1187
|
+
|
1188
|
+
|
1189
|
+
<span class='type'>(<tt>Array<Hash{String, Symbol => String, Number}></tt>, <tt>Hash{String, Symbol => String, Number}</tt>)</span>
|
1190
|
+
|
1191
|
+
|
1192
|
+
|
1193
|
+
—
|
1194
|
+
<div class='inline'>
|
1195
|
+
<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>
|
1196
|
+
</div>
|
1197
|
+
|
1198
|
+
</li>
|
1199
|
+
|
1200
|
+
<li>
|
1201
|
+
|
1202
|
+
<span class='name'>options</span>
|
1203
|
+
|
1204
|
+
|
1205
|
+
<span class='type'>(<tt><span class='object_link'><a href="PredictOptions.html" title="Tangram::PredictOptions (class)">PredictOptions</a></span></tt>)</span>
|
1206
|
+
|
1207
|
+
|
1208
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1209
|
+
|
1210
|
+
|
1211
|
+
—
|
1212
|
+
<div class='inline'>
|
1213
|
+
<p>These are the predict options.</p>
|
1214
|
+
</div>
|
1215
|
+
|
1216
|
+
</li>
|
1217
|
+
|
1218
|
+
</ul>
|
1219
|
+
|
1220
|
+
<p class="tag_title">Returns:</p>
|
1221
|
+
<ul class="return">
|
1222
|
+
|
1223
|
+
<li>
|
1224
|
+
|
1225
|
+
|
1226
|
+
<span class='type'>(<tt>Array<<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>></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>
|
1227
|
+
|
1228
|
+
|
1229
|
+
|
1230
|
+
—
|
1231
|
+
<div class='inline'>
|
1232
|
+
<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>
|
1233
|
+
</div>
|
1234
|
+
|
1235
|
+
</li>
|
1236
|
+
|
1237
|
+
</ul>
|
1238
|
+
|
1239
|
+
</div><table class="source_code">
|
1240
|
+
<tr>
|
1241
|
+
<td>
|
1242
|
+
<pre class="lines">
|
1243
|
+
|
1244
|
+
|
1245
|
+
274
|
1246
|
+
275
|
1247
|
+
276
|
1248
|
+
277
|
1249
|
+
278
|
1250
|
+
279
|
1251
|
+
280
|
1252
|
+
281
|
1253
|
+
282
|
1254
|
+
283
|
1255
|
+
284
|
1256
|
+
285</pre>
|
1257
|
+
</td>
|
1258
|
+
<td>
|
1259
|
+
<pre class="code"><span class="info file"># File 'lib/tangram/tangram.rb', line 274</span>
|
1260
|
+
|
1261
|
+
<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>
|
1262
|
+
<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>
|
1263
|
+
<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>
|
1264
|
+
<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>
|
1265
|
+
<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>
|
1266
|
+
<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>
|
1267
|
+
<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>
|
1268
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>tangram error</span><span class='tstring_end'>'</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>
|
1269
|
+
<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>
|
1270
|
+
<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>
|
1271
|
+
<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>
|
1272
|
+
<span class='kw'>end</span></pre>
|
1273
|
+
</td>
|
1274
|
+
</tr>
|
1275
|
+
</table>
|
1276
|
+
</div>
|
1277
|
+
|
1278
|
+
</div>
|
1279
|
+
|
1280
|
+
</div>
|
1281
|
+
|
1282
|
+
<div id="footer">
|
1283
|
+
Generated on Tue Aug 17 17:09:51 2021 by
|
1284
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1285
|
+
0.9.26 (ruby-2.7.4).
|
1286
|
+
</div>
|
1287
|
+
|
1288
|
+
</div>
|
1289
|
+
</body>
|
1290
|
+
</html>
|