在做特征选择时,可能面临两个问题:特征与类别预测有多大相关性,特征之间有多大冗余度。在特征选择中,“最好的m个特征不一定是m个最好的特征”,从相关度与冗余度来看,最好的m个特征是指与分类最相关的特征,但由于最好的m个特征之间可能存在冗余,因此最相关的m个特征并不一定比其他m个特征产生更好的分类准确率。
决策树在每次做特征选择的时候也是在剩下的特征集中根据信息增益(ID3)或信息增益比(C4.5)来选择最好的特征,他只考虑局部最优,因此会有之后的剪枝考虑全局最优。那么mRMR其实也是仅考虑局部最优,所以我们应该在mRMR的基础上再使用更复杂的wrapper或embedded. 参考 Feature Selection...
defmrmr_selection(data,relevance,redundancy,num_features):selected_features=[]# 选择第一个特征first_feature=max(relevance,key=relevance.get)selected_features.append(first_feature)for_inrange(num_features-1):# 计算当前所有未选择特征的得分scores={}forfeatureinrelevance.keys():iffeaturenotinselected_fea...
model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.ensemble import RandomForestClassifier data = datasets.load_iris() X = data.data y = data.target # 数据标准化 scaler = StandardScaler() X = scaler.fit_transform(X) # 划分训练集和测试集 X_trai...
from sklearn.feature_selection import SelectKBest # 选择K个最好的特征,返回选择特征后的数据 # 第一个参数为计算评估特征是否好的函数,该函数输入特征矩阵和目标向量,输出二元组(评分,P值)的数组,数组第i项为第i个特征的评分和P值。在此定义为计算相关系数 ...
For mutual information based feature selection methods like this web-version of mRMR, you might want to discretize your own data first as a few categorical states, -- empirically this leads to better results than continuous-value mutual information computation. You can also use the option below ...
Feature selection是指从原始数据中选择最相关的特征,以提高模型的性能和准确性。其中mRMR是一种常用的feature selection算法,它通过两个指标来评估每个特征的重要性:最小冗余度和最大相关性。最小冗余度指特征之间的相似程度,而最大相关性则指每个特征与目标变量之间的关联程度。通过综合考虑这两个指标,mRMR算法可以...
文献 《数据挖掘概念与技术》,韩家炜; Minimum Redundancy and Maximum Relevance Feature selection Variable selection using Random Forests Selecting good features – Part III: random forests mRMR (minimum Redundancy Maximum Relevance Feature Selection)
MRMR是一种滤波式特征选择算法,能最大化特征和目标间的相关性,减少相关特征之间冗余。该算法将每个特征和输出类别作为单独变量,使用互信息 I(a,b)衡量两个变量间的相似度,该表达式为: 参考文献 [1] Peng Hanchuan , Long Fuhui, Ding Chris. Feature selection based on mutual information: criteria of max-de...
def mrmr_selection(data, relevance, redundancy, num_features): selected_features = [] first_feature = max(relevance, key=relevance.get) selected_features.append(first_feature) for _ in range(num_features - 1): scores = {} for feature in relevance.keys(): if feature not in selected_featur...