/// <summary>
        /// Returns the rescaled (0-100) and sorted variable importance scores with corresponding name
        /// </summary>
        /// <param name="featureNameToIndex"></param>
        /// <returns></returns>
        public Dictionary <string, double> GetVariableImportance(Dictionary <string, int> featureNameToIndex)
        {
            var textTrees             = m_model.DumpModelEx(fmap: string.Empty, with_stats: 1, format: "text");
            var rawVariableImportance = FeatureImportanceParser.ParseFromTreeDump(textTrees, featureNameToIndex.Count);

            var max = rawVariableImportance.Max();

            var scaledVariableImportance = rawVariableImportance
                                           .Select(v => (v / max) * 100.0)
                                           .ToArray();

            return(featureNameToIndex.ToDictionary(kvp => kvp.Key, kvp => scaledVariableImportance[kvp.Value])
                   .OrderByDescending(kvp => kvp.Value)
                   .ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
        }
Exemplo n.º 2
0
 public string[] DumpModelEx(string fmap    = "",
                             int with_stats = 0,
                             string format  = "json")
 {
     return(booster.DumpModelEx(fmap, with_stats, format));
 }