marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.4k stars 1.79k forks source link

Add predict_fn_accept_dense_only to explain_instance when input is sparse but model takes dense #705

Open BinDong314 opened 1 year ago

BinDong314 commented 1 year ago

Add predict_fn_accept_dense_only to explain_instance.

When data_row (of explain_instance) is scipy.sparse.matrix but the model was NOT trained with scipy.sparse.matrix, the predict_fn_accept_dense_only convert inverse to dense before call predict_fn (and then back to sparse after call predict_fn)

Bin dbin@lbl.gov

BinDong314 commented 1 year ago

@marcotcr since this only involves a few lines of code change. Would you mind help to review and merge it? Thanks