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