d3rlpy
d3rlpy copied to clipboard
[Question] Embeddings for categorical variables
Greetings,
We have categorical features in our observation data. Are we able to modify the CustomEncoderFactory for the custom neural network to include categorical features to build embeddings?
I'm familiar with how to do with a vanilla torch dataset, i.e.
`class ModelDataset(Dataset): def init(self, df, cat_fields, cont_fields, y): self.df = df self.y = y.astype(np.float32) cat_values = [c.values for n,c in df[cat_fields].items()] cont_values = [c.values for n,c in df[cont_fields].items()] self.cat_features = np.stack(cat_values, 1).astype(np.int64) self.cont_features = np.stack(cont_values, 1).astype(np.float32)
def __len__(self):
return len(self.df)
def __getitem__(self, idx):
cat_val = self.cat_features[idx]
cont_val = self.cont_features[idx]
y = self.y[idx]
return [cat_val, cont_val, y]`