proximity loss when there are not continous features
the method compute_proximity_loss() from dice_genetic.py returns an error when the dataset does not contain continous features.
def compute_proximity_loss(self, x_hat_unnormalized, query_instance_normalized):
"""Compute weighted distance between two vectors."""
x_hat = self.data_interface.normalize_data(x_hat_unnormalized)
feature_weights = np.array(
[self.feature_weights_list[0][i] for i in self.data_interface.continuous_feature_indexes])
product = np.multiply(
(abs(x_hat - query_instance_normalized)[:, [self.data_interface.continuous_feature_indexes]]),
feature_weights)
product = product.reshape(-1, product.shape[-1])
proximity_loss = np.sum(product, axis=1)
# Dividing by the sum of feature weights to normalize proximity loss
return proximity_loss / sum(feature_weights)
@DBrughmans, can you paste the error or the stack trace here?
@DBrughmans can you paste the error or the stack trace here so that we can make progress on this issue?
@gaugup I have the error message when setting all the variables as str to make it categorical: " 367 (abs(x_hat - query_instance_normalized)[:, [self.data_interface.continuous_feature_indexes]]), 368 feature_weights) --> 369 product = product.reshape(-1, product.shape[-1]) 370 proximity_loss = np.sum(product, axis=1) 371
ValueError: cannot reshape array of size 0 into shape (0) "
I have the same error