forked from nmslib/nmslib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.html
843 lines (692 loc) · 38.1 KB
/
api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Reference — nmslib 1.8 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'1.8',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Configuring Logging for NMSLIB" href="logging.html" />
<link rel="prev" title="Python bindings for NMSLIB" href="quickstart.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> nmslib
</a>
<div class="version">
1.8
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="quickstart.html"> Quickstart</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#"> API Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#nmslib-init">nmslib.init</a></li>
<li class="toctree-l2"><a class="reference internal" href="#nmslib-floatindex">nmslib.FloatIndex</a></li>
<li class="toctree-l2"><a class="reference internal" href="#nmslib-doubleindex">nmslib.DoubleIndex</a></li>
<li class="toctree-l2"><a class="reference internal" href="#nmslib-intindex">nmslib.IntIndex</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="logging.html"> Logging</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">nmslib</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>API Reference</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="api-reference">
<h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h1>
<p>Information on the search methods (and their parameters) and spaces, can be found <a class="reference external" href="https://github.com/nmslib/nmslib/tree/master/manual/README.md">on this page</a>.</p>
<div class="section" id="nmslib-init">
<h2>nmslib.init<a class="headerlink" href="#nmslib-init" title="Permalink to this headline">¶</a></h2>
<p>This function acts act the main entry point into NMS lib. This
function should be called first before calling any other method.</p>
<dl class="function">
<dt id="nmslib.init">
<code class="descclassname">nmslib.</code><code class="descname">init</code><span class="sig-paren">(</span><em>space: str='cosinesimil'</em>, <em>space_params: object=None</em>, <em>method: str='hnsw'</em>, <em>data_type: nmslib.DataType=DataType.DENSE_VECTOR</em>, <em>dtype: nmslib.DistType=DistType.FLOAT</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.init" title="Permalink to this definition">¶</a></dt>
<dd><p>This function initializes a new NMSLIB index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>space</strong> (<em>str optional</em>) – The metric space to create for this index</li>
<li><strong>space_params</strong> (<em>dict optional</em>) – Parameters for configuring the space</li>
<li><strong>method</strong> (<em>str optional</em>) – The index method to use</li>
<li><strong>data_type</strong> (<em>nmslib.DataType optional</em>) – The type of data to index (dense/sparse/string vectors)</li>
<li><strong>dist_type</strong> (<em>nmslib.DistType optional</em>) – The type of index to create (float/double/int)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">A new NMSLIB Index.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="nmslib.DistType">
<em class="property">class </em><code class="descclassname">nmslib.</code><code class="descname">DistType</code><a class="headerlink" href="#nmslib.DistType" title="Permalink to this definition">¶</a></dt>
<dd><dl class="attribute">
<dt id="nmslib.DistType.FLOAT">
<code class="descname">FLOAT</code><a class="headerlink" href="#nmslib.DistType.FLOAT" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="nmslib.DistType.DOUBLE">
<code class="descname">DOUBLE</code><a class="headerlink" href="#nmslib.DistType.DOUBLE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="nmslib.DistType.INT">
<code class="descname">INT</code><a class="headerlink" href="#nmslib.DistType.INT" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="nmslib.DataType">
<em class="property">class </em><code class="descclassname">nmslib.</code><code class="descname">DataType</code><a class="headerlink" href="#nmslib.DataType" title="Permalink to this definition">¶</a></dt>
<dd><dl class="attribute">
<dt id="nmslib.DataType.DENSE_VECTOR">
<code class="descname">DENSE_VECTOR</code><a class="headerlink" href="#nmslib.DataType.DENSE_VECTOR" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="nmslib.DataType.OBJECT_AS_STRING">
<code class="descname">OBJECT_AS_STRING</code><a class="headerlink" href="#nmslib.DataType.OBJECT_AS_STRING" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="nmslib.DataType.SPARSE_VECTOR">
<code class="descname">SPARSE_VECTOR</code><a class="headerlink" href="#nmslib.DataType.SPARSE_VECTOR" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="nmslib-floatindex">
<h2>nmslib.FloatIndex<a class="headerlink" href="#nmslib-floatindex" title="Permalink to this headline">¶</a></h2>
<p>nmslib.dist.FloatIndex</p>
<dl class="class">
<dt id="nmslib.dist.FloatIndex">
<em class="property">class </em><code class="descclassname">nmslib.dist.</code><code class="descname">FloatIndex</code><a class="headerlink" href="#nmslib.dist.FloatIndex" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="nmslib.dist.FloatIndex.addDataPoint">
<code class="descname">addDataPoint</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>id: int</em>, <em>data: object</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.FloatIndex.addDataPoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a single datapoint to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>id</strong> (<em>int</em>) – The id of the object to add</li>
<li><strong>data</strong> (<em>object</em>) – The object to add to the index.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The position the item was added at</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.addDataPointBatch">
<code class="descname">addDataPointBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>data: object</em>, <em>ids: object=None</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.FloatIndex.addDataPointBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds multiple datapoints to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data</strong> (<em>object</em>) – The objects to add to the index.</li>
<li><strong>ids</strong> (<em>array_like optional</em>) – The ids of the object being inserted. If not set will default to the
row id of each object in the dataset</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The number of items added</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.createIndex">
<code class="descname">createIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>index_params: object=None</em>, <em>print_progress: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.FloatIndex.createIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the index, and makes it available for querying</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>index_params</strong> (<em>dict optional</em>) – Dictionary of optional parameters to use in indexing</li>
<li><strong>print_progress</strong> (<em>bool optional</em>) – Whether or not to display progress bar when creating index</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.getDistance">
<code class="descname">getDistance</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>arg0: int</em>, <em>arg1: int</em><span class="sig-paren">)</span> → float<a class="headerlink" href="#nmslib.dist.FloatIndex.getDistance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.knnQuery">
<code class="descname">knnQuery</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>vector: object</em>, <em>k: int=10</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.FloatIndex.knnQuery" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the approximate K nearest neighbours of a vector in the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>vector</strong> (<em>array_like</em>) – A 1D vector to query for.</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><strong>ids</strong> (<em>array_like.</em>) – A 1D vector of the ids of each nearest neighbour.</li>
<li><strong>distances</strong> (<em>array_like.</em>) – A 1D vector of the distance to each nearest neigbhour.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.knnQueryBatch">
<code class="descname">knnQueryBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>queries: object</em>, <em>k: int=10</em>, <em>num_threads: int=0</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.FloatIndex.knnQueryBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs multiple queries on the index, distributing the work over
a thread pool</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>input</strong> (<em>list</em>) – A list of queries to query for</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
<li><strong>num_threads</strong> (<em>int optional</em>) – The number of threads to use</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A list of tuples of (ids, distances)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.loadIndex">
<code class="descname">loadIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>filename: str</em>, <em>load_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.FloatIndex.loadIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads the index from disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to read from</li>
<li><strong>load_data</strong> (<em>bool optional</em>) – Whether or not to load previously saved data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.saveIndex">
<code class="descname">saveIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>filename: str</em>, <em>save_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.FloatIndex.saveIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Saves the index and/or data to disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to save to</li>
<li><strong>save_data</strong> (<em>bool optional</em>) – Whether or not to save data</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.FloatIndex.setQueryTimeParams">
<code class="descname">setQueryTimeParams</code><span class="sig-paren">(</span><em>self: nmslib.dist.FloatIndex</em>, <em>params: object=None</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.FloatIndex.setQueryTimeParams" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets parameters used in knnQuery.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> (<em>dict</em>) – A dictionary of params to use in querying. Setting params to None will reset</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="nmslib-doubleindex">
<h2>nmslib.DoubleIndex<a class="headerlink" href="#nmslib-doubleindex" title="Permalink to this headline">¶</a></h2>
<p>nmslib.dist.DoubleIndex</p>
<dl class="class">
<dt id="nmslib.dist.DoubleIndex">
<em class="property">class </em><code class="descclassname">nmslib.dist.</code><code class="descname">DoubleIndex</code><a class="headerlink" href="#nmslib.dist.DoubleIndex" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="nmslib.dist.DoubleIndex.addDataPoint">
<code class="descname">addDataPoint</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>id: int</em>, <em>data: object</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.DoubleIndex.addDataPoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a single datapoint to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>id</strong> (<em>int</em>) – The id of the object to add</li>
<li><strong>data</strong> (<em>object</em>) – The object to add to the index.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The position the item was added at</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.addDataPointBatch">
<code class="descname">addDataPointBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>data: object</em>, <em>ids: object=None</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.DoubleIndex.addDataPointBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds multiple datapoints to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data</strong> (<em>object</em>) – The objects to add to the index.</li>
<li><strong>ids</strong> (<em>array_like optional</em>) – The ids of the object being inserted. If not set will default to the
row id of each object in the dataset</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The number of items added</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.createIndex">
<code class="descname">createIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>index_params: object=None</em>, <em>print_progress: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.DoubleIndex.createIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the index, and makes it available for querying</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>index_params</strong> (<em>dict optional</em>) – Dictionary of optional parameters to use in indexing</li>
<li><strong>print_progress</strong> (<em>bool optional</em>) – Whether or not to display progress bar when creating index</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.getDistance">
<code class="descname">getDistance</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>arg0: int</em>, <em>arg1: int</em><span class="sig-paren">)</span> → float<a class="headerlink" href="#nmslib.dist.DoubleIndex.getDistance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.knnQuery">
<code class="descname">knnQuery</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>vector: object</em>, <em>k: int=10</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.DoubleIndex.knnQuery" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the approximate K nearest neighbours of a vector in the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>vector</strong> (<em>array_like</em>) – A 1D vector to query for.</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><strong>ids</strong> (<em>array_like.</em>) – A 1D vector of the ids of each nearest neighbour.</li>
<li><strong>distances</strong> (<em>array_like.</em>) – A 1D vector of the distance to each nearest neigbhour.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.knnQueryBatch">
<code class="descname">knnQueryBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>queries: object</em>, <em>k: int=10</em>, <em>num_threads: int=0</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.DoubleIndex.knnQueryBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs multiple queries on the index, distributing the work over
a thread pool</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>input</strong> (<em>list</em>) – A list of queries to query for</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
<li><strong>num_threads</strong> (<em>int optional</em>) – The number of threads to use</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A list of tuples of (ids, distances)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.loadIndex">
<code class="descname">loadIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>filename: str</em>, <em>load_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.DoubleIndex.loadIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads the index from disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to read from</li>
<li><strong>load_data</strong> (<em>bool optional</em>) – Whether or not to load previously saved data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.saveIndex">
<code class="descname">saveIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>filename: str</em>, <em>save_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.DoubleIndex.saveIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Saves the index and/or data to disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to save to</li>
<li><strong>save_data</strong> (<em>bool optional</em>) – Whether or not to save data</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.DoubleIndex.setQueryTimeParams">
<code class="descname">setQueryTimeParams</code><span class="sig-paren">(</span><em>self: nmslib.dist.DoubleIndex</em>, <em>params: object=None</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.DoubleIndex.setQueryTimeParams" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets parameters used in knnQuery.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> (<em>dict</em>) – A dictionary of params to use in querying. Setting params to None will reset</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="nmslib-intindex">
<h2>nmslib.IntIndex<a class="headerlink" href="#nmslib-intindex" title="Permalink to this headline">¶</a></h2>
<p>nmslib.dist.IntIndex</p>
<dl class="class">
<dt id="nmslib.dist.IntIndex">
<em class="property">class </em><code class="descclassname">nmslib.dist.</code><code class="descname">IntIndex</code><a class="headerlink" href="#nmslib.dist.IntIndex" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="nmslib.dist.IntIndex.addDataPoint">
<code class="descname">addDataPoint</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>id: int</em>, <em>data: object</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.IntIndex.addDataPoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a single datapoint to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>id</strong> (<em>int</em>) – The id of the object to add</li>
<li><strong>data</strong> (<em>object</em>) – The object to add to the index.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The position the item was added at</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.addDataPointBatch">
<code class="descname">addDataPointBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>data: object</em>, <em>ids: object=None</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.IntIndex.addDataPointBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds multiple datapoints to the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data</strong> (<em>object</em>) – The objects to add to the index.</li>
<li><strong>ids</strong> (<em>array_like optional</em>) – The ids of the object being inserted. If not set will default to the
row id of each object in the dataset</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The number of items added</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.createIndex">
<code class="descname">createIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>index_params: object=None</em>, <em>print_progress: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.IntIndex.createIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the index, and makes it available for querying</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>index_params</strong> (<em>dict optional</em>) – Dictionary of optional parameters to use in indexing</li>
<li><strong>print_progress</strong> (<em>bool optional</em>) – Whether or not to display progress bar when creating index</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.getDistance">
<code class="descname">getDistance</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>arg0: int</em>, <em>arg1: int</em><span class="sig-paren">)</span> → int<a class="headerlink" href="#nmslib.dist.IntIndex.getDistance" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.knnQuery">
<code class="descname">knnQuery</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>vector: object</em>, <em>k: int=10</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.IntIndex.knnQuery" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the approximate K nearest neighbours of a vector in the index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>vector</strong> (<em>array_like</em>) – A 1D vector to query for.</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><strong>ids</strong> (<em>array_like.</em>) – A 1D vector of the ids of each nearest neighbour.</li>
<li><strong>distances</strong> (<em>array_like.</em>) – A 1D vector of the distance to each nearest neigbhour.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.knnQueryBatch">
<code class="descname">knnQueryBatch</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>queries: object</em>, <em>k: int=10</em>, <em>num_threads: int=0</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#nmslib.dist.IntIndex.knnQueryBatch" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs multiple queries on the index, distributing the work over
a thread pool</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>input</strong> (<em>list</em>) – A list of queries to query for</li>
<li><strong>k</strong> (<em>int optional</em>) – The number of neighbours to return</li>
<li><strong>num_threads</strong> (<em>int optional</em>) – The number of threads to use</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A list of tuples of (ids, distances)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.loadIndex">
<code class="descname">loadIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>filename: str</em>, <em>load_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.IntIndex.loadIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads the index from disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to read from</li>
<li><strong>load_data</strong> (<em>bool optional</em>) – Whether or not to load previously saved data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.saveIndex">
<code class="descname">saveIndex</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>filename: str</em>, <em>save_data: bool=False</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.IntIndex.saveIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>Saves the index and/or data to disk</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>str</em>) – The filename to save to</li>
<li><strong>save_data</strong> (<em>bool optional</em>) – Whether or not to save data</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="nmslib.dist.IntIndex.setQueryTimeParams">
<code class="descname">setQueryTimeParams</code><span class="sig-paren">(</span><em>self: nmslib.dist.IntIndex</em>, <em>params: object=None</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#nmslib.dist.IntIndex.setQueryTimeParams" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets parameters used in knnQuery.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> (<em>dict</em>) – A dictionary of params to use in querying. Setting params to None will reset</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="logging.html" class="btn btn-neutral float-right" title="Configuring Logging for NMSLIB" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="quickstart.html" class="btn btn-neutral float-left" title="Python bindings for NMSLIB" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2019, Bilegsaikhan Naidan, Leonid Boytsov, Yury Malkov. With contributions from David Novak, Lawrence Cayton, Wei Dong, Avrelin Nikita, Ben Frederickson, Dmitry Yashunin, Bob Poekert, @gregfriedland, @orgoro, Scott Gigante, Maxim Andreev, Daniel Lemire, Nathan Kurz, Alexander Ponomarenko.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>