-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpages_smallkAPI.html
More file actions
914 lines (742 loc) · 54.5 KB
/
pages_smallkAPI.html
File metadata and controls
914 lines (742 loc) · 54.5 KB
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
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
<!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>7. Smallk API (C++) — SmallK 1.6.2 documentation</title>
<link rel="stylesheet" href="_static/css/my_theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="SmallK 1.6.2 documentation" href="index.html"/>
<link rel="next" title="8. Pysmallk API (Python)" href="pages_pysmallkAPI.html"/>
<link rel="prev" title="6. Command Line Tools" href="pages_commandLineTools.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<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"> SmallK
<img src="_static/georgiatech.png" class="logo" />
</a>
<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">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">SmallK</a></li>
<li class="toctree-l1"><a class="reference internal" href="pages_about.html">1. About</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_about.html#distributed-versions">1.1. Distributed Versions</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_about.html#ground-truth-data-for-graph-clustering-and-community-detection">1.2. Ground truth data for graph clustering and community detection</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_about.html#acknowledgements">1.3. Acknowledgements</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_about.html#contact-info">1.4. Contact Info</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_introduction.html">2. Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_introduction.html#background">2.1. Background</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_introduction.html#constrained-low-rank-approximations-and-nmf">2.2. Constrained low rank approximations and NMF</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_introduction.html#smallk-overview">2.3. SmallK Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_introduction.html#prerequisites">2.4. Prerequisites</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_quickstartInstall.html">3. Quickstart - Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartInstall.html#vagrant-virtual-machine">3.1. Vagrant Virtual Machine</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartInstall.html#docker-instructions">3.2. Docker Instructions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_quickstartSmallkAPI.html">4. Quickstart - Smallk API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#introduction">4.1. Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#c-project-setup">4.2. C++ Project Setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#load-a-matrix">4.3. Load a Matrix</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#perform-nmf-on-the-loaded-matrix">4.4. Perform NMF on the Loaded Matrix</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_quickstartSmallkAPI.html#nmf-bpp">4.4.1. NMF-BPP</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_quickstartSmallkAPI.html#nmf-hals">4.4.2. NMF-HALS</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_quickstartSmallkAPI.html#nmf-initialization">4.4.3. NMF Initialization</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#hierarchical-clustering">4.5. Hierarchical Clustering</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#flat-clustering">4.6. Flat Clustering</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#disclaimer">4.7. Disclaimer</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_quickstartSmallkAPI.html#contact-info">4.8. Contact Info</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_installation.html">5. Installation Instructions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#prerequisites">5.1. Prerequisites</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#id1">5.1.1. Elemental</a><ul>
<li class="toctree-l4"><a class="reference internal" href="pages_installation.html#how-to-install-elemental-on-macosx">5.1.1.1. How to Install Elemental on MacOSX</a><ul>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#osx-install-the-latest-gnu-compilers">5.1.1.1.1. OSX:Install the latest GNU compilers</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#osx-install-mpi-tools">5.1.1.1.2. OSX:Install MPI Tools</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#osx-install-libflame">5.1.1.1.3. OSX:Install libFlame</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#osx-install-elemental">5.1.1.1.4. OSX:Install Elemental</a><ul>
<li class="toctree-l6"><a class="reference internal" href="pages_installation.html#hybridrelease-build">5.1.1.1.4.1. HybridRelease Build</a></li>
<li class="toctree-l6"><a class="reference internal" href="pages_installation.html#purerelease-build">5.1.1.1.4.2. PureRelease Build</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="pages_installation.html#how-to-install-elemental-on-linux">5.1.1.2. How to Install Elemental on Linux</a><ul>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#linux-install-the-latest-gnu-compilers">5.1.1.2.1. Linux:Install the latest GNU compilers</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#linux-install-mpi-tools">5.1.1.2.2. Linux:Install MPI Tools</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#linux-install-libflame">5.1.1.2.3. Linux:Install libFlame</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#linux-install-an-accelerated-blas-library">5.1.1.2.4. Linux:Install an accelerated BLAS library</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#linux-install-elemental">5.1.1.2.5. Linux:Install Elemental</a><ul>
<li class="toctree-l6"><a class="reference internal" href="pages_installation.html#id5">5.1.1.2.5.1. HybridRelease build</a></li>
<li class="toctree-l6"><a class="reference internal" href="pages_installation.html#id6">5.1.1.2.5.2. PureRelease build</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#installation-of-python-libraries">5.1.2. Installation of Python libraries</a><ul>
<li class="toctree-l4"><a class="reference internal" href="pages_installation.html#osx-install-python-libraries">5.1.2.1. OSX:Install Python libraries</a><ul>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#install-python-scientific-packages">5.1.2.1.1. Install Python scientific packages</a></li>
<li class="toctree-l5"><a class="reference internal" href="pages_installation.html#install-cython-a-python-interface-to-c-c">5.1.2.1.2. Install Cython: a Python interface to C/C++</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="pages_installation.html#linux-install-python-libraries">5.1.2.2. Linux:Install Python libraries</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#build-and-installation-of-smallk">5.2. Build and Installation of SmallK</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#obtain-the-source-code">5.2.1. Obtain the Source Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#build-the-smallk-library">5.2.2. Build the SmallK library</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#install-the-smallk-library">5.2.3. Install the SmallK library</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_installation.html#check-the-build-and-installation">5.2.4. Check the build and installation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#build-and-installation-of-pysmallk-shared-library">5.3. Build and Installation of pysmallk shared library</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#matrix-file-formats">5.4. Matrix file formats</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#disclaimer">5.5. Disclaimer</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_installation.html#contact-info">5.6. Contact Info</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_commandLineTools.html">6. Command Line Tools</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#introduction">6.1. Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#preprocessor">6.2. Preprocessor</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#overview">6.2.1. Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#input-files">6.2.2. Input Files</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#command-line-options">6.2.3. Command Line Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#sample-runs">6.2.4. Sample Runs</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#matrixgen">6.3. Matrixgen</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id1">6.3.1. Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id2">6.3.2. Command Line Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id3">6.3.3. Sample Runs</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#nonnegative-matrix-factorization-nmf">6.4. Nonnegative Matrix Factorization (NMF)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id4">6.4.1. Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id5">6.4.2. Command Line Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id6">6.4.3. Sample Runs</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#hierclust">6.5. Hierclust</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id7">6.5.1. Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id9">6.5.2. Command Line Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id10">6.5.3. Sample Runs</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pages_commandLineTools.html#flatclust">6.6. Flatclust</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id12">6.6.1. Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id13">6.6.2. Command Line Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_commandLineTools.html#id14">6.6.3. Sample Runs</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">7. Smallk API (C++)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#examples-of-api-usage">7.1. Examples of API Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#smallk-api">7.2. SmallK API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#enumerations">7.2.1. Enumerations</a></li>
<li class="toctree-l3"><a class="reference internal" href="#api-functions">7.2.2. API functions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#initialization-and-cleanup">7.2.2.1. Initialization and cleanup</a></li>
<li class="toctree-l4"><a class="reference internal" href="#versioning">7.2.2.2. Versioning</a></li>
<li class="toctree-l4"><a class="reference internal" href="#common-functions">7.2.2.3. Common functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nmf-functions">7.2.2.4. NMF functions</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_pysmallkAPI.html">8. Pysmallk API (Python)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_pysmallkAPI.html#introduction">8.1. Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_pysmallkAPI.html#examples-of-pysmallk-usage">8.2. Examples of Pysmallk Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_pysmallkAPI.html#pysmallk-functions">8.3. Pysmallk Functions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pages_pysmallkAPI.html#preprocessor">8.3.1. Preprocessor</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_pysmallkAPI.html#matrixgen">8.3.2. Matrixgen</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_pysmallkAPI.html#smallkapi">8.3.3. SmallkAPI</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_pysmallkAPI.html#flatclust">8.3.4. Flatclust</a></li>
<li class="toctree-l3"><a class="reference internal" href="pages_pysmallkAPI.html#hierclust">8.3.5. Hierclust</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_tests.html">9. Tests</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_tests.html#smallk-test-results">9.1. SmallK Test Results</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pages_benchmarks_results.html">10. Benchmarks and Results</a></li>
<li class="toctree-l1"><a class="reference internal" href="pages_publications.html">11. Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="pages_software_repo.html">12. Software Repo</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pages_software_repo.html#getting-the-code-and-instructions">12.1. Getting the code and instructions</a></li>
<li class="toctree-l2"><a class="reference internal" href="pages_software_repo.html#contact-info">12.2. Contact Info</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">SmallK</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>7. Smallk API (C++)</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/pages_smallkAPI.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="smallk-api-c">
<h1>7. Smallk API (C++)<a class="headerlink" href="#smallk-api-c" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#examples-of-api-usage" id="id1">Examples of API Usage</a></li>
<li><a class="reference internal" href="#smallk-api" id="id2">SmallK API</a><ul>
<li><a class="reference internal" href="#enumerations" id="id3">Enumerations</a></li>
<li><a class="reference internal" href="#api-functions" id="id4">API functions</a><ul>
<li><a class="reference internal" href="#initialization-and-cleanup" id="id5">Initialization and cleanup</a></li>
<li><a class="reference internal" href="#versioning" id="id6">Versioning</a></li>
<li><a class="reference internal" href="#common-functions" id="id7">Common functions</a></li>
<li><a class="reference internal" href="#nmf-functions" id="id8">NMF functions</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="examples-of-api-usage">
<h2><a class="toc-backref" href="#id1">7.1. Examples of API Usage</a><a class="headerlink" href="#examples-of-api-usage" title="Permalink to this headline">¶</a></h2>
<p>In the examples folder you will find a file called <code class="docutils literal"><span class="pre">smallk_example.cpp</span></code>. This file contains several examples of how to use the SmallK library. Also included in the examples folder is a makefile that you can customize for your use. Note that the SmallK library must first be installed before the example project can be built.</p>
<p>As an example of how to use the sample project, assume the smallk software has been installed into <code class="docutils literal"><span class="pre">/usr/local/smallk</span></code>. Also assume that the user chose to create the recommended environment variable <code class="docutils literal"><span class="pre">SMALLK_INSTALL_DIR</span></code> that stores the location of the top-level install folder, i.e. the user’s <code class="docutils literal"><span class="pre">.bashrc</span></code> file contains this statement:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">export</span> <span class="nv">SMALLK_INSTALL_DIR</span><span class="o">=</span>/usr/local/smallk
</pre></div>
</div>
<p>To build the smallk example project, open a terminal window and cd to the smallk/examples folder and run this command:</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>make
</pre></div>
</div>
<p>To run the example project, run this command:</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>./bin/example ../../smallk_data
</pre></div>
</div>
<p>Note: the output will be <em>similar</em> to the following not identical since some problems are randomly initialized:</p>
<div class="highlight-none"><div class="highlight"><pre><span></span> Smallk major version: 1
Smallk minor version: 0
Smallk patch level: 0
Smallk version string: 1.0.0
Loading matrix...
************************************************************
* *
* Running NMF-BPP using k=32 *
* *
************************************************************
Initializing matrix W...
Initializing matrix H...
parameters:
algorithm: Nonnegative Least Squares with Block Principal Pivoting
stopping criterion: Ratio of Projected Gradients
height: 12411
width: 7984
k: 32
miniter: 5
maxiter: 5000
tol: 0.005
matrixfile: ../data/reuters.mtx
maxthreads: 8
1: progress metric: (min_iter)
2: progress metric: (min_iter)
3: progress metric: (min_iter)
4: progress metric: (min_iter)
5: progress metric: (min_iter)
6: progress metric: 0.0747031
7: progress metric: 0.0597987
8: progress metric: 0.0462878
9: progress metric: 0.0362883
10: progress metric: 0.030665
11: progress metric: 0.0281802
12: progress metric: 0.0267987
13: progress metric: 0.0236731
14: progress metric: 0.0220778
15: progress metric: 0.0227083
16: progress metric: 0.0244029
17: progress metric: 0.0247552
18: progress metric: 0.0220007
19: progress metric: 0.0173831
20: progress metric: 0.0137033
Solution converged after 39 iterations.
Elapsed wall clock time: 4.354 sec.
Writing output files...
************************************************************
* *
* Running NMF-HALS using k=16 *
* *
************************************************************
Initializing matrix W...
Initializing matrix H...
parameters:
algorithm: HALS
stopping criterion: Ratio of Projected Gradients
height: 12411
width: 7984
k: 16
miniter: 5
maxiter: 5000
tol: 0.005
matrixfile: ../data/reuters.mtx
maxthreads: 8
1: progress metric: (min_iter)
2: progress metric: (min_iter)
3: progress metric: (min_iter)
4: progress metric: (min_iter)
5: progress metric: (min_iter)
6: progress metric: 0.710219
7: progress metric: 0.580951
8: progress metric: 0.471557
9: progress metric: 0.491855
10: progress metric: 0.531999
11: progress metric: 0.353302
12: progress metric: 0.201634
13: progress metric: 0.1584
14: progress metric: 0.142572
15: progress metric: 0.12588
16: progress metric: 0.113239
17: progress metric: 0.0976934
18: progress metric: 0.0821207
19: progress metric: 0.0746089
20: progress metric: 0.0720616
40: progress metric: 0.0252854
60: progress metric: 0.0142085
80: progress metric: 0.0153269
Solution converged after 88 iterations.
Elapsed wall clock time: 1.560 sec.
Writing output files...
************************************************************
* *
* Running NMF-RANK2 with W and H initializers *
* *
************************************************************
Initializing matrix W...
Initializing matrix H...
parameters:
algorithm: Rank 2
stopping criterion: Ratio of Projected Gradients
height: 12411
width: 7984
k: 2
miniter: 5
maxiter: 5000
tol: 0.005
matrixfile: ../data/reuters.mtx
maxthreads: 8
1: progress metric: (min_iter)
2: progress metric: (min_iter)
3: progress metric: (min_iter)
4: progress metric: (min_iter)
5: progress metric: (min_iter)
6: progress metric: 0.0374741
7: progress metric: 0.0252389
8: progress metric: 0.0169805
9: progress metric: 0.0113837
10: progress metric: 0.00761077
11: progress metric: 0.0050782
12: progress metric: 0.00338569
Solution converged after 12 iterations.
Elapsed wall clock time: 0.028 sec.
Writing output files...
************************************************************
* *
* Repeating the previous run with tol = 1.0e-5 *
* *
************************************************************
Initializing matrix W...
Initializing matrix H...
parameters:
algorithm: Rank 2
stopping criterion: Ratio of Projected Gradients
height: 12411
width: 7984
k: 2
miniter: 5
maxiter: 5000
tol: 1e-05
matrixfile: ../data/reuters.mtx
maxthreads: 8
1: progress metric: (min_iter)
2: progress metric: (min_iter)
3: progress metric: (min_iter)
4: progress metric: (min_iter)
5: progress metric: (min_iter)
6: progress metric: 0.0374741
7: progress metric: 0.0252389
8: progress metric: 0.0169805
9: progress metric: 0.0113837
10: progress metric: 0.00761077
11: progress metric: 0.0050782
12: progress metric: 0.00338569
13: progress metric: 0.00225761
14: progress metric: 0.00150429
15: progress metric: 0.00100167
16: progress metric: 0.000666691
17: progress metric: 0.000443654
18: progress metric: 0.000295213
19: progress metric: 0.000196411
20: progress metric: 0.000130604
Solution converged after 27 iterations.
Elapsed wall clock time: 0.061 sec.
Writing output files...
Minimum value in W matrix: 0.
Maximum value in W matrix: 0.397027.
************************************************************
* *
* Running HierNMF2 with 5 clusters, JSON format *
* *
************************************************************
loading dictionary...
creating random W initializers...
creating random H initializers...
parameters:
height: 12411
width: 7984
matrixfile: ../data/reuters.mtx
dictfile: ../data/reuters_dictionary.txt
tol: 0.0001
miniter: 5
maxiter: 5000
maxterms: 5
maxthreads: 8
[1] [2] [3] [4]
Elapsed wall clock time: 391 ms.
9/9 factorizations converged.
Writing output files...
************************************************************
* *
* Running HierNMF2 with 10 clusters, 12 terms, XML format *
* *
************************************************************
creating random W initializers...
creating random H initializers...
parameters:
height: 12411
width: 7984
matrixfile: ../data/reuters.mtx
dictfile: ../data/reuters_dictionary.txt
tol: 0.0001
miniter: 5
maxiter: 5000
maxterms: 12
maxthreads: 8
[1] [2] [3] [4] [5] [6] dropping 20 items ...
[7] [8] [9]
Elapsed wall clock time: 837 ms.
21/21 factorizations converged.
Writing output files...
************************************************************
* *
* Running HierNmf2 with 18 clusters, 8 terms, with flat *
* *
************************************************************
creating random W initializers...
creating random H initializers...
parameters:
height: 12411
width: 7984
matrixfile: ../data/reuters.mtx
dictfile: ../data/reuters_dictionary.txt
tol: 0.0001
miniter: 5
maxiter: 5000
maxterms: 8
maxthreads: 8
[1] [2] [3] [4] [5] [6] dropping 20 items ...
[7] [8] [9] dropping 25 items ...
[10] [11] [12] [13] [14] [15] [16] [17]
Running NNLS solver...
1: progress metric: 1
2: progress metric: 0.264152
3: progress metric: 0.0760648
4: progress metric: 0.0226758
5: progress metric: 0.00743562
6: progress metric: 0.00280826
7: progress metric: 0.00103682
8: progress metric: 0.000361738
9: progress metric: 0.000133087
10: progress metric: 5.84849e-05
Elapsed wall clock time: 1.362 s.
40/40 factorizations converged.
Writing output files...
</pre></div>
</div>
<p>The output files are written to the default directory or the directory specified on the command line.</p>
</div>
<div class="section" id="smallk-api">
<h2><a class="toc-backref" href="#id2">7.2. SmallK API</a><a class="headerlink" href="#smallk-api" title="Permalink to this headline">¶</a></h2>
<p>The SmallK API is an extremely simplistic API for basic NMF and clustering. Users who require more control over the factorization or clustering algorithms can instead run one of the command-line applications in the SmallK distribution.</p>
<p>The SmallK API is exposed by the file smallk.hpp, which can be found in this location:</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>SMALLK_INSTALL_DIR/include/smallk.hpp.
</pre></div>
</div>
<p>All API functions are contained within the smallk namespace.</p>
<p>An example of how to use the API can be found in the file <code class="docutils literal"><span class="pre">examples/smallk_example.cpp</span></code>.</p>
<p>The smallk library maintains a set of state variables that are used to control the Nmf and clustering routines. Once set, the state variables maintain their values until changed by an API function. For instance, one state variable represents the matrix to be factored (or used for clustering). The API provides a function to load this matrix; once loaded, it can be repeatedly factored without the need for reloading. The state variables and their default values are documented below.</p>
<p>All computations with the smallk library are performed in double precision.</p>
<div class="section" id="enumerations">
<h3><a class="toc-backref" href="#id3">7.2.1. Enumerations</a><a class="headerlink" href="#enumerations" title="Permalink to this headline">¶</a></h3>
<p>The SmallK API provides two enumerated types, one for the supported NMF algorithms and one for the clustering file output format. These are:</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">enum</span> <span class="n">Algorithm</span>
<span class="p">{</span>
<span class="n">MU</span><span class="p">,</span> <span class="c1">// Multiplicative Updating, Lee & Seung</span>
<span class="n">BPP</span><span class="p">,</span> <span class="c1">// Block Principal Pivoting, Kim and Park</span>
<span class="n">HALS</span><span class="p">,</span> <span class="c1">// Hierarchical Alternating Least Squares, Cichocki & Pan</span>
<span class="n">RANK2</span> <span class="c1">// Rank2, Kuang and Park</span>
<span class="p">};</span>
</pre></div>
</div>
<p>The default NMF algorithm is BPP. The Rank2 algorithm is optimized for two-column or two-row matrices and is the underlying factorization routine for the clustering code.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">enum</span> <span class="n">OutputFormat</span>
<span class="p">{</span>
<span class="n">XML</span><span class="p">,</span> <span class="c1">// Extensible Markup Language</span>
<span class="n">JSON</span> <span class="c1">// JavaScript Object Notation</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="api-functions">
<h3><a class="toc-backref" href="#id4">7.2.2. API functions</a><a class="headerlink" href="#api-functions" title="Permalink to this headline">¶</a></h3>
<div class="section" id="initialization-and-cleanup">
<h4><a class="toc-backref" href="#id5">7.2.2.1. Initialization and cleanup</a><a class="headerlink" href="#initialization-and-cleanup" title="Permalink to this headline">¶</a></h4>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">Initialize</span><span class="p">(</span><span class="kt">int</span><span class="o">&</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">**&</span> <span class="n">argv</span><span class="p">)</span>
</pre></div>
</div>
<p>Call this function first, before all others in the API; initializes Elemental and the smallk library.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">bool</span> <span class="n">IsInitialized</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns true if the library has been initialized via a call to Initialize(), false otherwise.</p>
<p>Call this function last, after all others in the API; performs cleanup for Elemental and the smallk library:</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">Finalize</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="versioning">
<h4><a class="toc-backref" href="#id6">7.2.2.2. Versioning</a><a class="headerlink" href="#versioning" title="Permalink to this headline">¶</a></h4>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMajorVersion</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the major release version number of the library as an unsigned integer.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMinorVersion</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the minor release version number of the library as an unsigned integer.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetPatchLevel</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the patch version number of the library as an unsigned integer.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">GetVersionString</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the version of the library as a string, formatted as major.minor.patch.</p>
</div>
<div class="section" id="common-functions">
<h4><a class="toc-backref" href="#id7">7.2.2.3. Common functions</a><a class="headerlink" href="#common-functions" title="Permalink to this headline">¶</a></h4>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetOutputPrecision</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the floating point precision with which numerical output will be written (i.e., the computed W and H matrix factors from the Nmf routine). The default precision is six digits.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetOutputPrecision</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">num_digits</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the floating point precision with which numerical output will be written. Input values should be within the range [1, precision(double)]. Any inputs outside of this range will be adjusted.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMaxIter</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the maximum number of iterations allowed for NMF computations. The default value is 5000.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetMaxIter</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">max_iterations</span> <span class="o">=</span> <span class="mi">5000</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the maximum number of iterations allowed for NMF computations. The default of 5000 should be more than sufficient for most computations.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMinIter</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the minimum number of NMF iterations. The default value is 5.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetMinIter</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">min_iterations</span> <span class="o">=</span> <span class="mi">5</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the minimum number of NMF iterations to perform before checking for convergence. The convergence and progress estimation routines are non-trivial calculations, so increasing this value may result in faster performance.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMaxThreads</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the maximum number of threads used for NMF or clustering computations. The default value is hardware-dependent, but is generally the maximum number allowed by the hardware.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">SetMaxThreads</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">max_threads</span><span class="p">);</span>
</pre></div>
</div>
<p>Sets an upper limit to the number of threads used for NMF and clustering computations. Inputs that exceed the capabilities of the hardware will be adjusted. This function is provided for scaling and performance studies.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">Reset</span><span class="p">()</span>
</pre></div>
</div>
<p>Resets all state variables to their default values.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SeedRNG</span><span class="p">(</span><span class="k">const</span> <span class="kt">int</span> <span class="n">seed</span><span class="p">)</span>
</pre></div>
</div>
<p>Seeds the random number generator (RNG) within the smallk library. Normally this RNG is seeded from the system time whenever the library is initialized. The RNG is the <code class="docutils literal"><span class="pre">19937</span></code> Mersenne Twister implementation provided by the C++ standard library.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">LoadMatrix</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&</span> <span class="n">filepath</span><span class="p">)</span>
</pre></div>
</div>
<p>Loads a matrix contained in the given file. The file must either be a comma-separated value (.CSV) file for a dense matrix, or a MatrixMarket-format file (.MTX) for a sparse matrix. If the matrix cannot be loaded the library throws a std::runtime_error exception.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">bool</span> <span class="n">IsMatrixLoaded</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns true if a matrix is currently loaded, false if not.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">GetOuputDir</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns a string indicating the directory into which output files will be written. The default is the current directory.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetOutputDir</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&</span> <span class="n">outdir</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the directory into which output files should be written. The <code class="docutils literal"><span class="pre">outdir</span></code> argument can either be an absolute or relative path. The default is the current directory.</p>
</div>
<div class="section" id="nmf-functions">
<h4><a class="toc-backref" href="#id8">7.2.2.4. NMF functions</a><a class="headerlink" href="#nmf-functions" title="Permalink to this headline">¶</a></h4>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">Nmf</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">k</span><span class="p">,</span>
<span class="k">const</span> <span class="n">Algorithm</span> <span class="n">algorithm</span> <span class="o">=</span> <span class="n">Algorithm</span><span class="o">::</span><span class="n">BPP</span><span class="p">,</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&</span> <span class="n">initfile_w</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">(</span><span class="s">""</span><span class="p">),</span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&</span> <span class="n">initfile_h</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">(</span><span class="s">""</span><span class="p">))</span>
</pre></div>
</div>
<p>This function factors the input matrix A of nonnegative elements into nonnegative factors such that: <span class="math">\matr{A} \cong \matr{W} \matr{H}</span>. If a matrix is not currently loaded a std::logic_error exception will be thrown. The default algorithm is NMF-BPP; provide one of the enumerated algorithm values to use a different algorithm.</p>
<p>Where A is mxn, W is mxk, and H is kxn. The value of k a user defined argument, e.g., for clustering applications, k is the number of clusters.</p>
<p>Optional initializer matrices can be provided for the W and H factors via the <code class="docutils literal"><span class="pre">initfile_w</span></code> and <code class="docutils literal"><span class="pre">initfile_h</span></code> arguments. These files must contain fully dense matrices in .CSV format. The W matrix initializer must have dimension mxk, and the H matrix initializer must have dimension kxn. If the initializer matrices do not match these dimensions exactly a std::logic_error exception is thrown. If initializers are not provided, matrices W and H will be randomly initialized.</p>
<p>The computed factors W and H will be written to the output directory in the files <code class="docutils literal"><span class="pre">w.csv</span></code> and <code class="docutils literal"><span class="pre">h.csv</span></code>.</p>
<p>Exceptions will be thrown (either from Elemental or smallk) in case of error.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">const</span> <span class="kt">double</span><span class="o">*</span> <span class="n">LockedBufferW</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">ldim</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">height</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">width</span><span class="p">)</span>
</pre></div>
</div>
<p>This function returns a READONLY pointer to the buffer containing the W factor computed by the Nmf routine, along with buffer and matrix dimensions. The <code class="docutils literal"><span class="pre">ldim</span></code>, <code class="docutils literal"><span class="pre">height</span></code>, and <code class="docutils literal"><span class="pre">width</span></code> arguments are all out parameters. The buffer has a height of <code class="docutils literal"><span class="pre">ldim</span></code> and a width of <code class="docutils literal"><span class="pre">width</span></code>. The matrix W has the same width but a height of <code class="docutils literal"><span class="pre">height</span></code>, which may differ from ldim. The W matrix is stored in the buffer in column-major order. See the examples/smallk_example.cpp file for an illustration of how to use this function.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">const</span> <span class="kt">double</span><span class="o">*</span> <span class="n">LockedBufferH</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">ldim</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">height</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&</span> <span class="n">width</span><span class="p">)</span>
</pre></div>
</div>
<p>Same as LockedBufferW, but for the H matrix.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">double</span> <span class="n">GetNmfTolerance</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the tolerance value used to determine NMF convergence. The default value is 0.005.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetNmfTolerance</span><span class="p">(</span><span class="k">const</span> <span class="kt">double</span> <span class="n">tol</span><span class="o">=</span><span class="mf">0.005</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the tolerance value used to determine NMF convergence. The NMF algorithms are iterative, and at each iteration a progress metric is computed and compared with the tolerance value. When the metric falls below the tolerance value the iterations stop and convergence is declared. The tolerance value should satisfy 0.0 < tolerance < 1.0. Any inputs outside this range will cause a std::logic_error exception to be thrown.
Clustering Functions</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">LoadDictionary</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&</span> <span class="n">filepath</span><span class="p">)</span>
</pre></div>
</div>
<p>Loads the dictionary used for clustering. The dictionary is an ASCII file of text strings as described in the preprocessor input files section below. If the dictionary file cannot be loaded a std::runtime_error exception is thrown.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">GetMaxTerms</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the number of highest-probability dictionary terms to store per cluster. The default value is 5.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetMaxTerms</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">max_terms</span> <span class="o">=</span> <span class="mi">5</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the number of highest-probability dictionary terms to store per cluster.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="n">OutputFormat</span> <span class="n">GetOutputFormat</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns a member of the OutputFormat enumerated type; this is the file format for the clustering results. The default output format is JSON.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetOutputFormat</span><span class="p">(</span><span class="k">const</span> <span class="n">OutputFormat</span> <span class="o">=</span> <span class="n">OutputFormat</span><span class="o">::</span><span class="n">JSON</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the output format for the clustering result file. The argument must be one of the values in the OutputFormat enumerated type.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">double</span> <span class="n">GetHierNmf2Tolerance</span><span class="p">()</span>
</pre></div>
</div>
<p>Returns the tolerance value used by the NMF-RANK2 algorithm for hierarchical clustering. The default value is 1.0e-4.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">SetHierNmf2Tolerance</span><span class="p">(</span><span class="k">const</span> <span class="kt">double</span> <span class="n">tol</span><span class="o">=</span><span class="mf">1.0e-4</span><span class="p">)</span>
</pre></div>
</div>
<p>Sets the tolerance value used by the NMF-RANK2 algorithm for hierarchical clustering. The tolerance value should satisfy 0.0 < tolerance < 1.0. Any inputs outside this range will cause a <code class="docutils literal"><span class="pre">std::logic_error</span></code> exception to be thrown.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">HierNmf2</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">num_clusters</span><span class="p">)</span>
</pre></div>
</div>
<p>This function performs hierarchical clustering on the loaded matrix, generating the number of clusters specified by the <code class="docutils literal"><span class="pre">num_clusters</span></code> argument. For an overview of the hierarchical clustering process, see the description below for the hierclust command line application.</p>
<p>This function generates two output files in the output directory: <cite>assignments_N.csv</cite> and <cite>tree_N.{json, xml}</cite>. Here N is the number of clusters specified as an argument, and the tree file can be in either JSON XML format.</p>
<p>The content of the files is described below in the section on the hierclust command line application.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="n">HierNmf2WithFlat</span><span class="p">(</span><span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">num_clusters</span><span class="p">)</span>
</pre></div>
</div>
<p>This function performs hierarchical clustering on the loaded matrix, exactly as described for HierNmf2. In addition, it also computes a flat clustering result. Thus four output files are generated. The flat clustering result files are <code class="docutils literal"><span class="pre">assignments_flat_N.csv</span></code> and <code class="docutils literal"><span class="pre">clusters_N.{json,</span> <span class="pre">xml}</span></code>. The cluster file contents are documented below in the section on the flatclust command line application.</p>
</div>
</div>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="pages_pysmallkAPI.html" class="btn btn-neutral float-right" title="8. Pysmallk API (Python)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="pages_commandLineTools.html" class="btn btn-neutral" title="6. Command Line Tools" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2017, Georgia Institute of Technology.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'1.6.2',
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>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>