interpretml / DiCE

Generate Diverse Counterfactual Explanations for any machine learning model.
https://interpretml.github.io/DiCE/
MIT License
1.36k stars 188 forks source link

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

Open etheng-jiao opened 3 years ago

etheng-jiao commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

etheng-jiao commented 3 years ago

Yeah, sorry for my late. The problem is about tensorflow2

2021年5月6日 上午9:51,Amit Sharma @.***> 写道:

Did the fix above work for you @etheng-jiao https://github.com/etheng-jiao ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/interpretml/DiCE/issues/129#issuecomment-833311562, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASBO5OYUVCAD5CCUA3SNV73TMJDBHANCNFSM43ZWVGDA.

gaugup commented 3 years ago

@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?