D = data.values X = D[:, :-1] y = D[:, -1]
Here, X contains the features, and y contains the target variable of the dataset.
classifier = ExtraTreesClassifier(n_estimators=100) classifier.fit(X, y)
Now, we are initializing the classifier using the ExtraTreesClassifier class. After the initialization, we are fitting the classifier with the features of the dataset and the target. As a result, the classifier learns from the dataset. Now, the classifier can now calculate the feature importances of all the features.
print(classifier.feature_importances_)
The above Python statement now prints the feature importances of all the features. Please note that the sum of the values of the output array is 1. The output of the above program will be like the following:
[0.10974523 0.23562676 0.10118392 0.08101406 0.07622407 0.13656807 0.12010095 0.13953694]








































0 Comments