Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
v_pad = np.pad(v, (0, n_pad), 'constant')
self.d_abs_ragged.append(v_pad)
self.d_abs_ragged = np.array(self.d_abs_ragged)
if self.enc_model:
enc_data = self.enc.predict(train_data)
self.class_proto = {} # type: dict
self.class_enc = {} # type: dict
for i in range(self.classes):
idx = np.where(preds == i)[0]
self.class_proto[i] = np.expand_dims(np.mean(enc_data[idx], axis=0), axis=0)
self.class_enc[i] = enc_data[idx]
elif self.use_kdtree:
logger.warning('No encoder specified. Using k-d trees to represent class prototypes.')
if trustscore_kwargs is not None:
ts = TrustScore(**trustscore_kwargs)
else:
ts = TrustScore()
if self.is_cat: # map categorical to numerical data
train_data = ord_to_num(train_data_ord, self.d_abs)
ts.fit(train_data, preds, classes=self.classes)
self.kdtrees = ts.kdtrees
self.X_by_class = ts.X_kdtree
self.d_abs_ragged = np.array(self.d_abs_ragged)
if self.enc_model:
enc_data = self.enc.predict(train_data)
self.class_proto = {} # type: dict
self.class_enc = {} # type: dict
for i in range(self.classes):
idx = np.where(preds == i)[0]
self.class_proto[i] = np.expand_dims(np.mean(enc_data[idx], axis=0), axis=0)
self.class_enc[i] = enc_data[idx]
elif self.use_kdtree:
logger.warning('No encoder specified. Using k-d trees to represent class prototypes.')
if trustscore_kwargs is not None:
ts = TrustScore(**trustscore_kwargs)
else:
ts = TrustScore()
if self.is_cat: # map categorical to numerical data
train_data = ord_to_num(train_data_ord, self.d_abs)
ts.fit(train_data, preds, classes=self.classes)
self.kdtrees = ts.kdtrees
self.X_by_class = ts.X_kdtree