marcotcr / lime

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

Why is it difficult to convert the output from the for loop into a DataFrame? The output for the following code produces a DataFrame with only two columns. #531

Closed tlyddiard closed 4 years ago

tlyddiard commented 4 years ago

Why is it difficult to convert the output from the for loop into a DataFrame? The output for the following code produces a DataFrame with only two columns. l=[ ] for n in range(0,X_test.shape[0]+1): exp = explainer.explain_instance(X_test.values[n], clf.predict_proba, num_features=10) a=exp.as_list() l.append(a) df = pd.DataFrame(l) df

Whereas, I have no problem with generating a DataFrame when it is not in a for loop. It easily generates a table. exp = explainer.explain_instance(np.array(X_test)[i], clf.predict_proba, num_features=7) df= pd.DataFrame(exp.as_list(label=1), columns=['Feature', 'Value']) df

How do you recommend converting the output from the for loop into a dataframe?

Originally posted by @tlyddiard in https://github.com/marcotcr/lime/issues/213#issuecomment-714808175

tlyddiard commented 4 years ago

found solution

rachspreng commented 3 years ago

Read through #213 - What was your solution? Thanks.