mutual information&mRMR

互信息

给定两个随机变量x,y,他们的互信息(mutual information)有他们的概率密度函数来定义

 

    

最大决定性(max-dependency)

把互信息的思想用在特征选择上,我们是要选取一个特征子集,使得能最好的决定相关类别,我们管这个叫最大决定性(Max-Dependency),定义如下

    

由此可见

 

    

最大相关和最小冗余(max-relevance and min-redundancy)

定义最大相关性

最大相关性是特征与类别之间的相关性

    

最小冗余性: 两两特征之间的冗余性

    

把这两个概念相结合,我们用Max-R 和Min-R 来作为特征选择的原则,即希望选取,与类别最相关并且相互之间冗余性最小的特征。

    

显然,如果是像Max-Dependency 一样的化,直接选取子集,是一个NPhard 问题。

在实际操作上我们都是用用增量选取的方式来解决这个问题的,当已经有时,从剩下的特征集合中选择,显然我们希望选一个和类别最相关并且和已有的特征之间冗余性最小的特征

    

转载于:https://www.cnblogs.com/chend926/archive/2012/06/01/2530612.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MRMR (最大相关最小冗余) 算法是一种特征选择算法,它可以在高维数据中选择最具代表性的特征。下面是一个使用Python实现MRMR算法的示例代码: ```python import numpy as np def mrmr(X, y, n_selected_features): """ MRMR Algorithm for feature selection X: array-like, shape (n_samples, n_features) input data y: array-like, shape (n_samples,) target variable n_selected_features: int number of selected features """ # Initialize the list of selected features and the list of remaining features selected_features = [] remaining_features = list(range(X.shape[1])) # Calculate the mutual information between each feature and the target variable mi = mutual_info_classif(X, y) # Select the feature with the highest mutual information with the target variable best_feature_idx = np.argmax(mi) selected_features.append(best_feature_idx) remaining_features.remove(best_feature_idx) # Select the remaining features using the MRMR criterion while len(selected_features) < n_selected_features: mrmr_score = [] for feature_idx in remaining_features: # Calculate the relevance between the feature and the target variable relevance = mi[feature_idx] # Calculate the redundancy between the feature and the selected features redundancy = np.mean([mutual_info_score(X[:, feature_idx], X[:, selected_feature]) for selected_feature in selected_features]) # Calculate the MRMR criterion mrmr_score.append(relevance - redundancy) # Select the feature with the highest MRMR score best_feature_idx = remaining_features[np.argmax(mrmr_score)] selected_features.append(best_feature_idx) remaining_features.remove(best_feature_idx) return selected_features ``` 在上面的代码中,`X`是输入数据,`y`是目标变量,`n_selected_features`是要选择的特征数量。该代码使用`mutual_info_classif`和`mutual_info_score`函数计算特征与目标变量之间的互信息和特征之间的互信息,并使用MRMR准则选择最具代表性的特征。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值