Hi,
I am using lime package to explain my output and would like to get the index as column for all the records in the predictive dataframe.
I have used zip to combine the index to the list.
x=list(X_test.index)
l1=
output=
for i in range(np.array(X_test.shape[0])):
exp_data = explainer.explain_instance(np.array(X_test)[i], random_forest.predict_proba,
num_features=10)
a=exp_data.as_list()
l1.append(a)
for elem1,elem2 in zip(x,l1):
o1=list((elem1,elem2))
output=output + o1
print(output)
[6334, [((x10,x11,x12…)],12743, [(y110…]]
This is giving me two lists.
Then when i converted it to dataframe, It is giving the index in separate row instead of same row.
df1 = pd.DataFrame([output]).T
df1.columns=[‘a1’]
a1
0 6334
1 [(x10,x11,x12…]
2 12743
3 [(y110…]
idelally i ould like to have recordid/index with the list of values in the same row for that record. for eg
a1
0 [(6334,x10,x11,x12)]
1 [912743,y110,…)]
Thanks for your help.