How to calculate the number of features in a training data using python?

decision_trees
python

#1

I am currently solving one classification problem using decision tree algorithm in python.
I have read that The more features the algorithm has available, the more chance for a complex fit.So I want to know the code by which I can calculate the number of features in training data.

My classifier code.
from sklearn import tree
clf = tree.DecisionTreeClassifier(min_samples_split=40)
clf= clf.fit(features_train,labels_train)
ypred= clf.predict(features_test)


#2

@hinduja1234 - There are two methods by which you can calculate the number of features.

1 - len(features_train) # default axis is 0 by which you are calculating the number of columns.
2- len(features_train.column) # it will calculate the number of columns(features)

from sklearn import tree
clf = tree.DecisionTreeClassifier(min_samples_split=40)
clf= clf.fit(features_train,labels_train)
ypred= clf.predict(features_test)
z=len(features_train)
print(z)

Hope this helps!

Regards,
Harry