From 6cb6f1f3b16061888f08611c84314ec92cbe6caa Mon Sep 17 00:00:00 2001 From: Sheng Kung Yi Date: Sun, 17 May 2015 05:34:15 -0700 Subject: [PATCH] Lesson 6 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous modifications to remove ‘poi’ as removal criteria caused incompatibility with lesson 6 mini-project; additional checks added to regain compatibility. --- tools/feature_format.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/feature_format.py b/tools/feature_format.py index 1d32ce72cb0..09070e14d7a 100644 --- a/tools/feature_format.py +++ b/tools/feature_format.py @@ -71,11 +71,16 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True # Logic for deciding whether or not to add the data point. append = True + # exclude 'poi' class as criteria. + if features[0] == 'poi': + test_list = tmp_list[1:] + else: + test_list = tmp_list ### if all features are zero and you want to remove ### data points that are all zero, do that here if remove_all_zeroes: append = False - for item in tmp_list[1:]: + for item in test_list: if item != 0 and item != "NaN": append = True break @@ -83,7 +88,7 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True ### and you want to remove data points with any zeroes, ### handle that here if remove_any_zeroes: - if 0 in tmp_list[1:] or "NaN" in tmp_list[1:]: + if 0 in test_list or "NaN" in test_list: append = False ### Append the data point if flagged for addition. if append: