From fc08a8f643d0f38d12a728a4d3045f4f7be8f9bd Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Thu, 12 Mar 2020 09:41:54 -0500 Subject: [PATCH] bug fix: continuous variable handling --- data/gan.py | 2 +- data/maker/__init__.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/data/gan.py b/data/gan.py index 3c41f59..4f34634 100644 --- a/data/gan.py +++ b/data/gan.py @@ -409,7 +409,7 @@ class Train (GNet): # losses = tf.compat.v1.get_collection(flag, scope) total_loss = tf.add_n(losses, name='total_loss') - print (total_loss) + # print (total_loss) return total_loss, w def input_fn(self): """ diff --git a/data/maker/__init__.py b/data/maker/__init__.py index 354b78f..97cc3dd 100644 --- a/data/maker/__init__.py +++ b/data/maker/__init__.py @@ -22,9 +22,10 @@ class ContinuousToDiscrete : This function will convert a continous stream of information into a variety a bit stream of bins """ # BOUNDS = np.repeat(np.divide(X.max(),n),n).cumsum().tolist() - - BOUNDS = ContinuousToDiscrete.bounds(np.round(X,ContinuousToDiscrete.ROUND_UP),n) - + # print ( X.values.astype(np.float32)) + # print ("___________________________") + values = X.values.astype(np.float32) + BOUNDS = ContinuousToDiscrete.bounds(values,n) # _map = [{"index":BOUNDS.index(i),"ubound":i} for i in BOUNDS] _matrix = [] m = [] @@ -40,12 +41,13 @@ class ContinuousToDiscrete : # # for items in BOUNDS : # index = BOUNDS.index(items) - return _matrix + return np.array(_matrix) @staticmethod def bounds(x,n): # return np.array_split(x,n) - return list(pd.cut(np.array( np.round(x,ContinuousToDiscrete.ROUND_UP) ),n).categories) + values = np.round(x,ContinuousToDiscrete.ROUND_UP) + return list(pd.cut(values,n).categories)