ITMO_FS.filters.univariate.gini_index¶
-
ITMO_FS.filters.univariate.gini_index(x, y)¶ Calculate Gini index for features. Bigger values mean more important features. This measure works best with discrete features due to being based on information theory.
Parameters: - x (array-like, shape (n_samples, n_features)) – The training input samples.
- y (array-like, shape (n_samples,)) – The target values.
Returns: array-like, shape (n_features,)
Return type: feature scores
See also
http()- //lkm.fri.uni-lj.si/xaigor/slo/clanki/ijcai95z.pdf
Examples
>>> from ITMO_FS.filters.univariate import gini_index >>> from sklearn.preprocessing import KBinsDiscretizer >>> x = np.array([[3, 3, 3, 2, 2], [3, 3, 1, 2, 3], [1, 3, 5, 1, 1], ... [3, 1, 4, 3, 1], [3, 1, 2, 3, 1]]) >>> y = np.array([1, 3, 2, 1, 2]) >>> est = KBinsDiscretizer(n_bins=10, encode='ordinal') >>> x = est.fit_transform(x) >>> gini_index(x, y) array([0.14 , 0.04 , 0.64 , 0.24 , 0.37333333])