Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
4db1c62
1
Parent(s):
b80fb14
Use random forest for feature selection
Browse files- pysr/sr.py +2 -2
pysr/sr.py
CHANGED
@@ -722,10 +722,10 @@ def run_feature_selection(X, y, select_k_features):
|
|
722 |
the k most important features in X, returning indices for those
|
723 |
features as output."""
|
724 |
|
725 |
-
from sklearn.ensemble import RandomForestRegressor
|
726 |
from sklearn.feature_selection import SelectFromModel, SelectKBest
|
727 |
|
728 |
-
clf =
|
729 |
clf.fit(X, y)
|
730 |
selector = SelectFromModel(clf, threshold=-np.inf,
|
731 |
max_features=select_k_features, prefit=True)
|
|
|
722 |
the k most important features in X, returning indices for those
|
723 |
features as output."""
|
724 |
|
725 |
+
from sklearn.ensemble import RandomForestRegressor
|
726 |
from sklearn.feature_selection import SelectFromModel, SelectKBest
|
727 |
|
728 |
+
clf = RandomForestRegressor(n_estimators=100, max_depth=3, random_state=0)
|
729 |
clf.fit(X, y)
|
730 |
selector = SelectFromModel(clf, threshold=-np.inf,
|
731 |
max_features=select_k_features, prefit=True)
|