david-cortes / isotree

(Python, R, C/C++) Isolation Forest and variations such as SCiForest and EIF, with some additions (outlier detection + similarity + NA imputation)
https://isotree.readthedocs.io
BSD 2-Clause "Simplified" License
192 stars 38 forks source link

InvalidModelError: Model type not yet supported by TreeExplainer: <class 'isotree.IsolationForest'> #65

Closed maxwell3530 closed 2 months ago

maxwell3530 commented 2 months ago

from isotree import IsolationForest data= [ np.random.rand(500, 10, 20, 30) ] data = data.reshape(data.shape[0], -1) scaler = StandardScaler() data_scaled = scaler.fit_transform(data) iso_forest = IsolationForest(ndim=100, sample_size='auto', max_depth='auto', ntrees=100, missing_action="fail", coefs="uniform", standardize_data=False) outliers = iso_forest.fit_predict(data_scaled) explainer = shap.TreeExplainer(iso_forest) When I try to use TreeExplainer on isotree model , I got error for not supported by shap , but due to my data are time consuming on KernelExplainer , is there any way to get feature controbution by TreeExplainer? thanks

david-cortes commented 2 months ago

shap is a library that implements algorithms to work on models produced from other libraries, not the other way around. You might want to raise the issue with them instead.