Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Embeddings for categorical variables #304

Open
esbraun opened this issue Jul 28, 2023 · 1 comment
Open

[Question] Embeddings for categorical variables #304

esbraun opened this issue Jul 28, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@esbraun
Copy link

esbraun commented Jul 28, 2023

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]`
@esbraun esbraun added the enhancement New feature or request label Jul 28, 2023
@takuseno
Copy link
Owner

@esbraun Hi, thanks for the issue. You can build your own custom network for training.
https://d3rlpy.readthedocs.io/en/v2.0.4/tutorials/customize_neural_network.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants