bug fix ...

This commit is contained in:
Steve Nyemba 2020-03-06 16:22:37 -06:00
parent 97669f3b6b
commit d72fb6b4e3
1 changed files with 11 additions and 5 deletions

View File

@ -578,18 +578,20 @@ class Predict(GNet):
# if we are dealing with numeric values only we can perform a simple marginal sum against the indexes # if we are dealing with numeric values only we can perform a simple marginal sum against the indexes
# The code below will insure we have some acceptable cardinal relationships between id and synthetic values # The code below will insure we have some acceptable cardinal relationships between id and synthetic values
# #
df = pd.DataFrame(np.round(f).astype(np.int32))
df = pd.DataFrame(np.round(f)).astype(np.int32)
p = 0 not in df.sum(axis=1).values p = 0 not in df.sum(axis=1).values
x = df.sum(axis=1).values x = df.sum(axis=1).values
if np.divide( np.sum(x), x.size) > .9 or p and np.sum(x) == x.size and x.size == self.values.size: if np.divide( np.sum(x), x.size) > .9 or p and np.sum(x) == x.size :
ratio.append(np.divide( np.sum(x), x.size)) ratio.append(np.divide( np.sum(x), x.size))
found.append(df) found.append(df)
if i == CANDIDATE_COUNT: if i == CANDIDATE_COUNT:
break break
else: else:
continue continue
# i = df.T.index.astype(np.int32) #-- These are numeric pseudonyms # i = df.T.index.astype(np.int32) #-- These are numeric pseudonyms
@ -597,9 +599,13 @@ class Predict(GNet):
# #
# In case we are dealing with actual values like diagnosis codes we can perform # In case we are dealing with actual values like diagnosis codes we can perform
# #
_index = [found.index(item) for item in found if item.shape[1] == len(self.values)]
if not _index :
INDEX = np.random.choice(np.arange(len(found)),1)[0] INDEX = np.random.choice(np.arange(len(found)),1)[0]
INDEX = ratio.index(np.max(ratio)) INDEX = ratio.index(np.max(ratio))
else:
INDEX = _index[0]
df = found[INDEX] df = found[INDEX]
columns = self.ATTRIBUTES['synthetic'] if isinstance(self.ATTRIBUTES['synthetic'],list)else [self.ATTRIBUTES['synthetic']] columns = self.ATTRIBUTES['synthetic'] if isinstance(self.ATTRIBUTES['synthetic'],list)else [self.ATTRIBUTES['synthetic']]