Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In [34]: #Function to get weights from LIME explanation object def return_weights(ep) : exp_list = exp. as_map() [1] exp_list = sorted(exp_list, key=lambda x: x[0]) exp_weight

image text in transcribed
In [34]: #Function to get weights from LIME explanation object def return_weights(ep) : exp_list = exp. as_map() [1] exp_list = sorted(exp_list, key=lambda x: x[0]) exp_weight = [x[1] for x in exp_list] return exp_weight print(X_test. columns) print (len(X_test) ) #Iterate over the rows in feature matrix #and collect the LIME weights #You can run for more elements----but we pick a max of 25 for x in range (min(len(X_test), 25) ) : #Get explanation exp = lime_explainer . explain_instance(X_test. iloc[x], mlp . predict_proba, num_features = len(X_test. columns) ) #Get weights(exp) weights . append (exp_weight) Index([ 'mean radius', 'mean texture', "mean perimeter', "mean area", "mean smoothness', 'mean compactness', 'mean concavity", 'mean concave points", "mean symmetry', 'mean fractal dimension", 'radius error', 'texture error', 'perimeter error", 'area error", 'smoothness error', 'compactness error', 'concavity error', 'concave points error", 'symmetry error', 'fractal dimension error', 'worst radius', 'worst texture', "worst perimeter", 'worst area", 'worst smoothness', "worst compactness', 'worst concavity' 'worst concave points', 'worst symmetry', 'worst fractal dimension' ], dtype='object' ) 114 Name Error Traceback (most recent call last) Cell In [34], line 19 16 exp = lime_explainer . explain_instance(X_test. iloc[x], 17 mlp. predict_proba, num_features = len(X_test . columns) ) 18 #Get weights (exp) ---> 19 weights . append (exp_weight) NameError: name "weights' is not defined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finite Mathematics and Its Applications

Authors: Larry J. Goldstein, David I. Schneider, Martha J. Siegel, Steven Hair

12th edition

978-0134768588, 9780134437767, 134768582, 134437764, 978-0134768632

More Books

Students also viewed these Mathematics questions