-
Notifications
You must be signed in to change notification settings - Fork 770
Description
Hi
I would like to use LIME interpretation for the dataset, where i have done preprocessing like OneHotCoding, Imputer, Calculating new feature using ColumnTransformation. I found the below sample code provided for TabularExplainer (interpret-community). Here, the interpretation is provided on the raw feature based on transformation been passed.
When i have tried doing the same using LimeTabular i get the error, "Specifying the columns using strings is only supported for pandas DataFrames"
How i can achieve the interpretation of raw feature after such preprocessing is done?
`from sklearn.compose import ColumnTransformer
pipeLine1 = Pipeline(steps=[
('imputer', SimpleImputer(strategy='median')),
('scaler', StandardScaler())
])
pipeLine2 = Pipeline(steps=[
("imputer", SimpleImputer(strategy='constant', fill_value='missing')),
("encoder", OneHotEncoder(sparse=False))])
transformations = ColumnTransformer([
("age_fare_1", pipeLine1 , ["age", "fare"])
,("age_fare_2", many_to_one_transformer, ["age", "fare"])
, ("age_fare_3", many_to_many_transformer, ["age", "fare"])
, ("embarked", pipeLine2, ["embarked"])
, ("sex_pclass", OneHotEncoder(sparse=False), ["sex", "pclass"])
])`
`clf = Pipeline(steps=[('preprocessor', transformations),
('classifier', LogisticRegression(solver='lbfgs'))])
model = clf.fit(x_train, y_train)
lime = LimeTabular(predict_fn=model.predict_proba, data=x_train)
lime_local = lime.explain_local(x_test[:5], y_test[:5])
show(lime_local)`
Please suggest.
Thanks
Rita