isotree 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/LICENSE.txt +2 -2
  4. data/README.md +32 -14
  5. data/ext/isotree/ext.cpp +144 -31
  6. data/ext/isotree/extconf.rb +7 -7
  7. data/lib/isotree/isolation_forest.rb +110 -30
  8. data/lib/isotree/version.rb +1 -1
  9. data/vendor/isotree/LICENSE +1 -1
  10. data/vendor/isotree/README.md +165 -27
  11. data/vendor/isotree/include/isotree.hpp +2111 -0
  12. data/vendor/isotree/include/isotree_oop.hpp +394 -0
  13. data/vendor/isotree/inst/COPYRIGHTS +62 -0
  14. data/vendor/isotree/src/RcppExports.cpp +525 -52
  15. data/vendor/isotree/src/Rwrapper.cpp +1931 -268
  16. data/vendor/isotree/src/c_interface.cpp +953 -0
  17. data/vendor/isotree/src/crit.hpp +4232 -0
  18. data/vendor/isotree/src/dist.hpp +1886 -0
  19. data/vendor/isotree/src/exp_depth_table.hpp +134 -0
  20. data/vendor/isotree/src/extended.hpp +1444 -0
  21. data/vendor/isotree/src/external_facing_generic.hpp +399 -0
  22. data/vendor/isotree/src/fit_model.hpp +2401 -0
  23. data/vendor/isotree/src/{dealloc.cpp → headers_joined.hpp} +38 -22
  24. data/vendor/isotree/src/helpers_iforest.hpp +813 -0
  25. data/vendor/isotree/src/{impute.cpp → impute.hpp} +353 -122
  26. data/vendor/isotree/src/indexer.cpp +515 -0
  27. data/vendor/isotree/src/instantiate_template_headers.cpp +118 -0
  28. data/vendor/isotree/src/instantiate_template_headers.hpp +240 -0
  29. data/vendor/isotree/src/isoforest.hpp +1659 -0
  30. data/vendor/isotree/src/isotree.hpp +1804 -392
  31. data/vendor/isotree/src/isotree_exportable.hpp +99 -0
  32. data/vendor/isotree/src/merge_models.cpp +159 -16
  33. data/vendor/isotree/src/mult.hpp +1321 -0
  34. data/vendor/isotree/src/oop_interface.cpp +842 -0
  35. data/vendor/isotree/src/oop_interface.hpp +278 -0
  36. data/vendor/isotree/src/other_helpers.hpp +219 -0
  37. data/vendor/isotree/src/predict.hpp +1932 -0
  38. data/vendor/isotree/src/python_helpers.hpp +134 -0
  39. data/vendor/isotree/src/ref_indexer.hpp +154 -0
  40. data/vendor/isotree/src/robinmap/LICENSE +21 -0
  41. data/vendor/isotree/src/robinmap/README.md +483 -0
  42. data/vendor/isotree/src/robinmap/include/tsl/robin_growth_policy.h +406 -0
  43. data/vendor/isotree/src/robinmap/include/tsl/robin_hash.h +1620 -0
  44. data/vendor/isotree/src/robinmap/include/tsl/robin_map.h +807 -0
  45. data/vendor/isotree/src/robinmap/include/tsl/robin_set.h +660 -0
  46. data/vendor/isotree/src/serialize.cpp +4300 -139
  47. data/vendor/isotree/src/sql.cpp +141 -59
  48. data/vendor/isotree/src/subset_models.cpp +174 -0
  49. data/vendor/isotree/src/utils.hpp +3808 -0
  50. data/vendor/isotree/src/xoshiro.hpp +467 -0
  51. data/vendor/isotree/src/ziggurat.hpp +405 -0
  52. metadata +38 -104
  53. data/vendor/cereal/LICENSE +0 -24
  54. data/vendor/cereal/README.md +0 -85
  55. data/vendor/cereal/include/cereal/access.hpp +0 -351
  56. data/vendor/cereal/include/cereal/archives/adapters.hpp +0 -163
  57. data/vendor/cereal/include/cereal/archives/binary.hpp +0 -169
  58. data/vendor/cereal/include/cereal/archives/json.hpp +0 -1019
  59. data/vendor/cereal/include/cereal/archives/portable_binary.hpp +0 -334
  60. data/vendor/cereal/include/cereal/archives/xml.hpp +0 -956
  61. data/vendor/cereal/include/cereal/cereal.hpp +0 -1089
  62. data/vendor/cereal/include/cereal/details/helpers.hpp +0 -422
  63. data/vendor/cereal/include/cereal/details/polymorphic_impl.hpp +0 -796
  64. data/vendor/cereal/include/cereal/details/polymorphic_impl_fwd.hpp +0 -65
  65. data/vendor/cereal/include/cereal/details/static_object.hpp +0 -127
  66. data/vendor/cereal/include/cereal/details/traits.hpp +0 -1411
  67. data/vendor/cereal/include/cereal/details/util.hpp +0 -84
  68. data/vendor/cereal/include/cereal/external/base64.hpp +0 -134
  69. data/vendor/cereal/include/cereal/external/rapidjson/allocators.h +0 -284
  70. data/vendor/cereal/include/cereal/external/rapidjson/cursorstreamwrapper.h +0 -78
  71. data/vendor/cereal/include/cereal/external/rapidjson/document.h +0 -2652
  72. data/vendor/cereal/include/cereal/external/rapidjson/encodedstream.h +0 -299
  73. data/vendor/cereal/include/cereal/external/rapidjson/encodings.h +0 -716
  74. data/vendor/cereal/include/cereal/external/rapidjson/error/en.h +0 -74
  75. data/vendor/cereal/include/cereal/external/rapidjson/error/error.h +0 -161
  76. data/vendor/cereal/include/cereal/external/rapidjson/filereadstream.h +0 -99
  77. data/vendor/cereal/include/cereal/external/rapidjson/filewritestream.h +0 -104
  78. data/vendor/cereal/include/cereal/external/rapidjson/fwd.h +0 -151
  79. data/vendor/cereal/include/cereal/external/rapidjson/internal/biginteger.h +0 -290
  80. data/vendor/cereal/include/cereal/external/rapidjson/internal/diyfp.h +0 -271
  81. data/vendor/cereal/include/cereal/external/rapidjson/internal/dtoa.h +0 -245
  82. data/vendor/cereal/include/cereal/external/rapidjson/internal/ieee754.h +0 -78
  83. data/vendor/cereal/include/cereal/external/rapidjson/internal/itoa.h +0 -308
  84. data/vendor/cereal/include/cereal/external/rapidjson/internal/meta.h +0 -186
  85. data/vendor/cereal/include/cereal/external/rapidjson/internal/pow10.h +0 -55
  86. data/vendor/cereal/include/cereal/external/rapidjson/internal/regex.h +0 -740
  87. data/vendor/cereal/include/cereal/external/rapidjson/internal/stack.h +0 -232
  88. data/vendor/cereal/include/cereal/external/rapidjson/internal/strfunc.h +0 -69
  89. data/vendor/cereal/include/cereal/external/rapidjson/internal/strtod.h +0 -290
  90. data/vendor/cereal/include/cereal/external/rapidjson/internal/swap.h +0 -46
  91. data/vendor/cereal/include/cereal/external/rapidjson/istreamwrapper.h +0 -128
  92. data/vendor/cereal/include/cereal/external/rapidjson/memorybuffer.h +0 -70
  93. data/vendor/cereal/include/cereal/external/rapidjson/memorystream.h +0 -71
  94. data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/inttypes.h +0 -316
  95. data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/stdint.h +0 -300
  96. data/vendor/cereal/include/cereal/external/rapidjson/ostreamwrapper.h +0 -81
  97. data/vendor/cereal/include/cereal/external/rapidjson/pointer.h +0 -1414
  98. data/vendor/cereal/include/cereal/external/rapidjson/prettywriter.h +0 -277
  99. data/vendor/cereal/include/cereal/external/rapidjson/rapidjson.h +0 -656
  100. data/vendor/cereal/include/cereal/external/rapidjson/reader.h +0 -2230
  101. data/vendor/cereal/include/cereal/external/rapidjson/schema.h +0 -2497
  102. data/vendor/cereal/include/cereal/external/rapidjson/stream.h +0 -223
  103. data/vendor/cereal/include/cereal/external/rapidjson/stringbuffer.h +0 -121
  104. data/vendor/cereal/include/cereal/external/rapidjson/writer.h +0 -709
  105. data/vendor/cereal/include/cereal/external/rapidxml/license.txt +0 -52
  106. data/vendor/cereal/include/cereal/external/rapidxml/manual.html +0 -406
  107. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml.hpp +0 -2624
  108. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_iterators.hpp +0 -175
  109. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_print.hpp +0 -428
  110. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_utils.hpp +0 -123
  111. data/vendor/cereal/include/cereal/macros.hpp +0 -154
  112. data/vendor/cereal/include/cereal/specialize.hpp +0 -139
  113. data/vendor/cereal/include/cereal/types/array.hpp +0 -79
  114. data/vendor/cereal/include/cereal/types/atomic.hpp +0 -55
  115. data/vendor/cereal/include/cereal/types/base_class.hpp +0 -203
  116. data/vendor/cereal/include/cereal/types/bitset.hpp +0 -176
  117. data/vendor/cereal/include/cereal/types/boost_variant.hpp +0 -164
  118. data/vendor/cereal/include/cereal/types/chrono.hpp +0 -72
  119. data/vendor/cereal/include/cereal/types/common.hpp +0 -129
  120. data/vendor/cereal/include/cereal/types/complex.hpp +0 -56
  121. data/vendor/cereal/include/cereal/types/concepts/pair_associative_container.hpp +0 -73
  122. data/vendor/cereal/include/cereal/types/deque.hpp +0 -62
  123. data/vendor/cereal/include/cereal/types/forward_list.hpp +0 -68
  124. data/vendor/cereal/include/cereal/types/functional.hpp +0 -43
  125. data/vendor/cereal/include/cereal/types/list.hpp +0 -62
  126. data/vendor/cereal/include/cereal/types/map.hpp +0 -36
  127. data/vendor/cereal/include/cereal/types/memory.hpp +0 -425
  128. data/vendor/cereal/include/cereal/types/optional.hpp +0 -66
  129. data/vendor/cereal/include/cereal/types/polymorphic.hpp +0 -483
  130. data/vendor/cereal/include/cereal/types/queue.hpp +0 -132
  131. data/vendor/cereal/include/cereal/types/set.hpp +0 -103
  132. data/vendor/cereal/include/cereal/types/stack.hpp +0 -76
  133. data/vendor/cereal/include/cereal/types/string.hpp +0 -61
  134. data/vendor/cereal/include/cereal/types/tuple.hpp +0 -123
  135. data/vendor/cereal/include/cereal/types/unordered_map.hpp +0 -36
  136. data/vendor/cereal/include/cereal/types/unordered_set.hpp +0 -99
  137. data/vendor/cereal/include/cereal/types/utility.hpp +0 -47
  138. data/vendor/cereal/include/cereal/types/valarray.hpp +0 -89
  139. data/vendor/cereal/include/cereal/types/variant.hpp +0 -109
  140. data/vendor/cereal/include/cereal/types/vector.hpp +0 -112
  141. data/vendor/cereal/include/cereal/version.hpp +0 -52
  142. data/vendor/isotree/src/Makevars +0 -4
  143. data/vendor/isotree/src/crit.cpp +0 -912
  144. data/vendor/isotree/src/dist.cpp +0 -749
  145. data/vendor/isotree/src/extended.cpp +0 -790
  146. data/vendor/isotree/src/fit_model.cpp +0 -1090
  147. data/vendor/isotree/src/helpers_iforest.cpp +0 -324
  148. data/vendor/isotree/src/isoforest.cpp +0 -771
  149. data/vendor/isotree/src/mult.cpp +0 -607
  150. data/vendor/isotree/src/predict.cpp +0 -853
  151. data/vendor/isotree/src/utils.cpp +0 -1566
@@ -0,0 +1,399 @@
1
+ /* Isolation forests and variations thereof, with adjustments for incorporation
2
+ * of categorical variables and missing values.
3
+ * Writen for C++11 standard and aimed at being used in R and Python.
4
+ *
5
+ * This library is based on the following works:
6
+ * [1] Liu, Fei Tony, Kai Ming Ting, and Zhi-Hua Zhou.
7
+ * "Isolation forest."
8
+ * 2008 Eighth IEEE International Conference on Data Mining. IEEE, 2008.
9
+ * [2] Liu, Fei Tony, Kai Ming Ting, and Zhi-Hua Zhou.
10
+ * "Isolation-based anomaly detection."
11
+ * ACM Transactions on Knowledge Discovery from Data (TKDD) 6.1 (2012): 3.
12
+ * [3] Hariri, Sahand, Matias Carrasco Kind, and Robert J. Brunner.
13
+ * "Extended Isolation Forest."
14
+ * arXiv preprint arXiv:1811.02141 (2018).
15
+ * [4] Liu, Fei Tony, Kai Ming Ting, and Zhi-Hua Zhou.
16
+ * "On detecting clustered anomalies using SCiForest."
17
+ * Joint European Conference on Machine Learning and Knowledge Discovery in Databases. Springer, Berlin, Heidelberg, 2010.
18
+ * [5] https://sourceforge.net/projects/iforest/
19
+ * [6] https://math.stackexchange.com/questions/3388518/expected-number-of-paths-required-to-separate-elements-in-a-binary-tree
20
+ * [7] Quinlan, J. Ross. C4. 5: programs for machine learning. Elsevier, 2014.
21
+ * [8] Cortes, David.
22
+ * "Distance approximation using Isolation Forests."
23
+ * arXiv preprint arXiv:1910.12362 (2019).
24
+ * [9] Cortes, David.
25
+ * "Imputing missing values with unsupervised random trees."
26
+ * arXiv preprint arXiv:1911.06646 (2019).
27
+ * [10] https://math.stackexchange.com/questions/3333220/expected-average-depth-in-random-binary-tree-constructed-top-to-bottom
28
+ * [11] Cortes, David.
29
+ * "Revisiting randomized choices in isolation forests."
30
+ * arXiv preprint arXiv:2110.13402 (2021).
31
+ * [12] Guha, Sudipto, et al.
32
+ * "Robust random cut forest based anomaly detection on streams."
33
+ * International conference on machine learning. PMLR, 2016.
34
+ * [13] Cortes, David.
35
+ * "Isolation forests: looking beyond tree depth."
36
+ * arXiv preprint arXiv:2111.11639 (2021).
37
+ * [14] Ting, Kai Ming, Yue Zhu, and Zhi-Hua Zhou.
38
+ * "Isolation kernel and its effect on SVM"
39
+ * Proceedings of the 24th ACM SIGKDD
40
+ * International Conference on Knowledge Discovery & Data Mining. 2018.
41
+ *
42
+ * BSD 2-Clause License
43
+ * Copyright (c) 2019-2022, David Cortes
44
+ * All rights reserved.
45
+ * Redistribution and use in source and binary forms, with or without
46
+ * modification, are permitted provided that the following conditions are met:
47
+ * * Redistributions of source code must retain the above copyright notice, this
48
+ * list of conditions and the following disclaimer.
49
+ * * Redistributions in binary form must reproduce the above copyright notice,
50
+ * this list of conditions and the following disclaimer in the documentation
51
+ * and/or other materials provided with the distribution.
52
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
53
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
56
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
58
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
59
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
+ */
63
+ ISOTREE_EXPORTED
64
+ int fit_iforest(IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
65
+ real_t numeric_data[], size_t ncols_numeric,
66
+ int categ_data[], size_t ncols_categ, int ncat[],
67
+ real_t Xc[], sparse_ix Xc_ind[], sparse_ix Xc_indptr[],
68
+ size_t ndim, size_t ntry, CoefType coef_type, bool coef_by_prop,
69
+ real_t sample_weights[], bool with_replacement, bool weight_as_sample,
70
+ size_t nrows, size_t sample_size, size_t ntrees,
71
+ size_t max_depth, size_t ncols_per_tree,
72
+ bool limit_depth, bool penalize_range, bool standardize_data,
73
+ ScoringMetric scoring_metric, bool fast_bratio,
74
+ bool standardize_dist, double tmat[],
75
+ double output_depths[], bool standardize_depth,
76
+ real_t col_weights[], bool weigh_by_kurt,
77
+ double prob_pick_by_gain_pl, double prob_pick_by_gain_avg,
78
+ double prob_pick_by_full_gain, double prob_pick_by_dens,
79
+ double prob_pick_col_by_range, double prob_pick_col_by_var,
80
+ double prob_pick_col_by_kurt,
81
+ double min_gain, MissingAction missing_action,
82
+ CategSplit cat_split_type, NewCategAction new_cat_action,
83
+ bool all_perm, Imputer *imputer, size_t min_imp_obs,
84
+ UseDepthImp depth_imp, WeighImpRows weigh_imp_rows, bool impute_at_fit,
85
+ uint64_t random_seed, bool use_long_double, int nthreads);
86
+ ISOTREE_EXPORTED
87
+ int add_tree(IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
88
+ real_t numeric_data[], size_t ncols_numeric,
89
+ int categ_data[], size_t ncols_categ, int ncat[],
90
+ real_t Xc[], sparse_ix Xc_ind[], sparse_ix Xc_indptr[],
91
+ size_t ndim, size_t ntry, CoefType coef_type, bool coef_by_prop,
92
+ real_t sample_weights[], size_t nrows, size_t max_depth,
93
+ bool limit_depth, bool penalize_range, bool standardize_data,
94
+ real_t col_weights[], bool weigh_by_kurt,
95
+ double prob_pick_by_gain_pl, double prob_pick_by_gain_avg,
96
+ double prob_pick_by_full_gain, double prob_pick_by_dens,
97
+ double prob_pick_col_by_range, double prob_pick_col_by_var,
98
+ double prob_pick_col_by_kurt,
99
+ double min_gain, MissingAction missing_action,
100
+ CategSplit cat_split_type, NewCategAction new_cat_action,
101
+ UseDepthImp depth_imp, WeighImpRows weigh_imp_rows,
102
+ bool all_perm, std::vector<ImputeNode> *impute_nodes, size_t min_imp_obs,
103
+ TreesIndexer *indexer,
104
+ real_t ref_numeric_data[], int ref_categ_data[],
105
+ bool ref_is_col_major, size_t ref_ld_numeric, size_t ref_ld_categ,
106
+ real_t ref_Xc[], sparse_ix ref_Xc_ind[], sparse_ix ref_Xc_indptr[],
107
+ uint64_t random_seed, bool use_long_double);
108
+ ISOTREE_EXPORTED
109
+ void predict_iforest(real_t numeric_data[], int categ_data[],
110
+ bool is_col_major, size_t ncols_numeric, size_t ncols_categ,
111
+ real_t Xc[], sparse_ix Xc_ind[], sparse_ix Xc_indptr[],
112
+ real_t Xr[], sparse_ix Xr_ind[], sparse_ix Xr_indptr[],
113
+ size_t nrows, int nthreads, bool standardize,
114
+ IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
115
+ double output_depths[], sparse_ix tree_num[],
116
+ double per_tree_depths[],
117
+ TreesIndexer *indexer);
118
+ ISOTREE_EXPORTED void get_num_nodes(IsoForest &model_outputs, sparse_ix *n_nodes, sparse_ix *n_terminal, int nthreads) noexcept;
119
+ ISOTREE_EXPORTED void get_num_nodes(ExtIsoForest &model_outputs, sparse_ix *n_nodes, sparse_ix *n_terminal, int nthreads) noexcept;
120
+ void calc_similarity(real_t numeric_data[], int categ_data[],
121
+ real_t Xc[], sparse_ix Xc_ind[], sparse_ix Xc_indptr[],
122
+ size_t nrows, bool use_long_double, int nthreads,
123
+ bool assume_full_distr, bool standardize_dist, bool as_kernel,
124
+ IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
125
+ double tmat[], double rmat[], size_t n_from, bool use_indexed_references,
126
+ TreesIndexer *indexer, bool is_col_major, size_t ld_numeric, size_t ld_categ);
127
+ ISOTREE_EXPORTED
128
+ void impute_missing_values(real_t numeric_data[], int categ_data[], bool is_col_major,
129
+ real_t Xr[], sparse_ix Xr_ind[], sparse_ix Xr_indptr[],
130
+ size_t nrows, bool use_long_double, int nthreads,
131
+ IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
132
+ Imputer &imputer);
133
+ ISOTREE_EXPORTED
134
+ void merge_models(IsoForest* model, IsoForest* other,
135
+ ExtIsoForest* ext_model, ExtIsoForest* ext_other,
136
+ Imputer* imputer, Imputer* iother,
137
+ TreesIndexer* indexer, TreesIndexer* ind_other);
138
+ ISOTREE_EXPORTED
139
+ void subset_model(IsoForest* model, IsoForest* model_new,
140
+ ExtIsoForest* ext_model, ExtIsoForest* ext_model_new,
141
+ Imputer* imputer, Imputer* imputer_new,
142
+ TreesIndexer* indexer, TreesIndexer* indexer_new,
143
+ size_t *trees_take, size_t ntrees_take);
144
+ ISOTREE_EXPORTED
145
+ std::string generate_sql_with_select_from(IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
146
+ std::string &table_from, std::string &select_as,
147
+ std::vector<std::string> &numeric_colnames, std::vector<std::string> &categ_colnames,
148
+ std::vector<std::vector<std::string>> &categ_levels,
149
+ bool index1, int nthreads);
150
+ ISOTREE_EXPORTED
151
+ std::vector<std::string> generate_sql(IsoForest *model_outputs, ExtIsoForest *model_outputs_ext,
152
+ std::vector<std::string> &numeric_colnames, std::vector<std::string> &categ_colnames,
153
+ std::vector<std::vector<std::string>> &categ_levels,
154
+ bool output_tree_num, bool index1, bool single_tree, size_t tree_num,
155
+ int nthreads);
156
+
157
+ ISOTREE_EXPORTED
158
+ size_t determine_serialized_size(const IsoForest &model) noexcept;
159
+ ISOTREE_EXPORTED
160
+ size_t determine_serialized_size(const ExtIsoForest &model) noexcept;
161
+ ISOTREE_EXPORTED
162
+ size_t determine_serialized_size(const Imputer &model) noexcept;
163
+ ISOTREE_EXPORTED
164
+ size_t determine_serialized_size(const TreesIndexer &model) noexcept;
165
+ ISOTREE_EXPORTED
166
+ void serialize_IsoForest(const IsoForest &model, char *out);
167
+ ISOTREE_EXPORTED
168
+ void serialize_IsoForest(const IsoForest &model, FILE *out);
169
+ ISOTREE_EXPORTED
170
+ void serialize_IsoForest(const IsoForest &model, std::ostream &out);
171
+ ISOTREE_EXPORTED
172
+ std::string serialize_IsoForest(const IsoForest &model);
173
+ ISOTREE_EXPORTED
174
+ void deserialize_IsoForest(IsoForest &model, const char *in);
175
+ ISOTREE_EXPORTED
176
+ void deserialize_IsoForest(IsoForest &model, FILE *in);
177
+ ISOTREE_EXPORTED
178
+ void deserialize_IsoForest(IsoForest &model, std::istream &in);
179
+ ISOTREE_EXPORTED
180
+ void deserialize_IsoForest(IsoForest &model, const std::string &in);
181
+ ISOTREE_EXPORTED
182
+ void serialize_ExtIsoForest(const ExtIsoForest &model, char *out);
183
+ ISOTREE_EXPORTED
184
+ void serialize_ExtIsoForest(const ExtIsoForest &model, FILE *out);
185
+ ISOTREE_EXPORTED
186
+ void serialize_ExtIsoForest(const ExtIsoForest &model, std::ostream &out);
187
+ ISOTREE_EXPORTED
188
+ std::string serialize_ExtIsoForest(const ExtIsoForest &model);
189
+ ISOTREE_EXPORTED
190
+ void deserialize_ExtIsoForest(ExtIsoForest &model, const char *in);
191
+ ISOTREE_EXPORTED
192
+ void deserialize_ExtIsoForest(ExtIsoForest &model, FILE *in);
193
+ ISOTREE_EXPORTED
194
+ void deserialize_ExtIsoForest(ExtIsoForest &model, std::istream &in);
195
+ ISOTREE_EXPORTED
196
+ void deserialize_ExtIsoForest(ExtIsoForest &model, const std::string &in);
197
+ ISOTREE_EXPORTED
198
+ void serialize_Imputer(const Imputer &model, char *out);
199
+ ISOTREE_EXPORTED
200
+ void serialize_Imputer(const Imputer &model, FILE *out);
201
+ ISOTREE_EXPORTED
202
+ void serialize_Imputer(const Imputer &model, std::ostream &out);
203
+ ISOTREE_EXPORTED
204
+ std::string serialize_Imputer(const Imputer &model);
205
+ ISOTREE_EXPORTED
206
+ void deserialize_Imputer(Imputer &model, const char *in);
207
+ ISOTREE_EXPORTED
208
+ void deserialize_Imputer(Imputer &model, FILE *in);
209
+ ISOTREE_EXPORTED
210
+ void deserialize_Imputer(Imputer &model, std::istream &in);
211
+ ISOTREE_EXPORTED
212
+ void deserialize_Imputer(Imputer &model, const std::string &in);
213
+ ISOTREE_EXPORTED
214
+ void serialize_Indexer(const TreesIndexer &model, char *out);
215
+ ISOTREE_EXPORTED
216
+ void serialize_Indexer(const TreesIndexer &model, FILE *out);
217
+ ISOTREE_EXPORTED
218
+ void serialize_Indexer(const TreesIndexer &model, std::ostream &out);
219
+ ISOTREE_EXPORTED
220
+ std::string serialize_Indexer(const TreesIndexer &model);
221
+ ISOTREE_EXPORTED
222
+ void deserialize_Indexer(TreesIndexer &model, const char *in);
223
+ ISOTREE_EXPORTED
224
+ void deserialize_Indexer(TreesIndexer &model, FILE *in);
225
+ ISOTREE_EXPORTED
226
+ void deserialize_Indexer(TreesIndexer &model, std::istream &in);
227
+ ISOTREE_EXPORTED
228
+ void deserialize_Indexer(TreesIndexer &model, const std::string &in);
229
+ ISOTREE_EXPORTED
230
+ size_t determine_serialized_size_combined
231
+ (
232
+ const IsoForest *model,
233
+ const ExtIsoForest *model_ext,
234
+ const Imputer *imputer,
235
+ const TreesIndexer *indexer,
236
+ const size_t size_optional_metadata
237
+ ) noexcept;
238
+ ISOTREE_EXPORTED
239
+ size_t determine_serialized_size_combined
240
+ (
241
+ const char *serialized_model,
242
+ const char *serialized_model_ext,
243
+ const char *serialized_imputer,
244
+ const char *serialized_indexer,
245
+ const size_t size_optional_metadata
246
+ ) noexcept;
247
+ ISOTREE_EXPORTED
248
+ void serialize_combined
249
+ (
250
+ const IsoForest *model,
251
+ const ExtIsoForest *model_ext,
252
+ const Imputer *imputer,
253
+ const TreesIndexer *indexer,
254
+ const char *optional_metadata,
255
+ const size_t size_optional_metadata,
256
+ char *out
257
+ );
258
+ ISOTREE_EXPORTED
259
+ void serialize_combined
260
+ (
261
+ const IsoForest *model,
262
+ const ExtIsoForest *model_ext,
263
+ const Imputer *imputer,
264
+ const TreesIndexer *indexer,
265
+ const char *optional_metadata,
266
+ const size_t size_optional_metadata,
267
+ FILE *out
268
+ );
269
+ ISOTREE_EXPORTED
270
+ void serialize_combined
271
+ (
272
+ const IsoForest *model,
273
+ const ExtIsoForest *model_ext,
274
+ const Imputer *imputer,
275
+ const TreesIndexer *indexer,
276
+ const char *optional_metadata,
277
+ const size_t size_optional_metadata,
278
+ std::ostream &out
279
+ );
280
+ ISOTREE_EXPORTED
281
+ std::string serialize_combined
282
+ (
283
+ const IsoForest *model,
284
+ const ExtIsoForest *model_ext,
285
+ const Imputer *imputer,
286
+ const TreesIndexer *indexer,
287
+ const char *optional_metadata,
288
+ const size_t size_optional_metadata
289
+ );
290
+ ISOTREE_EXPORTED
291
+ void serialize_combined
292
+ (
293
+ const char *serialized_model,
294
+ const char *serialized_model_ext,
295
+ const char *serialized_imputer,
296
+ const char *serialized_indexer,
297
+ const char *optional_metadata,
298
+ const size_t size_optional_metadata,
299
+ FILE *out
300
+ );
301
+ ISOTREE_EXPORTED
302
+ void serialize_combined
303
+ (
304
+ const char *serialized_model,
305
+ const char *serialized_model_ext,
306
+ const char *serialized_imputer,
307
+ const char *serialized_indexer,
308
+ const char *optional_metadata,
309
+ const size_t size_optional_metadata,
310
+ std::ostream &out
311
+ );
312
+ ISOTREE_EXPORTED
313
+ std::string serialize_combined
314
+ (
315
+ const char *serialized_model,
316
+ const char *serialized_model_ext,
317
+ const char *serialized_imputer,
318
+ const char *serialized_indexer,
319
+ const char *optional_metadata,
320
+ const size_t size_optional_metadata
321
+ );
322
+ ISOTREE_EXPORTED
323
+ void deserialize_combined
324
+ (
325
+ const char* in,
326
+ IsoForest *model,
327
+ ExtIsoForest *model_ext,
328
+ Imputer *imputer,
329
+ TreesIndexer *indexer,
330
+ char *optional_metadata
331
+ );
332
+ ISOTREE_EXPORTED
333
+ void deserialize_combined
334
+ (
335
+ FILE* in,
336
+ IsoForest *model,
337
+ ExtIsoForest *model_ext,
338
+ Imputer *imputer,
339
+ TreesIndexer *indexer,
340
+ char *optional_metadata
341
+ );
342
+ ISOTREE_EXPORTED
343
+ void deserialize_combined
344
+ (
345
+ std::istream &in,
346
+ IsoForest *model,
347
+ ExtIsoForest *model_ext,
348
+ Imputer *imputer,
349
+ TreesIndexer *indexer,
350
+ char *optional_metadata
351
+ );
352
+ ISOTREE_EXPORTED
353
+ void deserialize_combined
354
+ (
355
+ const std::string &in,
356
+ IsoForest *model,
357
+ ExtIsoForest *model_ext,
358
+ Imputer *imputer,
359
+ TreesIndexer *indexer,
360
+ char *optional_metadata
361
+ );
362
+ ISOTREE_EXPORTED
363
+ bool check_can_undergo_incremental_serialization(const IsoForest &model, const char *serialized_bytes);
364
+ ISOTREE_EXPORTED
365
+ bool check_can_undergo_incremental_serialization(const ExtIsoForest &model, const char *serialized_bytes);
366
+ ISOTREE_EXPORTED
367
+ size_t determine_serialized_size_additional_trees(const IsoForest &model, size_t old_ntrees) noexcept;
368
+ ISOTREE_EXPORTED
369
+ size_t determine_serialized_size_additional_trees(const ExtIsoForest &model, size_t old_ntrees) noexcept;
370
+ ISOTREE_EXPORTED
371
+ size_t determine_serialized_size_additional_trees(const Imputer &model, size_t old_ntrees) noexcept;
372
+ ISOTREE_EXPORTED
373
+ size_t determine_serialized_size_additional_trees(const TreesIndexer &model, size_t old_ntrees) noexcept;
374
+ ISOTREE_EXPORTED
375
+ void incremental_serialize_IsoForest(const IsoForest &model, char *old_bytes_reallocated);
376
+ ISOTREE_EXPORTED
377
+ void incremental_serialize_ExtIsoForest(const ExtIsoForest &model, char *old_bytes_reallocated);
378
+ ISOTREE_EXPORTED
379
+ void incremental_serialize_Imputer(const Imputer &model, char *old_bytes_reallocated);
380
+ ISOTREE_EXPORTED
381
+ void incremental_serialize_Indexer(const TreesIndexer &model, char *old_bytes_reallocated);
382
+ ISOTREE_EXPORTED
383
+ void incremental_serialize_IsoForest(const IsoForest &model, std::string &old_bytes);
384
+ ISOTREE_EXPORTED
385
+ void incremental_serialize_ExtIsoForest(const ExtIsoForest &model, std::string &old_bytes);
386
+ ISOTREE_EXPORTED
387
+ void incremental_serialize_Imputer(const Imputer &model, std::string &old_bytes);
388
+ ISOTREE_EXPORTED
389
+ void incremental_serialize_Indexer(const TreesIndexer &model, std::string &old_bytes);
390
+
391
+ ISOTREE_EXPORTED
392
+ void set_reference_points(IsoForest *model_outputs, ExtIsoForest *model_outputs_ext, TreesIndexer *indexer,
393
+ const bool with_distances,
394
+ real_t *numeric_data, int *categ_data,
395
+ bool is_col_major, size_t ld_numeric, size_t ld_categ,
396
+ real_t *Xc, sparse_ix *Xc_ind, sparse_ix *Xc_indptr,
397
+ real_t *Xr, sparse_ix *Xr_ind, sparse_ix *Xr_indptr,
398
+ size_t nrows, int nthreads);
399
+