1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
%global _empty_manifest_terminate_build 0
Name: python-Boruta
Version: 0.3
Release: 1
Summary: Python Implementation of Boruta Feature Selection
License: BSD 3 clause
URL: https://github.com/danielhomola/boruta_py
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/d5/ab/800c93706b1919dbdcb48fcab3d5251dbd135fa2ca7cd345f7a4dcb0864b/Boruta-0.3.tar.gz
BuildArch: noarch
Requires: python3-numpy
Requires: python3-scikit-learn
Requires: python3-scipy
%description
# boruta_py #
This project hosts Python implementations of the [Boruta all-relevant feature selection method](https://m2.icm.edu.pl/boruta/).
[Related blog post] (http://danielhomola.com/2015/05/08/borutapy-an-all-relevant-feature-selection-method/)
## Dependencies ##
* numpy
* scipy
* scikit-learn
## How to use ##
Download, import and do as you would with any other scikit-learn method:
* fit(X, y)
* transform(X)
* fit_transform(X, y)
## Description ##
Python implementations of the Boruta R package.
This implementation tries to mimic the scikit-learn interface, so use fit,
transform or fit_transform, to run the feature selection.
For more, see the docs of these functions, and the examples below.
Original code and method by: Miron B Kursa, https://m2.icm.edu.pl/boruta/
Boruta is an all relevant feature selection method, while most other are
minimal optimal; this means it tries to find all features carrying
information usable for prediction, rather than finding a possibly compact
subset of features on which some classifier has a minimal error.
Why bother with all relevant feature selection?
When you try to understand the phenomenon that made your data, you should
care about all factors that contribute to it, not just the bluntest signs
of it in context of your methodology (yes, minimal optimal set of features
by definition depends on your classifier choice).
## What's different in BorutaPy? ##
It is the original R package recoded in Python with a few added extra features.
Some improvements include:
* Faster run times, thanks to scikit-learn
* Scikit-learn like interface
* Compatible with any ensemble method from scikit-learn
* Automatic n_estimator selection
* Ranking of features
For more details, please check the top of the docstring.
We highly recommend using pruned trees with a depth between 3-7.
Also, after playing around a lot with the original code I identified a few areas
where the core algorithm could be improved/altered to make it less strict and
more applicable to biological data, where the Bonferroni correction might be
overly harsh.
__Percentile as threshold__
The original method uses the maximum of the shadow features as a threshold in
deciding which real feature is doing better than the shadow ones. This could be
overly harsh.
To control this, I added the perc parameter, which sets the
percentile of the shadow features' importances, the algorithm uses as the
threshold. The default of 100 which is equivalent to taking the maximum as the
R version of Boruta does, but it could be relaxed. Note, since this is the
percentile, it changes with the size of the dataset. With several thousands of
features it isn't as stringent as with a few dozens at the end of a Boruta run.
__Two step correction for multiple testing__
The correction for multiple testing was relaxed by making it a two step
process, rather than a harsh one step Bonferroni correction.
We need to correct firstly because in each iteration we test a number of
features against the null hypothesis (does a feature perform better than
expected by random). For this the Bonferroni correction is used in the original
code which is known to be too stringent in such scenarios (at least for
biological data), and also the original code corrects for n features, even if
we are in the 50th iteration where we only have k<<n features left. For this
reason the first step of correction is the widely used Benjamini Hochberg FDR.
Following that however we also need to account for the fact that we have been
testing the same features over and over again in each iteration with the
same test. For this scenario the Bonferroni is perfect, so it is applied by
deviding the p-value threshold with the current iteration index.
If this two step correction is not required, the two_step parameter has to be
set to False, then (with perc=100) BorutaPy behaves exactly as the R version.
## Parameters ##
__estimator__ : object
> A supervised learning estimator, with a 'fit' method that returns the
> feature_importances_ attribute. Important features must correspond to
> high absolute values in the feature_importances_.
__n_estimators__ : int or string, default = 1000
> If int sets the number of estimators in the chosen ensemble method.
> If 'auto' this is determined automatically based on the size of the
> dataset. The other parameters of the used estimators need to be set
> with initialisation.
__perc__ : int, default = 100
> Instead of the max we use the percentile defined by the user, to pick
> our threshold for comparison between shadow and real features. The max
> tend to be too stringent. This provides a finer control over this. The
> lower perc is the more false positives will be picked as relevant but
> also the less relevant features will be left out. The usual trade-off.
> The default is essentially the vanilla Boruta corresponding to the max.
__alpha__ : float, default = 0.05
> Level at which the corrected p-values will get rejected in both correction
steps.
__two_step__ : Boolean, default = True
> If you want to use the original implementation of Boruta with Bonferroni
> correction only set this to False.
__max_iter__ : int, default = 100
> The number of maximum iterations to perform.
__verbose__ : int, default=0
> Controls verbosity of output.
## Attributes ##
**n_features_** : int
> The number of selected features.
**support_** : array of shape [n_features]
> The mask of selected features - only confirmed ones are True.
**support_weak_** : array of shape [n_features]
> The mask of selected tentative features, which haven't gained enough
> support during the max_iter number of iterations..
**ranking_** : array of shape [n_features]
> The feature ranking, such that ``ranking_[i]`` corresponds to the
> ranking position of the i-th feature. Selected (i.e., estimated
> best) features are assigned rank 1 and tentative features are assigned
> rank 2.
## Examples ##
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from boruta import BorutaPy
# load X and y
# NOTE BorutaPy accepts numpy arrays only, hence the .values attribute
X = pd.read_csv('examples/test_X.csv', index_col=0).values
y = pd.read_csv('examples/test_y.csv', header=None, index_col=0).values
y = y.ravel()
# define random forest classifier, with utilising all cores and
# sampling in proportion to y labels
rf = RandomForestClassifier(n_jobs=-1, class_weight='balanced', max_depth=5)
# define Boruta feature selection method
feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1)
# find all relevant features - 5 features should be selected
feat_selector.fit(X, y)
# check selected features - first 5 features are selected
feat_selector.support_
# check ranking of features
feat_selector.ranking_
# call transform() on X to filter it down to selected features
X_filtered = feat_selector.transform(X)
## References ##
1. Kursa M., Rudnicki W., "Feature Selection with the Boruta Package" Journal of Statistical Software, Vol. 36, Issue 11, Sep 2010
%package -n python3-Boruta
Summary: Python Implementation of Boruta Feature Selection
Provides: python-Boruta
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-Boruta
# boruta_py #
This project hosts Python implementations of the [Boruta all-relevant feature selection method](https://m2.icm.edu.pl/boruta/).
[Related blog post] (http://danielhomola.com/2015/05/08/borutapy-an-all-relevant-feature-selection-method/)
## Dependencies ##
* numpy
* scipy
* scikit-learn
## How to use ##
Download, import and do as you would with any other scikit-learn method:
* fit(X, y)
* transform(X)
* fit_transform(X, y)
## Description ##
Python implementations of the Boruta R package.
This implementation tries to mimic the scikit-learn interface, so use fit,
transform or fit_transform, to run the feature selection.
For more, see the docs of these functions, and the examples below.
Original code and method by: Miron B Kursa, https://m2.icm.edu.pl/boruta/
Boruta is an all relevant feature selection method, while most other are
minimal optimal; this means it tries to find all features carrying
information usable for prediction, rather than finding a possibly compact
subset of features on which some classifier has a minimal error.
Why bother with all relevant feature selection?
When you try to understand the phenomenon that made your data, you should
care about all factors that contribute to it, not just the bluntest signs
of it in context of your methodology (yes, minimal optimal set of features
by definition depends on your classifier choice).
## What's different in BorutaPy? ##
It is the original R package recoded in Python with a few added extra features.
Some improvements include:
* Faster run times, thanks to scikit-learn
* Scikit-learn like interface
* Compatible with any ensemble method from scikit-learn
* Automatic n_estimator selection
* Ranking of features
For more details, please check the top of the docstring.
We highly recommend using pruned trees with a depth between 3-7.
Also, after playing around a lot with the original code I identified a few areas
where the core algorithm could be improved/altered to make it less strict and
more applicable to biological data, where the Bonferroni correction might be
overly harsh.
__Percentile as threshold__
The original method uses the maximum of the shadow features as a threshold in
deciding which real feature is doing better than the shadow ones. This could be
overly harsh.
To control this, I added the perc parameter, which sets the
percentile of the shadow features' importances, the algorithm uses as the
threshold. The default of 100 which is equivalent to taking the maximum as the
R version of Boruta does, but it could be relaxed. Note, since this is the
percentile, it changes with the size of the dataset. With several thousands of
features it isn't as stringent as with a few dozens at the end of a Boruta run.
__Two step correction for multiple testing__
The correction for multiple testing was relaxed by making it a two step
process, rather than a harsh one step Bonferroni correction.
We need to correct firstly because in each iteration we test a number of
features against the null hypothesis (does a feature perform better than
expected by random). For this the Bonferroni correction is used in the original
code which is known to be too stringent in such scenarios (at least for
biological data), and also the original code corrects for n features, even if
we are in the 50th iteration where we only have k<<n features left. For this
reason the first step of correction is the widely used Benjamini Hochberg FDR.
Following that however we also need to account for the fact that we have been
testing the same features over and over again in each iteration with the
same test. For this scenario the Bonferroni is perfect, so it is applied by
deviding the p-value threshold with the current iteration index.
If this two step correction is not required, the two_step parameter has to be
set to False, then (with perc=100) BorutaPy behaves exactly as the R version.
## Parameters ##
__estimator__ : object
> A supervised learning estimator, with a 'fit' method that returns the
> feature_importances_ attribute. Important features must correspond to
> high absolute values in the feature_importances_.
__n_estimators__ : int or string, default = 1000
> If int sets the number of estimators in the chosen ensemble method.
> If 'auto' this is determined automatically based on the size of the
> dataset. The other parameters of the used estimators need to be set
> with initialisation.
__perc__ : int, default = 100
> Instead of the max we use the percentile defined by the user, to pick
> our threshold for comparison between shadow and real features. The max
> tend to be too stringent. This provides a finer control over this. The
> lower perc is the more false positives will be picked as relevant but
> also the less relevant features will be left out. The usual trade-off.
> The default is essentially the vanilla Boruta corresponding to the max.
__alpha__ : float, default = 0.05
> Level at which the corrected p-values will get rejected in both correction
steps.
__two_step__ : Boolean, default = True
> If you want to use the original implementation of Boruta with Bonferroni
> correction only set this to False.
__max_iter__ : int, default = 100
> The number of maximum iterations to perform.
__verbose__ : int, default=0
> Controls verbosity of output.
## Attributes ##
**n_features_** : int
> The number of selected features.
**support_** : array of shape [n_features]
> The mask of selected features - only confirmed ones are True.
**support_weak_** : array of shape [n_features]
> The mask of selected tentative features, which haven't gained enough
> support during the max_iter number of iterations..
**ranking_** : array of shape [n_features]
> The feature ranking, such that ``ranking_[i]`` corresponds to the
> ranking position of the i-th feature. Selected (i.e., estimated
> best) features are assigned rank 1 and tentative features are assigned
> rank 2.
## Examples ##
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from boruta import BorutaPy
# load X and y
# NOTE BorutaPy accepts numpy arrays only, hence the .values attribute
X = pd.read_csv('examples/test_X.csv', index_col=0).values
y = pd.read_csv('examples/test_y.csv', header=None, index_col=0).values
y = y.ravel()
# define random forest classifier, with utilising all cores and
# sampling in proportion to y labels
rf = RandomForestClassifier(n_jobs=-1, class_weight='balanced', max_depth=5)
# define Boruta feature selection method
feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1)
# find all relevant features - 5 features should be selected
feat_selector.fit(X, y)
# check selected features - first 5 features are selected
feat_selector.support_
# check ranking of features
feat_selector.ranking_
# call transform() on X to filter it down to selected features
X_filtered = feat_selector.transform(X)
## References ##
1. Kursa M., Rudnicki W., "Feature Selection with the Boruta Package" Journal of Statistical Software, Vol. 36, Issue 11, Sep 2010
%package help
Summary: Development documents and examples for Boruta
Provides: python3-Boruta-doc
%description help
# boruta_py #
This project hosts Python implementations of the [Boruta all-relevant feature selection method](https://m2.icm.edu.pl/boruta/).
[Related blog post] (http://danielhomola.com/2015/05/08/borutapy-an-all-relevant-feature-selection-method/)
## Dependencies ##
* numpy
* scipy
* scikit-learn
## How to use ##
Download, import and do as you would with any other scikit-learn method:
* fit(X, y)
* transform(X)
* fit_transform(X, y)
## Description ##
Python implementations of the Boruta R package.
This implementation tries to mimic the scikit-learn interface, so use fit,
transform or fit_transform, to run the feature selection.
For more, see the docs of these functions, and the examples below.
Original code and method by: Miron B Kursa, https://m2.icm.edu.pl/boruta/
Boruta is an all relevant feature selection method, while most other are
minimal optimal; this means it tries to find all features carrying
information usable for prediction, rather than finding a possibly compact
subset of features on which some classifier has a minimal error.
Why bother with all relevant feature selection?
When you try to understand the phenomenon that made your data, you should
care about all factors that contribute to it, not just the bluntest signs
of it in context of your methodology (yes, minimal optimal set of features
by definition depends on your classifier choice).
## What's different in BorutaPy? ##
It is the original R package recoded in Python with a few added extra features.
Some improvements include:
* Faster run times, thanks to scikit-learn
* Scikit-learn like interface
* Compatible with any ensemble method from scikit-learn
* Automatic n_estimator selection
* Ranking of features
For more details, please check the top of the docstring.
We highly recommend using pruned trees with a depth between 3-7.
Also, after playing around a lot with the original code I identified a few areas
where the core algorithm could be improved/altered to make it less strict and
more applicable to biological data, where the Bonferroni correction might be
overly harsh.
__Percentile as threshold__
The original method uses the maximum of the shadow features as a threshold in
deciding which real feature is doing better than the shadow ones. This could be
overly harsh.
To control this, I added the perc parameter, which sets the
percentile of the shadow features' importances, the algorithm uses as the
threshold. The default of 100 which is equivalent to taking the maximum as the
R version of Boruta does, but it could be relaxed. Note, since this is the
percentile, it changes with the size of the dataset. With several thousands of
features it isn't as stringent as with a few dozens at the end of a Boruta run.
__Two step correction for multiple testing__
The correction for multiple testing was relaxed by making it a two step
process, rather than a harsh one step Bonferroni correction.
We need to correct firstly because in each iteration we test a number of
features against the null hypothesis (does a feature perform better than
expected by random). For this the Bonferroni correction is used in the original
code which is known to be too stringent in such scenarios (at least for
biological data), and also the original code corrects for n features, even if
we are in the 50th iteration where we only have k<<n features left. For this
reason the first step of correction is the widely used Benjamini Hochberg FDR.
Following that however we also need to account for the fact that we have been
testing the same features over and over again in each iteration with the
same test. For this scenario the Bonferroni is perfect, so it is applied by
deviding the p-value threshold with the current iteration index.
If this two step correction is not required, the two_step parameter has to be
set to False, then (with perc=100) BorutaPy behaves exactly as the R version.
## Parameters ##
__estimator__ : object
> A supervised learning estimator, with a 'fit' method that returns the
> feature_importances_ attribute. Important features must correspond to
> high absolute values in the feature_importances_.
__n_estimators__ : int or string, default = 1000
> If int sets the number of estimators in the chosen ensemble method.
> If 'auto' this is determined automatically based on the size of the
> dataset. The other parameters of the used estimators need to be set
> with initialisation.
__perc__ : int, default = 100
> Instead of the max we use the percentile defined by the user, to pick
> our threshold for comparison between shadow and real features. The max
> tend to be too stringent. This provides a finer control over this. The
> lower perc is the more false positives will be picked as relevant but
> also the less relevant features will be left out. The usual trade-off.
> The default is essentially the vanilla Boruta corresponding to the max.
__alpha__ : float, default = 0.05
> Level at which the corrected p-values will get rejected in both correction
steps.
__two_step__ : Boolean, default = True
> If you want to use the original implementation of Boruta with Bonferroni
> correction only set this to False.
__max_iter__ : int, default = 100
> The number of maximum iterations to perform.
__verbose__ : int, default=0
> Controls verbosity of output.
## Attributes ##
**n_features_** : int
> The number of selected features.
**support_** : array of shape [n_features]
> The mask of selected features - only confirmed ones are True.
**support_weak_** : array of shape [n_features]
> The mask of selected tentative features, which haven't gained enough
> support during the max_iter number of iterations..
**ranking_** : array of shape [n_features]
> The feature ranking, such that ``ranking_[i]`` corresponds to the
> ranking position of the i-th feature. Selected (i.e., estimated
> best) features are assigned rank 1 and tentative features are assigned
> rank 2.
## Examples ##
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from boruta import BorutaPy
# load X and y
# NOTE BorutaPy accepts numpy arrays only, hence the .values attribute
X = pd.read_csv('examples/test_X.csv', index_col=0).values
y = pd.read_csv('examples/test_y.csv', header=None, index_col=0).values
y = y.ravel()
# define random forest classifier, with utilising all cores and
# sampling in proportion to y labels
rf = RandomForestClassifier(n_jobs=-1, class_weight='balanced', max_depth=5)
# define Boruta feature selection method
feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1)
# find all relevant features - 5 features should be selected
feat_selector.fit(X, y)
# check selected features - first 5 features are selected
feat_selector.support_
# check ranking of features
feat_selector.ranking_
# call transform() on X to filter it down to selected features
X_filtered = feat_selector.transform(X)
## References ##
1. Kursa M., Rudnicki W., "Feature Selection with the Boruta Package" Journal of Statistical Software, Vol. 36, Issue 11, Sep 2010
%prep
%autosetup -n Boruta-0.3
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-Boruta -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri Apr 21 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3-1
- Package Spec generated
|