I have this boruta code, and I want to generate the results in pandas with columns included
model = RandomForestRegressor(n_estimators=100, max_depth=5, random_state=42)# let's initialize Borutafeat_selector = BorutaPy( verbose=2, estimator=model, n_estimators='auto', max_iter=10, # numero di iterazioni da fare random_state=42,)# train Boruta# N.B.: X and y must be numpy arraysfeat_selector.fit(np.array(X), np.array(y))# print support and ranking for each featureprint("\n------Support and Ranking for each feature------\n")for i in range(len(feat_selector.support_)): if feat_selector.support_[i]: print("Passes the test: ", X.columns[i]," - Ranking: ", feat_selector.ranking_[i], "✔️") else: print("Doesn't pass the test: ", X.columns[i], " - Ranking: ", feat_selector.ranking_[i], "❌")# features selected by BorutaX_filtered = feat_selector.transform(np.array(X))
My selected result is this:
X.columns[feat_selector.support_]Index(['J80', 'J100', 'J160', 'J200', 'J250'], dtype='object')X_filteredarray([[12.73363 , 8.518314 , 5.2625847 , ..., 0.06733382]])
How do I generate the result in Pandas dataframe with the headers? Now I have up to 25 headers.