zer02
zer02

Reputation: 4021

How can I use "metrics.mutual_info" in scikit's feature.selection

I would like to use other scoring functions then chi2 etc., that are not listed on this page.

http://scikit-learn.org/stable/modules/feature_selection.html

http://scikit-learn.org/stable/modules/classes.html

For example metrics.mutual_info and metrics.balanced_accuracy_score

How can I integrate those into my code?

Thanks for help

Upvotes: 3

Views: 2078

Answers (1)

Christos Baziotis
Christos Baziotis

Reputation: 6035

The new scikit-learn version 0.18, has added support for Mutual information feature selection. So no need to use the metrics.mutual_info. You can use the new feature_selection.mutual_info_classif score function in SelectKBest or SelectPercentile just like you use chi2.

X_new = SelectKBest(mutual_info_classif, k=100).fit_transform(X, y)

For more information about the resent changes look at the changelog.

Upvotes: 3

Related Questions