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

TypeError: get_decimal_precisions() got an unexpected keyword argument 'output_type' #129

Open
etheng-jiao opened this issue Apr 29, 2021 · 4 comments

Comments

@etheng-jiao
Copy link

d = dice_ml.Data(dataframe=pipdata, continuous_features=['A','B','C','D','E','F','H','I','J','K'],outcome_name='G')from tensorflow.keras.models import Sequential
from tensorflow.python.keras.layers import Dense
from tensorflow.python.keras.wrappers.scikit_learn import KerasRegressor
import tensorflow.compat.v1 as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from sklearn.model_selection import train_test_split
sess = tf.InteractiveSession()

Generating train and test data

datasetX = pipdata.drop("G",axis=1)
datasetY = pipdata["G"]

X_train,X_test,Y_train,Y_test = train_test_split(datasetX,datasetY,test_size=0.2,random_state=0)

Fitting a dense neural network model

ann_model = Sequential()
ann_model.add(Dense(6, input_shape=(X_train.shape[1],), activation=tf.nn.relu))
ann_model.add(Dense(1, activation=tf.nn.sigmoid))
ann_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
history=ann_model.fit(X_train, y_train, validation_split=0.20, epochs=30, verbose=0)
#, class_weight={0:1,1:2})
history
m = dice_ml.Model(model=ann_model,backend='sklearn')

new_d = dice_ml.Data(features={
'A':[-130, 4500],
'B':[-150,7000],
'C':[-54,6200],
'D':[-150,8900],
'E':[-26,1250],
'F':[-26,2545],
'H':[-625,8270],
'I':[-30,1581],
'J':[-135,7364],
'K':[-72,4666]},
outcome_name='G')
exp = dice_ml.Dice(new_d,m)
exp

---> 37 self.precisions = self.data_interface.get_decimal_precisions(output_type="dict")
38 if self.data_interface.outcome_name in self.precisions:
39 self.outcome_precision = [self.precisions[self.data_interface.outcome_name]]

TypeError: get_decimal_precisions() got an unexpected keyword argument 'output_type'

@amit-sharma
Copy link
Collaborator

amit-sharma commented Apr 29, 2021

@etheng-jiao if you are using tensorflow, then need to set the backend to TF1 (for tensorflow v1) or TF2.

m = dice_ml.Model(model=ann_model,backend='TF1')

@amit-sharma
Copy link
Collaborator

Did the fix above work for you @etheng-jiao ?

@etheng-jiao
Copy link
Author

etheng-jiao commented May 14, 2021 via email

@gaugup
Copy link
Collaborator

gaugup commented May 25, 2021

@etheng-jiao did you give a try with 'TF2' when initializing the dice-ml model? Are you unblocked? If so, could you close this issue?

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

3 participants