Skip to content

Commit

Permalink
Lesson 6 compatibility
Browse files Browse the repository at this point in the history
Previous modifications to remove ‘poi’ as removal criteria caused
incompatibility with lesson 6 mini-project; additional checks added to
regain compatibility.
  • Loading branch information
Sheng Kung Yi authored and Sheng Kung Yi committed May 17, 2015
1 parent 8152779 commit 6cb6f1f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/feature_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,24 @@ 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
### if any features for a given data point are zero
### 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:
Expand Down

0 comments on commit 6cb6f1f

Please sign in to comment.