From 84b82ab55fb82a636fda75fdc28d0439add48a93 Mon Sep 17 00:00:00 2001 From: Yizheng Liao Date: Thu, 23 Apr 2015 22:28:32 -0700 Subject: [PATCH 1/2] add flag variable in Python get_fscore() to control printing --- wrapper/xgboost.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wrapper/xgboost.py b/wrapper/xgboost.py index 53bec0a69..51200f8ed 100644 --- a/wrapper/xgboost.py +++ b/wrapper/xgboost.py @@ -510,14 +510,16 @@ class Booster(object): res.append(str(sarr[i])) return res - def get_fscore(self, fmap=''): + def get_fscore(self, fmap='',verbose = False): """ Get feature importance of each feature. """ trees = self.get_dump(fmap) fmap = {} for tree in trees: - sys.stdout.write(str(tree) + '\n') + if verbos is True: + sys.stdout.write(str(tree) + '\n') + for l in tree.split('\n'): arr = l.split('[') if len(arr) == 1: From b5c8085638a786bd0c2f180be0e274e6727b9f06 Mon Sep 17 00:00:00 2001 From: Yizheng Liao Date: Thu, 23 Apr 2015 23:40:10 -0700 Subject: [PATCH 2/2] remove print in Python get_fscore() --- wrapper/xgboost.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wrapper/xgboost.py b/wrapper/xgboost.py index 51200f8ed..7f3958769 100644 --- a/wrapper/xgboost.py +++ b/wrapper/xgboost.py @@ -510,16 +510,13 @@ class Booster(object): res.append(str(sarr[i])) return res - def get_fscore(self, fmap='',verbose = False): + def get_fscore(self, fmap=''): """ Get feature importance of each feature. """ trees = self.get_dump(fmap) fmap = {} for tree in trees: - if verbos is True: - sys.stdout.write(str(tree) + '\n') - for l in tree.split('\n'): arr = l.split('[') if len(arr) == 1: