bug fix: continuous variable handling

This commit is contained in:
Steve Nyemba 2020-03-12 09:41:54 -05:00
parent bbd03c4a63
commit fc08a8f643
2 changed files with 8 additions and 6 deletions

View File

@ -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):
"""

View File

@ -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)