Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to find the contributing features of each tree in Random Forest Classifier in Python

$
0
0

@jayashrees wrote:

I have built a Random Forest Classifier with 50 trees and cross validated it with K-folds technique keeping number of folds as 5.Out of 60,630 features in my dataset,I have used 70% of the features.

kfold = model_selection.KFold(n_splits=5, random_state=42)
model=RandomForestClassifier(n_estimators=70,n_jobs=-1,oob_score = True,max_features = 0.7, min_samples_leaf = 50)
results = model_selection.cross_val_score(model,features,labels, cv=kfold,scoring='f1')

How to find the features that went in to building each tree?Likewise I want to find for all 50 trees.

Expected Result:

Tree 1:feature1,feature5,feature 7…
Tree 2: feature 10,feature 17,feature30…
.
.
.
.
Tree 50:feature 40000,feature 60000,feature 60000

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles