41

The command xgb.importance returns a graph of feature importance measured by an f score.

What does this f score represent and how is it calculated?

Output: Graph of feature importance Graph of feature importance

4

2 に答える 2

39

これは、各機能が分割された回数を単純に合計する指標です。これは、R バージョンの Frequency メトリックに似ています。https://cran.r-project.org/web/packages/xgboost/xgboost.pdf

これは、可能な限り基本的な機能の重要度の指標です。

つまり、この変数は何回分割されましたか?

このメソッドのコードは、すべてのツリーに特定の機能の存在を追加するだけであることを示しています。

[ここ.. https://github.com/dmlc/xgboost/blob/master/python-package/xgboost/core.py#L953][1]

def get_fscore(self, fmap=''):
    """Get feature importance of each feature.
    Parameters
    ----------
    fmap: str (optional)
       The name of feature map file
    """
    trees = self.get_dump(fmap)  ## dump all the trees to text
    fmap = {}                    
    for tree in trees:              ## loop through the trees
        for line in tree.split('\n'):     # text processing
            arr = line.split('[')
            if len(arr) == 1:             # text processing 
                continue
            fid = arr[1].split(']')[0]    # text processing
            fid = fid.split('<')[0]       # split on the greater/less(find variable name)

            if fid not in fmap:  # if the feature id hasn't been seen yet
                fmap[fid] = 1    # add it
            else:
                fmap[fid] += 1   # else increment it
    return fmap                  # return the fmap, which has the counts of each time a  variable was split on
于 2015-12-11T21:39:19.040 に答える
3

この答えは正確で完全であることがわかりました。これは、feature_importances の実装を示しています。

https://stats.stackexchange.com/questions/162162/relative-variable-importance-for-boosting

于 2018-03-19T21:46:11.290 に答える