@@ -164,10 +164,11 @@ class Mrpt {
164
164
* @param depth_min_ minimum depth of trees considered when searching for
165
165
* optimal parameters; in the set
166
166
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
167
- * sets this to 5
167
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
168
168
* @param votes_max_ maximum number of votes considered when searching for
169
169
* optimal parameters; a default value -1 sets this to
170
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
170
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
171
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
171
172
* @param density expected proportion of non-zero components in the random vectors;
172
173
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
173
174
* the dimension of data
@@ -201,10 +202,11 @@ class Mrpt {
201
202
* @param depth_min_ minimum depth of trees considered when searching for
202
203
* optimal parameters; in the set
203
204
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
204
- * sets this to 5
205
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
205
206
* @param votes_max_ maximum number of votes considered when searching for
206
207
* optimal parameters; a default value -1 sets this to
207
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
208
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
209
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
208
210
* @param density expected proportion of non-zero components in the random vectors;
209
211
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
210
212
* the dimension of data
@@ -239,10 +241,11 @@ class Mrpt {
239
241
* @param depth_min_ minimum depth of trees considered when searching for
240
242
* optimal parameters; in the set
241
243
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
242
- * sets this to 5
244
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
243
245
* @param votes_max_ maximum number of votes considered when searching for
244
246
* optimal parameters; a default value -1 sets this to
245
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
247
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
248
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
246
249
* @param density_ expected proportion of non-zero components in the random vectors;
247
250
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
248
251
* the dimension of data
@@ -325,10 +328,11 @@ class Mrpt {
325
328
* @param depth_min_ minimum depth of trees considered when searching for
326
329
* optimal parameters; in the set
327
330
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
328
- * sets this to 5
331
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
329
332
* @param votes_max_ maximum number of votes considered when searching for
330
333
* optimal parameters; a default value -1 sets this to
331
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
334
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
335
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
332
336
* @param density_ expected proportion of non-zero components in the random vectors;
333
337
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
334
338
* the dimension of data
@@ -341,6 +345,26 @@ class Mrpt {
341
345
int depth_min_ = -1 , int votes_max_ = -1 , float density_ = -1.0 , int seed = 0 ,
342
346
const std::vector<int > &indices_test = {}) {
343
347
348
+ if (trees_max == - 1 ) {
349
+ trees_max = std::min (std::sqrt (n_samples), 1000.0 );
350
+ }
351
+
352
+ if (depth_min_ == -1 ) {
353
+ depth_min_ = std::max (static_cast <int >(std::log2 (n_samples) - 11 ), 5 );
354
+ }
355
+
356
+ if (depth_max == -1 ) {
357
+ depth_max = std::max (static_cast <int >(std::log2 (n_samples) - 4 ), depth_min_);
358
+ }
359
+
360
+ if (votes_max_ == -1 ) {
361
+ votes_max_ = std::max (trees_max / 10 , std::min (trees_max, 10 ));
362
+ }
363
+
364
+ if (density_ > -1.0001 && density_ < -0.9999 ) {
365
+ density_ = 1.0 / std::sqrt (dim);
366
+ }
367
+
344
368
if (!empty ()) {
345
369
throw std::logic_error (" The index has already been grown." );
346
370
}
@@ -349,60 +373,37 @@ class Mrpt {
349
373
throw std::out_of_range (" k_ must belong to the set {1, ..., n}." );
350
374
}
351
375
352
- if (trees_max < - 1 || trees_max = = 0 ) {
376
+ if (trees_max <= 0 ) {
353
377
throw std::out_of_range (" trees_max must be positive." );
354
378
}
355
379
356
- if (depth_max < - 1 || depth_max = = 0 || depth_max > std::log2 (n_samples)) {
380
+ if (depth_max <= 0 || depth_max > std::log2 (n_samples)) {
357
381
throw std::out_of_range (" depth_max must belong to the set {1, ... , log2(n)}." );
358
382
}
359
383
360
- if (depth_min_ < - 1 || depth_min_ = = 0 || depth_min_ > depth_max) {
384
+ if (depth_min_ <= 0 || depth_min_ > depth_max) {
361
385
throw std::out_of_range (" depth_min_ must belong to the set {1, ... , depth_max}" );
362
386
}
363
387
364
- if (votes_max_ < - 1 || votes_max_ = = 0 || votes_max_ > trees_max) {
388
+ if (votes_max_ <= 0 || votes_max_ > trees_max) {
365
389
throw std::out_of_range (" votes_max_ must belong to the set {1, ... , trees_max}." );
366
390
}
367
391
368
- if (density_ < - 1.0001 || density_ > 1.0001 || (density_ > - 0.9999 && density_ < - 0.0001 ) ) {
392
+ if (density_ < 0.0 || density_ > 1.0001 ) {
369
393
throw std::out_of_range (" The density must be on the interval (0,1]." );
370
394
}
371
395
372
396
if (n_samples < 101 ) {
373
397
throw std::out_of_range (" Sample size must be at least 101 to autotune an index." );
374
398
}
375
399
376
- if (trees_max == - 1 ) {
377
- trees_max = std::min (std::sqrt (n_samples), 1000.0 );
378
- }
379
-
380
- if (depth_min_ == -1 ) {
381
- depth_min = std::max (static_cast <int >(std::log2 (n_samples) - 11 ), 5 );
382
- } else {
383
- depth_min = depth_min_;
384
- }
385
-
386
- if (depth_max == -1 ) {
387
- depth_max = std::max (static_cast <int >(std::log2 (n_samples) - 4 ), depth_min);
388
- }
389
-
390
- if (votes_max_ == -1 ) {
391
- votes_max = std::max (trees_max / 10 , std::min (trees_max, 10 ));
392
- } else {
393
- votes_max = votes_max_;
394
- }
395
-
396
- if (density_ < 0 ) {
397
- density = 1.0 / std::sqrt (dim);
398
- } else {
399
- density = density_;
400
- }
401
-
400
+ depth_min = depth_min_;
401
+ votes_max = votes_max_;
402
402
k = k_;
403
+
403
404
const Eigen::Map<const Eigen::MatrixXf> Q (data, dim, n_test);
404
405
405
- grow (trees_max, depth_max, density , seed);
406
+ grow (trees_max, depth_max, density_ , seed);
406
407
Eigen::MatrixXi exact (k, n_test);
407
408
compute_exact (Q, exact, indices_test);
408
409
@@ -453,10 +454,11 @@ class Mrpt {
453
454
* @param depth_min_ minimum depth of trees considered when searching for
454
455
* optimal parameters on the set
455
456
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
456
- * sets this to 5
457
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
457
458
* @param votes_max_ maximum number of votes considered when searching for
458
459
* optimal parameters; a default value -1 sets this to
459
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
460
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
461
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
460
462
* @param density_ expected proportion of non-zero components of random vectors;
461
463
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
462
464
* the dimension of data
@@ -486,10 +488,11 @@ class Mrpt {
486
488
* @param depth_min_ minimum depth of trees considered when searching for
487
489
* optimal parameters on the set
488
490
* \f$\{1,2, \dots ,\lfloor \log_2 (n) \rfloor \}\f$; a default value -1
489
- * sets this to 5
491
+ * sets this to \f$ \mathrm{max}(\lfloor \log_2 (n) \rfloor - 11, 5)\f$
490
492
* @param votes_max_ maximum number of votes considered when searching for
491
493
* optimal parameters; a default value -1 sets this to
492
- * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor, 10) \f$
494
+ * \f$ \mathrm{max}(\lfloor \mathrm{trees\_max} / 10 \rfloor,
495
+ * \mathrm{min}(10, \mathrm{trees\_max})) \f$
493
496
* @param density_ expected proportion of non-zero components of random vectors;
494
497
* default value -1.0 sets this to \f$ 1 / \sqrt{d} \f$, where \f$ d\f$ is
495
498
* the dimension of data
0 commit comments