bug fix: continuous variable handling
This commit is contained in:
parent
bbd03c4a63
commit
fc08a8f643
|
@ -409,7 +409,7 @@ class Train (GNet):
|
||||||
# losses = tf.compat.v1.get_collection(flag, scope)
|
# losses = tf.compat.v1.get_collection(flag, scope)
|
||||||
|
|
||||||
total_loss = tf.add_n(losses, name='total_loss')
|
total_loss = tf.add_n(losses, name='total_loss')
|
||||||
print (total_loss)
|
# print (total_loss)
|
||||||
return total_loss, w
|
return total_loss, w
|
||||||
def input_fn(self):
|
def input_fn(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -22,9 +22,10 @@ class ContinuousToDiscrete :
|
||||||
This function will convert a continous stream of information into a variety a bit stream of bins
|
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 = np.repeat(np.divide(X.max(),n),n).cumsum().tolist()
|
||||||
|
# print ( X.values.astype(np.float32))
|
||||||
BOUNDS = ContinuousToDiscrete.bounds(np.round(X,ContinuousToDiscrete.ROUND_UP),n)
|
# print ("___________________________")
|
||||||
|
values = X.values.astype(np.float32)
|
||||||
|
BOUNDS = ContinuousToDiscrete.bounds(values,n)
|
||||||
# _map = [{"index":BOUNDS.index(i),"ubound":i} for i in BOUNDS]
|
# _map = [{"index":BOUNDS.index(i),"ubound":i} for i in BOUNDS]
|
||||||
_matrix = []
|
_matrix = []
|
||||||
m = []
|
m = []
|
||||||
|
@ -40,12 +41,13 @@ class ContinuousToDiscrete :
|
||||||
#
|
#
|
||||||
# for items in BOUNDS :
|
# for items in BOUNDS :
|
||||||
# index = BOUNDS.index(items)
|
# index = BOUNDS.index(items)
|
||||||
return _matrix
|
return np.array(_matrix)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bounds(x,n):
|
def bounds(x,n):
|
||||||
# return np.array_split(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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue