kodama-cpp
Standalone float32 KODAMA kernels for CPU, CUDA, and Apple Metal
Loading...
Searching...
No Matches
kodama.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Stefano Cacciatore
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "kodama/version.hpp"
7
8#include <cstddef>
9#include <cstdint>
10#include <memory>
11#include <string>
12#include <vector>
13
14namespace kodama {
15
16namespace detail {
17struct KODAMAGraphHandleAccess;
18}
19
20enum class Backend {
21 Auto,
22 CPU,
23 CUDA,
24 Metal
25};
26
27enum class DistanceMetric {
28 Cosine,
31};
32
41
42enum class PLSMode {
43 PLS_DA,
45};
46
47enum class CoreClassifier {
48 PLS_LDA,
49 KNN
50};
51
61
63 static EvolutionPolicy from_name(const std::string& name);
64};
65
66enum class GraphWeightType {
67 SNN,
70 Binary
71};
72
76
80};
81
82enum class UMAPGraphMode {
83 Binary,
84 Fuzzy
85};
86
87enum class MatrixValueType {
88 Float64,
90};
91
92enum class GraphIndexBase {
93 Auto,
94 Zero,
95 One
96};
97
99 PQN,
100 Sum,
101 Median,
102 Sqrt,
103 None
104};
105
106enum class ScalingMethod {
107 None,
108 Centering,
112};
113
115 const void* data = nullptr;
116 std::size_t rows = 0;
117 std::size_t cols = 0;
119
120 MatrixView() = default;
121
122 MatrixView(const double* data_ptr, std::size_t n_rows, std::size_t n_cols)
123 : data(data_ptr), rows(n_rows), cols(n_cols), value_type(MatrixValueType::Float64) {}
124
125 MatrixView(const float* data_ptr, std::size_t n_rows, std::size_t n_cols)
126 : data(data_ptr), rows(n_rows), cols(n_cols), value_type(MatrixValueType::Float32) {}
127
128 float value_float(std::size_t i, std::size_t j) const {
129 const std::size_t offset = i * cols + j;
131 return static_cast<const float*>(data)[offset];
132 }
133 return static_cast<float>(static_cast<const double*>(data)[offset]);
134 }
135
136 double operator()(std::size_t i, std::size_t j) const {
137 const std::size_t offset = i * cols + j;
139 return static_cast<double>(static_cast<const float*>(data)[offset]);
140 }
141 return static_cast<const double*>(data)[offset];
142 }
143};
144
146 int folds = 10;
147 bool stratified = true;
148 std::uint64_t seed = 1;
149};
150
167
172 bool center = true;
173 bool scale = true;
175 int gpu_device = 0;
176 int n_threads = 1;
177 // Nonzero values scope reusable fold workspaces to one immutable data epoch.
178 std::uint64_t data_epoch = 0;
179};
180
185 bool center = true;
186 bool scale = true;
188 int gpu_device = 0;
189 int n_threads = 1;
190 std::uint64_t data_epoch = 0;
191
192 CorePLSLDAOptions() = default;
193
195 cv = options.cv;
198 center = options.center;
199 scale = options.scale;
200 backend = options.backend;
201 gpu_device = options.gpu_device;
202 n_threads = options.n_threads;
203 data_epoch = options.data_epoch;
204 return *this;
205 }
206
207 operator PLSOptions() const {
208 PLSOptions out;
209 out.cv = cv;
212 out.center = center;
213 out.scale = scale;
214 out.backend = backend;
216 out.n_threads = n_threads;
218 return out;
219 }
220};
221
223 int fold = 0;
224 int n_train = 0;
226 double accuracy = 0.0;
227};
228
230 std::vector<int> labels;
231 std::vector<int> counts;
232 std::size_t n_labels = 0;
233
234 int operator()(std::size_t truth, std::size_t predicted) const {
235 return counts[truth * n_labels + predicted];
236 }
237};
238
255
257 std::vector<int> predicted_labels;
258 std::vector<int> true_labels;
259 std::vector<int> fold_assignments;
260 std::vector<FoldResult> folds;
261 double global_accuracy = 0.0;
263 double runtime_seconds = 0.0;
264 double peak_memory_mb = 0.0;
266};
267
279
281 std::vector<int> predicted_labels;
282 std::vector<int> true_labels;
283 std::vector<int> fold_assignments;
284 std::vector<FoldResult> folds;
285 std::vector<double> accuracy_by_components;
287 double global_accuracy = 0.0;
289 double runtime_seconds = 0.0;
290 double peak_memory_mb = 0.0;
292};
293
295 int cycles = 100;
296 bool progress = false;
300 bool shake = false;
301 std::uint64_t seed = 1;
305 bool guarded_diversity = false;
310 KNNOptions options;
311 options.k = 30;
312 return options;
313 }();
314};
315
317 std::vector<int> clbest;
318 std::vector<int> clbest_dirty;
319 std::vector<int> cvpredbest;
320 double accbest = 0.0;
321 double scorebest = 0.0;
322 std::vector<double> vect_acc;
323 std::vector<double> vect_score;
324 std::vector<int> proposal_size;
325 std::vector<int> active_classes;
326 std::vector<unsigned char> accepted;
327 std::vector<unsigned char> improving_acceptance;
328 std::vector<unsigned char> temperature_acceptance;
329 std::vector<int> fold_assignments;
346 bool success = false;
347 double runtime_seconds = 0.0;
348 double peak_memory_mb = 0.0;
349};
350
352 std::vector<int> indices;
353 std::vector<float> distances;
354 int neighbors = 0;
356};
357
365
374 public:
378 ResidentIVFIndex& operator=(ResidentIVFIndex&&) noexcept;
379
381 ResidentIVFIndex& operator=(const ResidentIVFIndex&) = delete;
382
383 bool valid() const noexcept;
384 Backend backend() const noexcept;
385 DistanceMetric metric() const noexcept;
386 int rows() const noexcept;
387 int dimensions() const noexcept;
388 int nlist() const noexcept;
389 double build_seconds() const noexcept;
390
391 private:
392 struct Impl;
393 std::unique_ptr<Impl> impl_;
394
395 explicit ResidentIVFIndex(std::unique_ptr<Impl> impl);
396
399 const KNNOptions&
400 );
402 const ResidentIVFIndex&,
404 int,
406 );
408 const ResidentIVFIndex&,
409 int,
410 bool,
412 );
413};
414
419 int k = 30;
420 int n_threads = 1;
421 int n_iterations = 10;
422 int random_walk_steps = 4;
423 int target_clusters = 0;
424 int gpu_device = 0;
425 double prune = 0.0;
426 bool mutual = false;
427};
428
430 std::vector<int> membership;
431 double modularity = 0.0;
432 int n_communities = 0;
433 int n_vertices = 0;
434 int n_edges = 0;
435 int target_clusters = 0;
436 int target_gap = 0;
437 bool target_exact = true;
438 double runtime_seconds = 0.0;
439 Backend backend = Backend::CPU;
440};
441
443 int n_components = 2;
444 int n_threads = 1;
445 std::uint64_t seed = 4;
446 int gpu_device = 0;
447 Backend backend = Backend::CPU;
448};
449
451 std::vector<float> umap;
452 std::vector<float> opentsne;
453 int samples = 0;
454 int components = 2;
455 Backend backend = Backend::CPU;
456 double runtime_seconds = 0.0;
457};
458
460 std::string step;
461 double wall_seconds = 0.0;
462 double accumulated_seconds = 0.0;
463};
464
466 int neighbors = 100;
467 int n_threads = 1;
468 std::uint64_t seed = 1234;
469 DistanceMetric metric = DistanceMetric::Euclidean;
470 Backend backend = Backend::CPU;
471 KNNIndexType index_type = KNNIndexType::NativeHNSW;
472 int ivf_nlist = 0;
473 int ivf_nprobe = 0;
474 int gpu_device = 0;
475 bool materialize_graph = false;
476 std::vector<int> samples;
477};
478
479struct KODAMAGraphResult;
480
482 public:
483 struct Impl;
484
490 KODAMAGraphHandle& operator=(KODAMAGraphHandle&&) noexcept;
491
492 bool valid() const noexcept;
493 Backend backend() const noexcept;
494 int samples() const noexcept;
495 int neighbors() const noexcept;
496 bool host_materialized() const noexcept;
497
498 private:
499 explicit KODAMAGraphHandle(std::shared_ptr<Impl> impl);
500 std::shared_ptr<Impl> impl_;
501
502 friend struct detail::KODAMAGraphHandleAccess;
503 friend NeighborGraph KODAMAGraphMaterialize(const KODAMAGraphResult& graph);
504};
505
507 std::vector<KODAMAStageTiming> timings;
508 std::shared_ptr<KODAMAGraphHandle> handle;
511 std::vector<float> spatial_jitter;
513 int samples = 0;
514 int dimensions = 0;
515 int neighbors = 0;
516 int spatial_dimensions = 0;
517 int graph_builds = 0;
518 int spatial_graph_builds = 0;
519 Backend backend = Backend::CPU;
520 KNNIndexType index_type = KNNIndexType::NativeHNSW;
521 int ivf_nlist = 0;
522 int ivf_nprobe = 0;
523 double ivf_pilot_recall = 0.0;
524 double input_copy_seconds = 0.0;
525 double graph_seconds = 0.0;
526 double spatial_graph_seconds = 0.0;
527 double visual_init_seconds = 0.0;
528 double runtime_seconds = 0.0;
529 std::uint64_t graph_storage_bytes = 0;
530};
531
533 int runs = 100;
534 int cycles = 20;
535 int components = 50;
536 int landmarks = 10000;
537 int splitting = 0;
538 int graph_neighbors = 100;
539 int folds = 5;
540 int n_threads = 1;
541 int spatial_cols = 0;
542 double spatial_resolution = 0.4;
543 bool spatial_graph_mix = false;
544 int spatial_constraint_mode = 0;
545 SpatialCoordinateMode spatial_coordinate_mode = SpatialCoordinateMode::Standard;
546 std::uint64_t seed = 1234;
547 DistanceMetric metric = DistanceMetric::Euclidean;
548 Backend backend = Backend::CPU;
549 CoreClassifier classifier = CoreClassifier::KNN;
550 EvolutionPolicy evolution = EvolutionPolicy::standard();
551 bool progress = false;
552 bool apply_kodama_dissimilarity = true;
553 bool compute_visual_init = true;
554 bool materialize_graph = false;
555 GraphFeatureMode graph_feature_mode = GraphFeatureMode::LaplacianSelfTuning;
556 int graph_feature_components = 0;
557 int graph_feature_steps = 3;
558 std::vector<float> spatial;
559 std::vector<int> samples;
560 KNNOptions knn = [] {
561 KNNOptions options;
562 options.k = 30;
563 return options;
564 }();
566};
567
569 int run = 0;
570 int cycle = 0;
571 int proposal_size = 0;
572 int active_classes = 0;
573 unsigned char accepted = 0;
574 unsigned char improving_acceptance = 0;
575 unsigned char temperature_acceptance = 0;
576};
577
579 int run = 0;
580 int cycles_completed = 0;
581 int transition_attempted = 0;
582 int transition_accepted = 0;
583 int many_to_one_attempted = 0;
584 int many_to_one_accepted = 0;
585 int pls_coarsening_attempted = 0;
586 int pls_coarsening_accepted = 0;
587 int cv_evaluations = 0;
588 std::uint64_t landmark_rows_hash = 0;
589 std::uint64_t initial_labels_hash = 0;
590 std::uint64_t fold_assignments_hash = 0;
591};
592
594 std::vector<KODAMAStageTiming> timings;
595 std::vector<double> acc;
596 std::vector<double> v;
597 std::vector<int> res;
598 std::vector<int> res_constrain;
599 std::vector<int> landmark_occupied_strata;
601 std::vector<int> landmark_grid_bins;
602 std::vector<double> landmark_seconds;
603 std::vector<double> coarse_partition_seconds;
604 std::vector<double> landmark_sampling_seconds;
605 std::vector<double> constraint_seconds;
606 std::vector<double> landmark_prepare_seconds;
608 std::vector<double> landmark_graph_seconds;
609 std::vector<double> core_evolution_seconds;
610 std::vector<double> projection_seconds;
611 std::vector<CoreRunDiagnostic> run_diagnostics;
612 std::vector<CoreCycleDiagnostic> cycle_diagnostics;
615 int runs = 0;
616 int samples = 0;
617 int cycles = 0;
618 int res_constrain_rows = 0;
619 int effective_landmarks = 0;
620 int graph_builds = 0;
621 int spatial_graph_builds = 0;
622 int n_threads = 1;
623 Backend backend = Backend::CPU;
624 Backend graph_backend = Backend::CPU;
625 Backend optimization_backend = Backend::CPU;
626 Backend dissimilarity_backend = Backend::CPU;
627 KNNIndexType graph_index_type = KNNIndexType::NativeHNSW;
628 int graph_ivf_nlist = 0;
629 int graph_ivf_nprobe = 0;
630 int shared_landmark_partition_strata = 0;
631 double graph_ivf_pilot_recall = 0.0;
632 bool has_visual_init = false;
633 bool knn_is_kodama_corrected = false;
634 bool gpu_auto_workers = false;
635 bool gpu_scheduler_enabled = false;
636 bool shared_landmark_partition_used = false;
637 int gpu_scheduler_lanes = 0;
638 std::uint64_t kmeans_input_uploads = 0;
639 std::uint64_t projection_sparse_uploads = 0;
640 std::uint64_t projection_full_downloads = 0;
641 std::uint64_t result_row_uploads = 0;
642 std::uint64_t result_matrix_downloads = 0;
643 int gpu_sm_count = 0;
644 double gpu_free_memory_mb = 0.0;
645 double gpu_total_memory_mb = 0.0;
646 double gpu_worker_memory_estimate_mb = 0.0;
647 double runtime_seconds = 0.0;
648 double input_copy_seconds = 0.0;
649 double visual_init_seconds = 0.0;
650 double graph_feature_seconds = 0.0;
651 double spatial_precompute_seconds = 0.0;
652 double graph_seconds = 0.0;
653 double shared_landmark_partition_seconds = 0.0;
654 double spatial_graph_seconds = 0.0;
655 double optimization_wall_seconds = 0.0;
656 double optimization_sum_seconds = 0.0;
657 double dissimilarity_seconds = 0.0;
658 double peak_memory_mb = 0.0;
659 std::uint64_t graph_storage_bytes = 0;
660};
661
663 int n_components = 2;
664 int n_epochs = 200;
665 int n_neighbors = 30;
666 int negative_sample_rate = 5;
667 double learning_rate = 1.0;
668 double min_dist = 0.01;
669 double repulsion_strength = 1.0;
670 int spectral_n_iter = 20;
671 int n_threads = 1;
672 int seed = 1234;
673 int gpu_device = 0;
674 UMAPGraphMode graph_mode = UMAPGraphMode::Fuzzy;
675 std::vector<float> init;
676 std::string init_source;
677 Backend init_backend = Backend::Auto;
678};
679
681 int n_components = 2;
682 int n_neighbors = 0;
683 double perplexity = 30.0;
684 double theta = 0.5;
685 int early_exaggeration_iter = 250;
686 int n_iter = 500;
687 double early_exaggeration = 12.0;
688 double exaggeration = 1.0;
689 double learning_rate = 0.0;
690 bool learning_rate_auto = true;
691 double initial_momentum = 0.8;
692 double final_momentum = 0.8;
693 double min_gain = 0.01;
694 double max_step_norm = 5.0;
695 int n_threads = 1;
696 int seed = 4;
697 int gpu_device = 0;
698 std::vector<float> init;
699 std::string init_source;
700 Backend init_backend = Backend::Auto;
701};
702
704 std::vector<float> embedding;
705 int samples = 0;
706 int components = 2;
707 Backend backend = Backend::CPU;
708 std::string initialization;
709 Backend initialization_backend = Backend::Auto;
710 std::string optimizer;
711 std::size_t graph_edges = 0;
712 float graph_max_weight = 0.0f;
713 double runtime_seconds = 0.0;
714};
715
717 int n_components = 2;
718 bool center = true;
719 bool scale = false;
720 int oversample = -1;
721 int power_iterations = -1;
722 int n_threads = 1;
723 std::uint64_t seed = 4;
724 int gpu_device = 0;
725 Backend backend = Backend::CPU;
726};
727
728struct PCAResult {
729 std::vector<float> scores;
730 std::vector<float> loadings;
731 std::vector<float> singular_values;
732 std::vector<float> sdev;
733 std::vector<float> variance;
734 std::vector<float> variance_explained;
736 std::vector<float> center;
737 std::vector<float> scale;
738 int samples = 0;
739 int variables = 0;
740 int components = 0;
741 int oversample = 0;
742 int power_iterations = 0;
743 Backend backend = Backend::CPU;
744 double total_variance = 0.0;
745 double runtime_seconds = 0.0;
746};
747
750 std::vector<float> weights;
751 std::vector<float> response_loadings;
752 std::vector<float> scores;
753 std::vector<float> coefficients;
754 std::vector<float> fitted;
755 std::vector<float> x_center;
756 std::vector<float> x_scale;
757 std::vector<float> y_center;
758 int samples = 0;
759 int predictors = 0;
760 int responses = 0;
761 int components = 0;
762 Backend backend = Backend::CPU;
763 double runtime_seconds = 0.0;
764};
765
767 NormalizationMethod method = NormalizationMethod::PQN;
768 Backend backend = Backend::CPU;
769 int n_threads = 1;
770 int gpu_device = 0;
771 std::vector<float> reference;
772};
773
775 std::vector<float> train;
776 std::vector<float> test;
777 std::vector<float> train_coefficients;
778 std::vector<float> test_coefficients;
779 std::vector<float> reference;
780 std::size_t train_rows = 0;
781 std::size_t test_rows = 0;
782 std::size_t variables = 0;
783 NormalizationMethod method = NormalizationMethod::PQN;
784 Backend backend = Backend::CPU;
785 double runtime_seconds = 0.0;
786};
787
789 ScalingMethod method = ScalingMethod::Autoscaling;
790 Backend backend = Backend::CPU;
791 int n_threads = 1;
792 int gpu_device = 0;
793};
794
796 std::vector<float> train;
797 std::vector<float> test;
798 std::vector<float> center;
799 std::vector<float> scale;
800 std::size_t train_rows = 0;
801 std::size_t test_rows = 0;
802 std::size_t variables = 0;
803 ScalingMethod method = ScalingMethod::Autoscaling;
804 Backend backend = Backend::CPU;
805 double runtime_seconds = 0.0;
806};
807
809 int neighbors = 15;
810 Backend backend = Backend::CPU;
811 int n_threads = 1;
812 int gpu_device = 0;
813};
814
816 std::vector<float> values;
817 std::vector<float> sample_max_distances;
818 std::size_t samples = 0;
819 std::size_t variables = 0;
820 std::size_t sample_groups = 0;
821 int neighbors = 15;
822 Backend backend = Backend::CPU;
823 double graph_seconds = 0.0;
824 double aggregation_seconds = 0.0;
825 double runtime_seconds = 0.0;
826};
827
830 int n_threads = 1;
831 bool require_nonzero_each_sample = true;
832};
833
840 std::vector<float> score;
841 std::vector<double> p_value;
842 std::vector<double> adjusted_p_value;
843 std::vector<float> per_sample_score;
844 std::vector<double> per_sample_p_value;
845 std::vector<int> ranking;
846 std::vector<int> sample_labels;
847 std::vector<int> basis_dimensions;
848 std::size_t samples = 0;
849 std::size_t variables = 0;
850 std::size_t sample_groups = 0;
851 Backend backend = Backend::CPU;
852 double basis_seconds = 0.0;
853 double statistic_seconds = 0.0;
854 double runtime_seconds = 0.0;
855};
856
858 MatrixView x,
859 const std::vector<int>& labels,
860 const std::vector<int>& constrain,
861 const KNNOptions& options = KNNOptions()
862);
863
865 MatrixView x,
866 const std::vector<int>& labels,
867 const std::vector<int>& constrain,
868 const KNNOptions& options = KNNOptions()
869);
870
872 MatrixView x,
873 const std::vector<int>& labels,
874 const std::vector<int>& constrain,
875 const KNNOptions& options = KNNOptions()
876);
877
879 MatrixView x,
880 const std::vector<int>& labels,
881 const std::vector<int>& constrain,
882 const KNNOptions& options = KNNOptions()
883);
884
886 MatrixView x,
887 const std::vector<int>& labels,
888 const std::vector<int>& constrain,
889 const PLSOptions& options = PLSOptions()
890);
891
893 MatrixView x,
894 const std::vector<int>& labels,
895 const std::vector<int>& constrain,
896 const PLSOptions& options = PLSOptions()
897);
898
900 MatrixView x,
901 const std::vector<int>& labels,
902 const std::vector<int>& constrain,
903 const PLSOptions& options = PLSOptions()
904);
905
907 MatrixView x,
908 const std::vector<int>& labels,
909 const std::vector<int>& constrain,
910 const PLSOptions& options = PLSOptions()
911);
912
914 MatrixView x,
915 const std::vector<int>& labels,
916 const std::vector<int>& constrain,
917 const PLSOptions& options = PLSOptions()
918);
919
921 MatrixView x,
922 const std::vector<int>& labels,
923 const std::vector<int>& constrain,
924 const PLSOptions& options = PLSOptions()
925);
926
928 MatrixView x,
929 const std::vector<int>& labels,
930 const std::vector<int>& constrain,
931 const PLSOptions& options = PLSOptions()
932);
933
934std::vector<int> PLSLDAPredict_CPU(
935 MatrixView train,
936 const std::vector<int>& labels,
937 MatrixView test,
938 const PLSOptions& options = PLSOptions()
939);
940
941std::vector<int> PLSLDAPredict_CUDA(
942 MatrixView train,
943 const std::vector<int>& labels,
944 MatrixView test,
945 const PLSOptions& options = PLSOptions()
946);
947
948std::vector<int> PLSLDAPredict_METAL(
949 MatrixView train,
950 const std::vector<int>& labels,
951 MatrixView test,
952 const PLSOptions& options = PLSOptions()
953);
954
955std::vector<int> PLSLDAPredict(
956 MatrixView train,
957 const std::vector<int>& labels,
958 MatrixView test,
959 const PLSOptions& options = PLSOptions()
960);
961
963 MatrixView x,
964 const std::vector<int>& clbest,
965 const std::vector<int>& constrain,
966 const std::vector<int>& fixed,
967 const CoreOptions& options = CoreOptions()
968);
969
971 MatrixView x,
972 const std::vector<int>& clbest,
973 const std::vector<int>& constrain,
974 const std::vector<int>& fixed,
975 const CoreOptions& options = CoreOptions()
976);
977
979 MatrixView x,
980 const std::vector<int>& clbest,
981 const std::vector<int>& constrain,
982 const std::vector<int>& fixed,
983 const CoreOptions& options = CoreOptions()
984);
985
987 MatrixView x,
988 const std::vector<int>& clbest,
989 const std::vector<int>& constrain,
990 const std::vector<int>& fixed,
991 const CoreOptions& options = CoreOptions()
992);
993
995 MatrixView x,
996 const std::vector<int>& clbest,
997 const std::vector<int>& constrain,
998 const std::vector<int>& fixed,
999 const CoreOptions& options = CoreOptions()
1000);
1001
1003 MatrixView x,
1004 const std::vector<int>& clbest,
1005 const std::vector<int>& constrain,
1006 const std::vector<int>& fixed,
1007 const CoreOptions& options = CoreOptions()
1008);
1009
1011 MatrixView x,
1012 const std::vector<int>& clbest,
1013 const std::vector<int>& constrain,
1014 const std::vector<int>& fixed,
1015 const CoreOptions& options = CoreOptions()
1016);
1017
1019 MatrixView x,
1020 const std::vector<int>& clbest,
1021 const std::vector<int>& constrain,
1022 const std::vector<int>& fixed,
1023 const CoreOptions& options = CoreOptions()
1024);
1025
1027 MatrixView x,
1028 const std::vector<int>& clbest,
1029 const std::vector<int>& constrain,
1030 const std::vector<int>& fixed,
1031 const CoreOptions& options = CoreOptions()
1032);
1033
1035 const NeighborGraph& graph,
1036 int samples,
1037 const std::vector<int>& clbest,
1038 const std::vector<int>& constrain,
1039 const std::vector<int>& fixed,
1040 const CoreOptions& options = CoreOptions()
1041);
1042
1044 const NeighborGraph& graph,
1045 int samples,
1046 const std::vector<int>& initial_clbest,
1047 const std::vector<int>& constrain = std::vector<int>(),
1048 const std::vector<int>& fixed = std::vector<int>(),
1049 const CoreOptions& options = CoreOptions()
1050);
1051
1053 const NeighborGraph& graph,
1054 int samples,
1055 const std::vector<int>& initial_clbest,
1056 const std::vector<int>& constrain = std::vector<int>(),
1057 const std::vector<int>& fixed = std::vector<int>(),
1058 const CoreOptions& options = CoreOptions()
1059);
1060
1062 MatrixView x,
1063 const std::vector<int>& clbest,
1064 const std::vector<int>& constrain,
1065 const std::vector<int>& fixed,
1066 const CoreOptions& options = CoreOptions()
1067);
1068
1070 MatrixView x,
1071 const std::vector<int>& starting_labels = std::vector<int>(),
1072 const std::vector<int>& constrain = std::vector<int>(),
1073 const std::vector<int>& fixed = std::vector<int>(),
1074 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1075);
1076
1078 MatrixView x,
1079 const std::vector<int>& starting_labels = std::vector<int>(),
1080 const std::vector<int>& constrain = std::vector<int>(),
1081 const std::vector<int>& fixed = std::vector<int>(),
1082 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1083);
1084
1086 MatrixView x,
1087 const std::vector<int>& starting_labels = std::vector<int>(),
1088 const std::vector<int>& constrain = std::vector<int>(),
1089 const std::vector<int>& fixed = std::vector<int>(),
1090 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1091);
1092
1094 MatrixView x,
1095 const std::vector<int>& starting_labels = std::vector<int>(),
1096 const std::vector<int>& constrain = std::vector<int>(),
1097 const std::vector<int>& fixed = std::vector<int>(),
1098 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1099);
1100
1102 MatrixView x,
1103 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1104);
1105
1107 MatrixView x,
1108 MatrixView spatial,
1109 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1110);
1111
1113 MatrixView x,
1114 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1115);
1116
1118 MatrixView x,
1119 MatrixView spatial,
1120 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1121);
1122
1124 MatrixView x,
1125 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1126);
1127
1129 MatrixView x,
1130 MatrixView spatial,
1131 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1132);
1133
1135 MatrixView x,
1136 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1137);
1138
1141 const std::vector<float>& spatial,
1142 int rows,
1143 int columns,
1144 const std::vector<int>& samples
1145);
1146
1149
1151 MatrixView x,
1152 MatrixView spatial,
1153 const KODAMAGraphOptions& options = KODAMAGraphOptions()
1154);
1155
1157 MatrixView x,
1158 const KODAMAGraphResult& graph,
1159 const std::vector<int>& starting_labels = std::vector<int>(),
1160 const std::vector<int>& constrain = std::vector<int>(),
1161 const std::vector<int>& fixed = std::vector<int>(),
1162 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1163);
1164
1166 const KODAMAGraphResult& graph,
1167 const std::vector<int>& starting_labels = std::vector<int>(),
1168 const std::vector<int>& constrain = std::vector<int>(),
1169 const std::vector<int>& fixed = std::vector<int>(),
1170 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1171);
1172
1182 NeighborGraph& graph,
1183 const std::vector<int>& run_labels,
1184 int runs,
1185 int samples,
1186 Backend backend = Backend::CPU,
1187 int n_threads = 1,
1188 int gpu_device = 0
1189);
1190
1191std::vector<float> KODAMAGraphFeatures_CPU(
1192 const NeighborGraph& graph,
1193 int samples,
1194 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1195);
1196
1198 const NeighborGraph& graph,
1199 int samples,
1200 const std::vector<int>& starting_labels = std::vector<int>(),
1201 const std::vector<int>& constrain = std::vector<int>(),
1202 const std::vector<int>& fixed = std::vector<int>(),
1203 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1204);
1205
1207 MatrixView x,
1208 const NeighborGraph& graph,
1209 const std::vector<int>& starting_labels = std::vector<int>(),
1210 const std::vector<int>& constrain = std::vector<int>(),
1211 const std::vector<int>& fixed = std::vector<int>(),
1212 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1213);
1214
1216 MatrixView x,
1217 const NeighborGraph& graph,
1218 const std::vector<int>& starting_labels = std::vector<int>(),
1219 const std::vector<int>& constrain = std::vector<int>(),
1220 const std::vector<int>& fixed = std::vector<int>(),
1221 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1222);
1223
1225 MatrixView x,
1226 const NeighborGraph& graph,
1227 const std::vector<int>& starting_labels = std::vector<int>(),
1228 const std::vector<int>& constrain = std::vector<int>(),
1229 const std::vector<int>& fixed = std::vector<int>(),
1230 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1231);
1232
1234 MatrixView x,
1235 const NeighborGraph& graph,
1236 const std::vector<int>& starting_labels = std::vector<int>(),
1237 const std::vector<int>& constrain = std::vector<int>(),
1238 const std::vector<int>& fixed = std::vector<int>(),
1239 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1240);
1241
1243 const NeighborGraph& graph,
1244 int samples,
1245 const std::vector<int>& starting_labels = std::vector<int>(),
1246 const std::vector<int>& constrain = std::vector<int>(),
1247 const std::vector<int>& fixed = std::vector<int>(),
1248 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1249);
1250
1252 const NeighborGraph& graph,
1253 int samples,
1254 const std::vector<int>& starting_labels = std::vector<int>(),
1255 const std::vector<int>& constrain = std::vector<int>(),
1256 const std::vector<int>& fixed = std::vector<int>(),
1257 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1258);
1259
1261 const NeighborGraph& graph,
1262 int samples,
1263 const std::vector<int>& starting_labels = std::vector<int>(),
1264 const std::vector<int>& constrain = std::vector<int>(),
1265 const std::vector<int>& fixed = std::vector<int>(),
1266 const KODAMAMatrixOptions& options = KODAMAMatrixOptions()
1267);
1268
1270 const NeighborGraph& graph,
1271 const UMAPOptions& options = UMAPOptions()
1272);
1273
1275 const NeighborGraph& graph,
1276 MatrixView raw_data,
1277 const UMAPOptions& options = UMAPOptions()
1278);
1279
1281 const NeighborGraph& graph,
1282 const UMAPOptions& options = UMAPOptions()
1283);
1284
1286 const NeighborGraph& graph,
1287 const UMAPOptions& options = UMAPOptions()
1288);
1289
1291 const NeighborGraph& graph,
1292 MatrixView raw_data,
1293 const UMAPOptions& options = UMAPOptions()
1294);
1295
1297 const NeighborGraph& graph,
1298 MatrixView raw_data,
1299 const UMAPOptions& options = UMAPOptions()
1300);
1301
1303 const NeighborGraph& graph,
1304 const OpenTSNEOptions& options = OpenTSNEOptions()
1305);
1306
1308 const NeighborGraph& graph,
1309 MatrixView raw_data,
1310 const OpenTSNEOptions& options = OpenTSNEOptions()
1311);
1312
1314 const NeighborGraph& graph,
1315 const OpenTSNEOptions& options = OpenTSNEOptions()
1316);
1317
1319 const NeighborGraph& graph,
1320 MatrixView raw_data,
1321 const OpenTSNEOptions& options = OpenTSNEOptions()
1322);
1323
1325 const NeighborGraph& graph,
1326 const OpenTSNEOptions& options = OpenTSNEOptions()
1327);
1328
1330 const NeighborGraph& graph,
1331 MatrixView raw_data,
1332 const OpenTSNEOptions& options = OpenTSNEOptions()
1333);
1334
1336 MatrixView raw_data,
1338);
1339
1341 MatrixView x,
1342 const PCAOptions& options = PCAOptions()
1343);
1344
1346 MatrixView x,
1347 const PCAOptions& options = PCAOptions()
1348);
1349
1351 MatrixView x,
1352 const PCAOptions& options = PCAOptions()
1353);
1354
1356 MatrixView x,
1357 const PCAOptions& options = PCAOptions()
1358);
1359
1361 MatrixView x,
1362 const PCAOptions& options = PCAOptions()
1363);
1364
1366 MatrixView x,
1367 MatrixView y,
1368 const PLSOptions& options = PLSOptions()
1369);
1370
1372 MatrixView x,
1373 MatrixView y,
1374 const PLSOptions& options = PLSOptions()
1375);
1376
1378 MatrixView x,
1379 MatrixView y,
1380 const PLSOptions& options = PLSOptions()
1381);
1382
1384 MatrixView x,
1385 MatrixView y,
1386 const PLSOptions& options = PLSOptions()
1387);
1388
1390 MatrixView train,
1391 MatrixView test = MatrixView(),
1393);
1394
1396 MatrixView train,
1397 const NormalizationOptions& options
1398);
1399
1401 MatrixView train,
1402 MatrixView test = MatrixView(),
1404);
1405
1407 MatrixView train,
1408 const NormalizationOptions& options
1409);
1410
1412 MatrixView train,
1413 MatrixView test = MatrixView(),
1415);
1416
1418 MatrixView train,
1419 const NormalizationOptions& options
1420);
1421
1423 MatrixView train,
1424 MatrixView test = MatrixView(),
1426);
1427
1429 MatrixView train,
1430 const NormalizationOptions& options
1431);
1432
1434 MatrixView train,
1435 MatrixView test = MatrixView(),
1436 const ScalingOptions& options = ScalingOptions()
1437);
1438
1440 MatrixView train,
1441 const ScalingOptions& options
1442);
1443
1445 MatrixView train,
1446 MatrixView test = MatrixView(),
1447 const ScalingOptions& options = ScalingOptions()
1448);
1449
1451 MatrixView train,
1452 const ScalingOptions& options
1453);
1454
1456 MatrixView train,
1457 MatrixView test = MatrixView(),
1458 const ScalingOptions& options = ScalingOptions()
1459);
1460
1462 MatrixView train,
1463 const ScalingOptions& options
1464);
1465
1467 MatrixView train,
1468 MatrixView test = MatrixView(),
1469 const ScalingOptions& options = ScalingOptions()
1470);
1471
1473 MatrixView train,
1474 const ScalingOptions& options
1475);
1476
1478 MatrixView data,
1479 MatrixView spatial,
1480 const std::vector<int>& samples = {},
1481 const PassingMessageOptions& options = PassingMessageOptions()
1482);
1483
1485 MatrixView data,
1486 MatrixView spatial,
1487 const std::vector<int>& samples = {},
1488 const PassingMessageOptions& options = PassingMessageOptions()
1489);
1490
1492 MatrixView data,
1493 MatrixView spatial,
1494 const std::vector<int>& samples = {},
1495 const PassingMessageOptions& options = PassingMessageOptions()
1496);
1497
1499 MatrixView data,
1500 MatrixView spatial,
1501 const std::vector<int>& samples = {},
1502 const PassingMessageOptions& options = PassingMessageOptions()
1503);
1504
1506 MatrixView data,
1507 MatrixView spatial,
1508 const std::vector<int>& samples = {},
1509 const SpatialFeatureOptions& options = SpatialFeatureOptions()
1510);
1511
1513 MatrixView data,
1514 MatrixView spatial,
1515 const std::vector<int>& samples = {},
1516 const SpatialFeatureOptions& options = SpatialFeatureOptions()
1517);
1518
1520 MatrixView x,
1521 const GraphClusterOptions& options = GraphClusterOptions()
1522);
1523
1525 MatrixView x,
1526 const GraphClusterOptions& options = GraphClusterOptions()
1527);
1528
1530 MatrixView x,
1531 const GraphClusterOptions& options = GraphClusterOptions()
1532);
1533
1535 MatrixView x,
1536 const GraphClusterOptions& options = GraphClusterOptions()
1537);
1538
1540 MatrixView train,
1541 const KNNOptions& options = KNNOptions()
1542);
1543
1551 const ResidentIVFIndex& index,
1552 MatrixView query,
1553 int k,
1554 ResidentIVFSearchStats* stats = nullptr
1555);
1556
1562 const ResidentIVFIndex& index,
1563 int k,
1564 bool exclude_self = true,
1565 ResidentIVFSearchStats* stats = nullptr
1566);
1567
1569 const NeighborGraph& graph,
1570 int samples,
1571 const GraphClusterOptions& options = GraphClusterOptions()
1572);
1573
1575 const NeighborGraph& graph,
1576 int samples,
1577 const GraphClusterOptions& options = GraphClusterOptions()
1578);
1579
1581 MatrixView embedding,
1582 const NeighborGraph& graph,
1583 const GraphClusterOptions& options = GraphClusterOptions()
1584);
1585
1587 MatrixView embedding,
1588 const GraphClusterOptions& options = GraphClusterOptions()
1589);
1590
1591const char* to_string(Backend backend);
1592const char* to_string(DistanceMetric metric);
1593const char* to_string(KNNIndexType index_type);
1594const char* to_string(PLSMode mode);
1595const char* to_string(CoreClassifier classifier);
1596const char* to_string(GraphWeightType weight_type);
1597const char* to_string(GraphFeatureMode mode);
1599
1600} // namespace kodama
KODAMAGraphHandle(KODAMAGraphHandle &&) noexcept
KODAMAGraphHandle & operator=(const KODAMAGraphHandle &) noexcept
KODAMAGraphHandle(const KODAMAGraphHandle &) noexcept
ResidentIVFIndex(ResidentIVFIndex &&) noexcept
double build_seconds() const noexcept
bool valid() const noexcept
Backend backend() const noexcept
int dimensions() const noexcept
int nlist() const noexcept
friend ResidentIVFIndex BuildResidentIVFIndex(MatrixView, const KNNOptions &)
friend NeighborGraph SearchResidentIVFIndexSelf(const ResidentIVFIndex &, int, bool, ResidentIVFSearchStats *)
friend NeighborGraph SearchResidentIVFIndex(const ResidentIVFIndex &, MatrixView, int, ResidentIVFSearchStats *)
DistanceMetric metric() const noexcept
int rows() const noexcept
KODAMAGraphResult KODAMAGraph_CPU(MatrixView x, const KODAMAGraphOptions &options=KODAMAGraphOptions())
PassingMessageResult PassingMessage_CUDA(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const PassingMessageOptions &options=PassingMessageOptions())
CoreResult CoreKNN_METAL(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
CoreResult core_cpp(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
ResidentIVFIndex BuildResidentIVFIndex(MatrixView train, const KNNOptions &options=KNNOptions())
NeighborGraph KODAMAKNNGraph_METAL(MatrixView x, const GraphClusterOptions &options=GraphClusterOptions())
DistanceMetric
Definition kodama.hpp:27
CoreResult Core(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
PCAResult RSVD(MatrixView x, const PCAOptions &options=PCAOptions())
EmbeddingResult KODAMAOpenTSNE_CUDA(const NeighborGraph &graph, const OpenTSNEOptions &options=OpenTSNEOptions())
PassingMessageResult PassingMessage(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const PassingMessageOptions &options=PassingMessageOptions())
ScalingMethod
Definition kodama.hpp:106
CoreResult CoreKNNGraph_CUDA(const NeighborGraph &graph, int samples, const std::vector< int > &initial_clbest, const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const CoreOptions &options=CoreOptions())
KODAMAMatrixResult KODAMAMatrixFromGraph_CUDA(const NeighborGraph &graph, int samples, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
NeighborGraph SearchResidentIVFIndex(const ResidentIVFIndex &index, MatrixView query, int k, ResidentIVFSearchStats *stats=nullptr)
KODAMAMatrixResult KODAMAMatrixFromGraphData(MatrixView x, const NeighborGraph &graph, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
KNNCVResult KNNCV_CPU(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const KNNOptions &options=KNNOptions())
PCAResult PCA(MatrixView x, const PCAOptions &options=PCAOptions())
KODAMAGraphResult KODAMAGraph(MatrixView x, const KODAMAGraphOptions &options=KODAMAGraphOptions())
KODAMAMatrixResult KODAMAMatrixFromGraphData_METAL(MatrixView x, const NeighborGraph &graph, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
KNNCVResult KNNCV(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const KNNOptions &options=KNNOptions())
NormalizationResult Normalization_CUDA(MatrixView train, MatrixView test=MatrixView(), const NormalizationOptions &options=NormalizationOptions())
NeighborGraph KODAMAKNNGraph(MatrixView x, const GraphClusterOptions &options=GraphClusterOptions())
NormalizationMethod
Definition kodama.hpp:98
void KODAMADissimilarityInPlace(NeighborGraph &graph, const std::vector< int > &run_labels, int runs, int samples, Backend backend=Backend::CPU, int n_threads=1, int gpu_device=0)
PLSCVResult PLSLDACV(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
KNNCVResult KNNCV_METAL(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const KNNOptions &options=KNNOptions())
GraphClusterResult KODAMAEmbeddingCluster(MatrixView embedding, const GraphClusterOptions &options=GraphClusterOptions())
EmbeddingResult KODAMAUMAP_METAL(const NeighborGraph &graph, const UMAPOptions &options=UMAPOptions())
PLSCVResult PLSDACV_CUDA(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
PassingMessageResult PassingMessage_CPU(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const PassingMessageOptions &options=PassingMessageOptions())
GraphIndexBase
Definition kodama.hpp:92
PLSCVResult PLSLDACV_METAL(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
VisualizationInitResult KODAMAVisualizationPCAInit(MatrixView raw_data, const VisualizationInitOptions &options=VisualizationInitOptions())
EmbeddingResult KODAMAOpenTSNE_METAL(const NeighborGraph &graph, const OpenTSNEOptions &options=OpenTSNEOptions())
UMAPGraphMode
Definition kodama.hpp:82
NeighborGraph KODAMAKNNGraph_CUDA(MatrixView x, const GraphClusterOptions &options=GraphClusterOptions())
EmbeddingResult KODAMAUMAP_CPU(const NeighborGraph &graph, const UMAPOptions &options=UMAPOptions())
std::vector< float > KODAMASeparateSpatialSamples(const std::vector< float > &spatial, int rows, int columns, const std::vector< int > &samples)
const char * to_string(Backend backend)
CoreResult CoreKNN_CUDA(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
NormalizationResult Normalization(MatrixView train, MatrixView test=MatrixView(), const NormalizationOptions &options=NormalizationOptions())
KODAMAMatrixResult KODAMAMatrixFromGraphData_CPU(MatrixView x, const NeighborGraph &graph, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
KODAMAGraphResult KODAMAGraph_METAL(MatrixView x, const KODAMAGraphOptions &options=KODAMAGraphOptions())
ScalingResult Scaling_CUDA(MatrixView train, MatrixView test=MatrixView(), const ScalingOptions &options=ScalingOptions())
ScalingResult Scaling_CPU(MatrixView train, MatrixView test=MatrixView(), const ScalingOptions &options=ScalingOptions())
PLSFitResult PLS_METAL(MatrixView x, MatrixView y, const PLSOptions &options=PLSOptions())
CoreClassifier
Definition kodama.hpp:47
EmbeddingResult KODAMAUMAP_CUDA(const NeighborGraph &graph, const UMAPOptions &options=UMAPOptions())
CoreResult CoreKNNGraph_METAL(const NeighborGraph &graph, int samples, const std::vector< int > &initial_clbest, const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const CoreOptions &options=CoreOptions())
KODAMAMatrixResult KODAMAMatrix(MatrixView x, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
NeighborGraph KODAMAKNNGraph_CPU(MatrixView x, const GraphClusterOptions &options=GraphClusterOptions())
KODAMAMatrixResult KODAMAMatrix_CPU(MatrixView x, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
CoreResult CoreKNN_CPU(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
PCAResult PCA_CPU(MatrixView x, const PCAOptions &options=PCAOptions())
CoreResult CorePLSLDA_CUDA(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
std::vector< int > PLSLDAPredict_METAL(MatrixView train, const std::vector< int > &labels, MatrixView test, const PLSOptions &options=PLSOptions())
GraphClusterResult KODAMAEmbeddingGraphCluster(MatrixView embedding, const NeighborGraph &graph, const GraphClusterOptions &options=GraphClusterOptions())
CoreResult CorePLSLDA_METAL(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
CoreResult CorePLSLDA(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
bool MetalAvailable()
PassingMessageResult PassingMessage_METAL(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const PassingMessageOptions &options=PassingMessageOptions())
PLSFitResult PLS_CUDA(MatrixView x, MatrixView y, const PLSOptions &options=PLSOptions())
ScalingResult Scaling(MatrixView train, MatrixView test=MatrixView(), const ScalingOptions &options=ScalingOptions())
PLSCVResult PLSLDACV_CUDA(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
std::vector< int > PLSLDAPredict_CUDA(MatrixView train, const std::vector< int > &labels, MatrixView test, const PLSOptions &options=PLSOptions())
PCAResult PCA_METAL(MatrixView x, const PCAOptions &options=PCAOptions())
PLSCVResult PLSLDACV_CPU(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
SpatialFeatureResult SpatialFeatureSelection(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const SpatialFeatureOptions &options=SpatialFeatureOptions())
EmbeddingResult KODAMAOpenTSNE_CPU(const NeighborGraph &graph, const OpenTSNEOptions &options=OpenTSNEOptions())
NeighborGraph KODAMAGraphMaterialize(const KODAMAGraphResult &graph)
PLSFitResult PLS(MatrixView x, MatrixView y, const PLSOptions &options=PLSOptions())
GraphWeightType
Definition kodama.hpp:66
NormalizationResult Normalization_METAL(MatrixView train, MatrixView test=MatrixView(), const NormalizationOptions &options=NormalizationOptions())
std::vector< int > PLSLDAPredict_CPU(MatrixView train, const std::vector< int > &labels, MatrixView test, const PLSOptions &options=PLSOptions())
KODAMAMatrixResult KODAMAMatrixFromGraph(const NeighborGraph &graph, int samples, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
PLSFitResult PLS_CPU(MatrixView x, MatrixView y, const PLSOptions &options=PLSOptions())
KODAMAMatrixResult KODAMAMatrix_METAL(MatrixView x, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
GraphClusterResult KODAMAGraphCluster(const NeighborGraph &graph, int samples, const GraphClusterOptions &options=GraphClusterOptions())
PCAResult PCA_CUDA(MatrixView x, const PCAOptions &options=PCAOptions())
MatrixValueType
Definition kodama.hpp:87
std::vector< float > KODAMAGraphFeatures_CPU(const NeighborGraph &graph, int samples, const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
CoreResult CorePLSLDA_CPU(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
KODAMAMatrixResult KODAMAMatrixFromGraphData_CUDA(MatrixView x, const NeighborGraph &graph, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
NeighborGraph SearchResidentIVFIndexSelf(const ResidentIVFIndex &index, int k, bool exclude_self=true, ResidentIVFSearchStats *stats=nullptr)
KODAMAGraphResult KODAMAGraph_CUDA(MatrixView x, const KODAMAGraphOptions &options=KODAMAGraphOptions())
KNNIndexType
Definition kodama.hpp:33
CoreResult CoreKNN(MatrixView x, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
KODAMAMatrixResult KODAMAMatrix_CUDA(MatrixView x, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
SpatialCoordinateMode
Definition kodama.hpp:77
std::vector< int > PLSLDAPredict(MatrixView train, const std::vector< int > &labels, MatrixView test, const PLSOptions &options=PLSOptions())
CoreResult CoreKNNGraph_CPU(const NeighborGraph &graph, int samples, const std::vector< int > &clbest, const std::vector< int > &constrain, const std::vector< int > &fixed, const CoreOptions &options=CoreOptions())
SpatialFeatureResult SpatialFeatureSelection_CPU(MatrixView data, MatrixView spatial, const std::vector< int > &samples={}, const SpatialFeatureOptions &options=SpatialFeatureOptions())
PLSCVResult PLSDACV(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
KODAMAMatrixResult KODAMAMatrixFromGraph_CPU(const NeighborGraph &graph, int samples, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
GraphClusterResult KODAMAGraphCluster_CPU(const NeighborGraph &graph, int samples, const GraphClusterOptions &options=GraphClusterOptions())
KODAMAMatrixResult KODAMAMatrixFromGraph_METAL(const NeighborGraph &graph, int samples, const std::vector< int > &starting_labels=std::vector< int >(), const std::vector< int > &constrain=std::vector< int >(), const std::vector< int > &fixed=std::vector< int >(), const KODAMAMatrixOptions &options=KODAMAMatrixOptions())
KNNCVResult KNNCV_CUDA(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const KNNOptions &options=KNNOptions())
NormalizationResult Normalization_CPU(MatrixView train, MatrixView test=MatrixView(), const NormalizationOptions &options=NormalizationOptions())
PLSCVResult PLSDACV_CPU(MatrixView x, const std::vector< int > &labels, const std::vector< int > &constrain, const PLSOptions &options=PLSOptions())
GraphFeatureMode
Definition kodama.hpp:73
ScalingResult Scaling_METAL(MatrixView train, MatrixView test=MatrixView(), const ScalingOptions &options=ScalingOptions())
int operator()(std::size_t truth, std::size_t predicted) const
Definition kodama.hpp:234
std::vector< int > labels
Definition kodama.hpp:230
std::vector< int > counts
Definition kodama.hpp:231
CorePLSLDAOptions pls
Definition kodama.hpp:308
bool adaptive_proposal_size
Definition kodama.hpp:306
bool many_to_one_absorption
Definition kodama.hpp:303
CoreClassifier classifier
Definition kodama.hpp:299
EvolutionPolicy evolution
Definition kodama.hpp:307
std::uint64_t seed
Definition kodama.hpp:301
std::uint64_t data_epoch
Definition kodama.hpp:190
CorePLSLDAOptions & operator=(const PLSOptions &options)
Definition kodama.hpp:194
std::vector< unsigned char > accepted
Definition kodama.hpp:326
std::vector< int > clbest_dirty
Definition kodama.hpp:318
std::vector< int > active_classes
Definition kodama.hpp:325
int pls_coarsening_accepted
Definition kodama.hpp:344
std::vector< int > clbest
Definition kodama.hpp:317
std::vector< int > cvpredbest
Definition kodama.hpp:319
double peak_memory_mb
Definition kodama.hpp:348
double runtime_seconds
Definition kodama.hpp:347
int stochastic_state_attempts
Definition kodama.hpp:334
int stochastic_state_accepts
Definition kodama.hpp:335
int pls_coarsening_attempted
Definition kodama.hpp:343
int current_state_rejections
Definition kodama.hpp:336
std::vector< int > proposal_size
Definition kodama.hpp:324
std::vector< double > vect_score
Definition kodama.hpp:323
std::vector< double > vect_acc
Definition kodama.hpp:322
std::vector< unsigned char > temperature_acceptance
Definition kodama.hpp:328
std::vector< unsigned char > improving_acceptance
Definition kodama.hpp:327
std::vector< int > fold_assignments
Definition kodama.hpp:329
std::string optimizer
Definition kodama.hpp:710
std::string initialization
Definition kodama.hpp:708
std::vector< float > embedding
Definition kodama.hpp:704
static EvolutionPolicy from_name(const std::string &name)
static EvolutionPolicy standard()
std::uint64_t seed
Definition kodama.hpp:148
std::vector< int > membership
Definition kodama.hpp:430
std::vector< int > fold_assignments
Definition kodama.hpp:259
ConfusionMatrix confusion
Definition kodama.hpp:262
KNNParametersUsed parameters
Definition kodama.hpp:265
std::vector< FoldResult > folds
Definition kodama.hpp:260
std::vector< int > true_labels
Definition kodama.hpp:258
std::vector< int > predicted_labels
Definition kodama.hpp:257
double hnsw_target_recall
Definition kodama.hpp:163
FoldOptions cv
Definition kodama.hpp:152
DistanceMetric metric
Definition kodama.hpp:154
KNNIndexType index_type
Definition kodama.hpp:156
DistanceMetric metric
Definition kodama.hpp:242
KNNIndexType index_type
Definition kodama.hpp:241
std::vector< int > samples
Definition kodama.hpp:476
VisualizationInitResult visual_init
Definition kodama.hpp:512
std::vector< KODAMAStageTiming > timings
Definition kodama.hpp:507
std::shared_ptr< KODAMAGraphHandle > handle
Definition kodama.hpp:508
std::vector< float > spatial_jitter
Definition kodama.hpp:511
NeighborGraph spatial_knn
Definition kodama.hpp:510
CorePLSLDAOptions pls
Definition kodama.hpp:565
std::vector< float > spatial
Definition kodama.hpp:558
std::vector< int > samples
Definition kodama.hpp:559
std::vector< int > landmark_occupied_strata
Definition kodama.hpp:599
std::vector< double > coarse_partition_seconds
Definition kodama.hpp:603
std::vector< double > core_evolution_seconds
Definition kodama.hpp:609
std::vector< double > v
Definition kodama.hpp:596
std::vector< int > landmark_grid_bins
Definition kodama.hpp:601
std::vector< double > acc
Definition kodama.hpp:595
std::vector< CoreCycleDiagnostic > cycle_diagnostics
Definition kodama.hpp:612
std::vector< double > landmark_prepare_seconds
Definition kodama.hpp:606
std::vector< double > projection_seconds
Definition kodama.hpp:610
VisualizationInitResult visual_init
Definition kodama.hpp:614
std::vector< double > landmark_graph_seconds
Definition kodama.hpp:608
std::vector< CoreRunDiagnostic > run_diagnostics
Definition kodama.hpp:611
std::vector< int > landmark_represented_strata
Definition kodama.hpp:600
std::vector< double > landmark_sampling_seconds
Definition kodama.hpp:604
std::vector< double > constraint_seconds
Definition kodama.hpp:605
std::vector< int > res
Definition kodama.hpp:597
std::vector< int > res_constrain
Definition kodama.hpp:598
std::vector< KODAMAStageTiming > timings
Definition kodama.hpp:594
std::vector< double > landmark_seconds
Definition kodama.hpp:602
std::vector< double > landmark_initialization_seconds
Definition kodama.hpp:607
MatrixValueType value_type
Definition kodama.hpp:118
const void * data
Definition kodama.hpp:115
std::size_t cols
Definition kodama.hpp:117
double operator()(std::size_t i, std::size_t j) const
Definition kodama.hpp:136
MatrixView()=default
MatrixView(const double *data_ptr, std::size_t n_rows, std::size_t n_cols)
Definition kodama.hpp:122
float value_float(std::size_t i, std::size_t j) const
Definition kodama.hpp:128
MatrixView(const float *data_ptr, std::size_t n_rows, std::size_t n_cols)
Definition kodama.hpp:125
std::size_t rows
Definition kodama.hpp:116
std::vector< float > distances
Definition kodama.hpp:353
GraphIndexBase index_base
Definition kodama.hpp:355
std::vector< int > indices
Definition kodama.hpp:352
std::vector< float > reference
Definition kodama.hpp:771
std::vector< float > train
Definition kodama.hpp:775
std::vector< float > train_coefficients
Definition kodama.hpp:777
std::vector< float > test
Definition kodama.hpp:776
std::vector< float > test_coefficients
Definition kodama.hpp:778
std::vector< float > reference
Definition kodama.hpp:779
std::vector< float > init
Definition kodama.hpp:698
std::string init_source
Definition kodama.hpp:699
std::vector< float > loadings
Definition kodama.hpp:730
std::vector< float > singular_values
Definition kodama.hpp:731
std::vector< float > variance
Definition kodama.hpp:733
std::vector< float > scores
Definition kodama.hpp:729
std::vector< float > sdev
Definition kodama.hpp:732
std::vector< float > cumulative_variance_explained
Definition kodama.hpp:735
std::vector< float > variance_explained
Definition kodama.hpp:734
std::vector< float > center
Definition kodama.hpp:736
std::vector< float > scale
Definition kodama.hpp:737
ConfusionMatrix confusion
Definition kodama.hpp:288
std::vector< int > predicted_labels
Definition kodama.hpp:281
std::vector< int > true_labels
Definition kodama.hpp:282
std::vector< int > fold_assignments
Definition kodama.hpp:283
PLSParametersUsed parameters
Definition kodama.hpp:291
std::vector< double > accuracy_by_components
Definition kodama.hpp:285
std::vector< FoldResult > folds
Definition kodama.hpp:284
std::vector< float > x_scale
Definition kodama.hpp:756
std::vector< float > fitted
Definition kodama.hpp:754
std::vector< float > response_loadings
Definition kodama.hpp:751
std::vector< float > coefficients
Definition kodama.hpp:753
std::vector< float > scores
Definition kodama.hpp:752
std::vector< float > x_center
Definition kodama.hpp:755
std::vector< float > y_center
Definition kodama.hpp:757
std::vector< float > weights
Definition kodama.hpp:750
std::uint64_t data_epoch
Definition kodama.hpp:178
FoldOptions cv
Definition kodama.hpp:169
std::vector< float > values
Definition kodama.hpp:816
std::vector< float > sample_max_distances
Definition kodama.hpp:817
std::vector< float > train
Definition kodama.hpp:796
std::vector< float > scale
Definition kodama.hpp:799
std::vector< float > center
Definition kodama.hpp:798
std::vector< float > test
Definition kodama.hpp:797
std::vector< double > per_sample_p_value
Definition kodama.hpp:844
std::vector< int > sample_labels
Definition kodama.hpp:846
std::vector< double > adjusted_p_value
Definition kodama.hpp:842
std::vector< double > p_value
Definition kodama.hpp:841
std::vector< float > per_sample_score
Definition kodama.hpp:843
std::vector< int > ranking
Definition kodama.hpp:845
std::vector< float > score
Definition kodama.hpp:840
std::vector< int > basis_dimensions
Definition kodama.hpp:847
std::string init_source
Definition kodama.hpp:676
std::vector< float > init
Definition kodama.hpp:675
std::vector< float > umap
Definition kodama.hpp:451
std::vector< float > opentsne
Definition kodama.hpp:452