@@ -18,24 +18,46 @@ where at each iteration the model scores each
1818feature or sample (without an estimator) and chooses that with the maximum score.
1919This can be executed using:
2020
21- .. code-block :: python
22-
23- selector = Selector(
24- # the number of selections to make
25- # if None, set to half the samples or features
26- # if float, fraction of the total dataset to select
27- # if int, absolute number of selections to make
28- n_to_select = 4 ,
29- # option to use `tqdm <https://tqdm.github.io/>`_ progress bar
30- progress_bar = True ,
31- # float, cutoff score to stop selecting
32- score_threshold = 1e-12 ,
33- # boolean, whether to select randomly after non-redundant selections are exhausted
34- full = False ,
35- )
36- selector.fit(X, y)
37-
38- Xr = selector.transform(X)
21+ .. doctest ::
22+
23+ >>> import numpy as np
24+ >>> from skmatter.feature_selection import CUR , FPS , PCovCUR, PCovFPS
25+ >>> selector = CUR(
26+ ... # the number of selections to make
27+ ... # if None, set to half the samples or features
28+ ... # if float, fraction of the total dataset to select
29+ ... # if int, absolute number of selections to make
30+ ... n_to_select= 2 ,
31+ ... # option to use `tqdm <https://tqdm.github.io/>`_ progress bar
32+ ... progress_bar= True ,
33+ ... # float, cutoff score to stop selecting
34+ ... score_threshold= 1e-12 ,
35+ ... # boolean, whether to select randomly after non-redundant selections
36+ ... # are exhausted
37+ ... full= False ,
38+ ... )
39+ >>> X = np.array([[ 0.12 , 0.21 , 0.02 ], # 3 samples, 3 features
40+ ... [- 0.09 , 0.32 , - 0.10 ],
41+ ... [- 0.03 , - 0.53 , 0.08 ]])
42+ >>> y = np.array([0 ., 0 ., 1 .]) # classes of each sample
43+ >>> selector.fit(X)
44+ CUR(n_to_select=2, progress_bar=True, score_threshold=1e-12)
45+ >>> Xr = selector.transform(X)
46+ >>> print (Xr.shape)
47+ (3, 2)
48+ >>> selector = PCovCUR(n_to_select = 2 )
49+ >>> selector.fit(X, y)
50+ PCovCUR(n_to_select=2)
51+ >>> Xr = selector.transform(X)
52+ >>> print (Xr.shape)
53+ (3, 2)
54+ >>> from skmatter.sample_selection import CUR , FPS , PCovCUR, PCovFPS
55+ >>> selector = CUR(n_to_select = 2 )
56+ >>> selector.fit(X)
57+ CUR(n_to_select=2)
58+ >>> Xr = X[selector.selected_idx_]
59+ >>> print (Xr.shape)
60+ (2, 3)
3961
4062where `Selector ` is one of the classes below that overwrites the method
4163:py:func: `score `.
0 commit comments