0% found this document useful (0 votes)
7 views1 page

Convert and Merge These Two Algorithm Into Python Code and Create A New Algorithm

This document describes a new algorithm that merges the LIME and KernelSHAP algorithms for local explanations in Python. The algorithm takes a classifier, an input sample, and parameters for superpixels and features, and outputs explainable coefficients from a linear model. It involves sampling by permuting superpixels, transforming features, and fitting a linear model based on similarity scores and SHAP values.

Uploaded by

ZuniButt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Convert and Merge These Two Algorithm Into Python Code and Create A New Algorithm

This document describes a new algorithm that merges the LIME and KernelSHAP algorithms for local explanations in Python. The algorithm takes a classifier, an input sample, and parameters for superpixels and features, and outputs explainable coefficients from a linear model. It involves sampling by permuting superpixels, transforming features, and fitting a linear model based on similarity scores and SHAP values.

Uploaded by

ZuniButt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Convert and merge these two algorithm into python code and create a new algorithm.

Algorithm 1 LIME algorithm for local explanations

Input: classifier f, input sample x, number of superpixels n, number of features to pick m

Output: explainable coefficients from the linear model

1: ŷ ← f.predict(x)

2: for i in n do

3: p_i ← Permute(x) //Randomly pick superpixels

4: obs_i ← f.predict(p)

5: dist_i ← |ŷ - obs_i|

6: end for

7: simscore ← SimilarityScore(dist)

8: x_pick ← Pick(psimscorem)

9: L ← LinearModel.fit(pmsimscore)

10: return L.weights

Algorithm 2 KernelSHAP Algorithm for Local Explanations


Input: classifier f, input sample x
Output: explainable coefficients from the linear model
1: zk ← SampleByRemovingFeature(x)
2: zk ← h(zk) // hx is a feature transformation to reshape to x
3: yk ← f(zk)
4: Wx ← SHAP(f, zk, yk)
5: LinearModel(Wx).fit()
6: Return LinearModel.coefficients()

You might also like