Skip to content

Commit 6383ca3

Browse files
authored
Adds Python syntax highlighting to README.md (#76)
1 parent f9cdd44 commit 6383ca3

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,36 @@ __verbose__ : int, default=0
172172

173173
## Examples ##
174174

175-
import pandas as pd
176-
from sklearn.ensemble import RandomForestClassifier
177-
from boruta import BorutaPy
178-
179-
# load X and y
180-
# NOTE BorutaPy accepts numpy arrays only, hence the .values attribute
181-
X = pd.read_csv('examples/test_X.csv', index_col=0).values
182-
y = pd.read_csv('examples/test_y.csv', header=None, index_col=0).values
183-
y = y.ravel()
184-
185-
# define random forest classifier, with utilising all cores and
186-
# sampling in proportion to y labels
187-
rf = RandomForestClassifier(n_jobs=-1, class_weight='balanced', max_depth=5)
188-
189-
# define Boruta feature selection method
190-
feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1)
191-
192-
# find all relevant features - 5 features should be selected
193-
feat_selector.fit(X, y)
194-
195-
# check selected features - first 5 features are selected
196-
feat_selector.support_
197-
198-
# check ranking of features
199-
feat_selector.ranking_
200-
201-
# call transform() on X to filter it down to selected features
202-
X_filtered = feat_selector.transform(X)
175+
```python
176+
import pandas as pd
177+
from sklearn.ensemble import RandomForestClassifier
178+
from boruta import BorutaPy
179+
180+
# load X and y
181+
# NOTE BorutaPy accepts numpy arrays only, hence the .values attribute
182+
X = pd.read_csv('examples/test_X.csv', index_col=0).values
183+
y = pd.read_csv('examples/test_y.csv', header=None, index_col=0).values
184+
y = y.ravel()
185+
186+
# define random forest classifier, with utilising all cores and
187+
# sampling in proportion to y labels
188+
rf = RandomForestClassifier(n_jobs=-1, class_weight='balanced', max_depth=5)
189+
190+
# define Boruta feature selection method
191+
feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1)
192+
193+
# find all relevant features - 5 features should be selected
194+
feat_selector.fit(X, y)
195+
196+
# check selected features - first 5 features are selected
197+
feat_selector.support_
198+
199+
# check ranking of features
200+
feat_selector.ranking_
201+
202+
# call transform() on X to filter it down to selected features
203+
X_filtered = feat_selector.transform(X)
204+
```
203205

204206
## References ##
205207

0 commit comments

Comments
 (0)