Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 增加功能重要性_Python_Machine Learning_Classification_Random Forest - Fatal编程技术网

Python 增加功能重要性

Python 增加功能重要性,python,machine-learning,classification,random-forest,Python,Machine Learning,Classification,Random Forest,我正在研究一个分类问题。我有大约1000个特性,目标变量有2个类。所有1000个要素的值均为1或0。我正在尝试查找特征重要性,但我的特征重要性值在0.0-0.003之间变化。我不确定这样低的值是否有意义 有没有一种方法可以提高功能的重要性 # Variable importance rf = RandomForestClassifier(min_samples_split=10, random_state =1) rf.fit(X, Y) print ("Features sorted

我正在研究一个分类问题。我有大约1000个特性,目标变量有2个类。所有1000个要素的值均为1或0。我正在尝试查找特征重要性,但我的特征重要性值在0.0-0.003之间变化。我不确定这样低的值是否有意义

有没有一种方法可以提高功能的重要性

# Variable importance
rf = RandomForestClassifier(min_samples_split=10, random_state =1)  
rf.fit(X, Y)  
print ("Features sorted by their score:")
a =  (list(zip(map(lambda x: round(x, 3), rf.feature_importances_), X)))

我真的很感激任何帮助!谢谢

因为您只有两个目标类,所以您可以执行不等方差t检验,当所有其他特征排序方法都失败时,该检验对于在二元分类任务中查找重要特征非常有用。您可以使用
scipy.stats.ttest\u ind
实现这一点。它基本上是一种统计测试,用于检查这两种分布是否不同。如果返回的p值小于0.05,则可以假定它们是不同的分布。要实现每个功能,请执行以下步骤:

  • 分别提取类别1和类别2的所有预测值
  • 对这两个分布运行test_ind,指定它们的方差未知,并确保它是双尾t检验
  • 如果p值小于0.05,则此功能非常重要
  • 或者,您可以对所有功能执行此操作,并使用p值作为功能重要性的度量。p值越低,特征的重要性越高

    干杯