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

Dice Object Initialization Error #429

Open
ntheol opened this issue Feb 19, 2024 · 0 comments
Open

Dice Object Initialization Error #429

ntheol opened this issue Feb 19, 2024 · 0 comments

Comments

@ntheol
Copy link

ntheol commented Feb 19, 2024

Hello!

I have trained an ML pipeline for a pytorch model by using the skorch wrapper like this:

nn = NeuralNetBinaryClassifier(nn_model,criterion=nn.BCELoss(),optimizer=torch.optim.AdamW, max_epochs=10, batch_size=32,verbose=False)

numerical_transformer = Pipeline([
('scaler', StandardScaler())
])

label_encoded_transformer = Pipeline([
('label_encoder', OrdinalEncoder())
])

one_hot_encoded_transformer = Pipeline([
('one_hot_encoder', OneHotEncoder())
])

preprocessor = ColumnTransformer(
transformers=[
('num', numerical_transformer,numeric_columns),
# ('label',label_encoded_transformer,label_encoded_features),
('one_hot', one_hot_encoded_transformer, cat_columns)
])

params = {
"Model__lr": [0.001, 0.01, 0.1],
"Model__batch_size": (16,64), # Different batch sizes
"Model__optimizer": [AdamW, Adam,SGD], # Different optimizers
"preprocessor__num__scaler": [StandardScaler(), MinMaxScaler(),RobustScaler()]
}

ml_pipeline = Pipeline([("preprocessor", preprocessor),
('float32', FunctionTransformer(func=convert_to_float32)),
("Model", nn)])

optimizer = GridSearchCV(ml_pipeline,param_grid=params,optimization_algorithm='grid_search')
opt = optimizer.fit(train,train_labels)

Does DiCE support this kind of model?
When trying to initialize it in this way :
d = dice_ml.Data(dataframe=train, continuous_features=numeric_cols.tolist(), outcome_name='label')

m = dice_ml.Model(model=opt.best_estimator_, backend="sklearn")

#Initializing DiCE object
exp = dice_ml.Dice(d, m, method="random")

I get the below error:
error

Is it because DiCE does not support the skorch wrapper?
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant