Skip to content

Commit

Permalink
Update logic for appending points
Browse files Browse the repository at this point in the history
  • Loading branch information
ShengKungYi committed May 8, 2015
1 parent 7021408 commit 812f6ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/feature_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True

for key in keys:
tmp_list = []
append = False
for feature in features:
try:
dictionary[key][feature]
Expand All @@ -64,25 +63,26 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True
value = 0
tmp_list.append( float(value) )

# Logic for deciding whether or not to add the data point.
append = True
### if all features are zero and you want to remove
### data points that are all zero, do that here
if remove_all_zeroes:
all_zeroes = True
append = False
for item in tmp_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:
any_zeroes = False
if 0 in tmp_list or "NaN" in tmp_list:
append = False
### Append the data point if flagged for addition.
if append:
return_list.append( np.array(tmp_list) )


return np.array(return_list)


Expand Down

0 comments on commit 812f6ac

Please sign in to comment.