@@ -867,11 +867,14 @@ class NearestConvexHull(BaseEstimator, ClassifierMixin, TransformerMixin):
867
867
The number of hulls used per class, when subsampling is "random".
868
868
n_samples_per_hull : int, default=15
869
869
Defines how many samples are used to build a hull. -1 will include
870
- all samples per class.
871
- subsampling : {"min", "random"}, default="min"
872
- Subsampling strategy of training set to estimate distance to hulls.
873
- "min" estimates hull using the n_samples_per_hull closest matrices.
874
- "random" estimates hull using n_samples_per_hull random matrices.
870
+ all samples per class. If subsampling is "full", this
871
+ parameter is defaulted to -1.
872
+ subsampling : {"min", "random", "full"}, default="min"
873
+ Subsampling strategy of training set to estimate distance to hulls:
874
+
875
+ - "min" estimates hull using the n_samples_per_hull closest matrices;
876
+ - "random" estimates hull using n_samples_per_hull random matrices;
877
+ - "full" estimates the hull using the entire training matrices, as in [1]_.
875
878
seed : float, default=None
876
879
Optional random seed to use when subsampling is set to `random`.
877
880
@@ -900,9 +903,14 @@ def __init__(
900
903
self .subsampling = subsampling
901
904
self .seed = seed
902
905
903
- if subsampling not in ["min" , "random" ]:
906
+ if subsampling not in ["min" , "random" , "full" ]:
904
907
raise ValueError (f"Unknown subsampling type { subsampling } ." )
905
908
909
+ if subsampling == "full" :
910
+ # From code perspective, "full" strategy is the same as min strategy
911
+ # without sorting
912
+ self .n_samples_per_hull = - 1
913
+
906
914
def fit (self , X , y ):
907
915
"""Fit (store the training data).
908
916
@@ -996,7 +1004,7 @@ def _predict_distances(self, X):
996
1004
if self .debug :
997
1005
print ("Total test samples:" , X .shape [0 ])
998
1006
999
- if self .subsampling == "min" :
1007
+ if self .subsampling == "min" or self . subsampling == "full" :
1000
1008
self ._process_sample = self ._process_sample_min_hull
1001
1009
elif self .subsampling == "random" :
1002
1010
self ._process_sample = self ._process_sample_random_hull
0 commit comments