0
$\begingroup$

it is my first time using LIME and I have never used any interpretation technique before.

most likely I am doing something wrong but I cannot figure out what is it.

I tried googling and going through SOF questions to find the way to resolve this but did not find anything that could help me.

my dataset df_reps looks like this

Toyota Horse Toyota Gear... Mazda Night King
Green Mazda King Toyota ... Blue Mazda Toyota
...
...
Gear Tyre Toyota Geaer ... Horse Blue Park
Laptop Invoice Toyota ...  Horse Mango Kitkat

and labels to predict, is whether the customer approved of not so the labels are only 0 and 1

Here is my code

def BOW(df):
  CountVec = CountVectorizer() # to use only  bigrams ngram_range=(2,2)
  Count_data = CountVec.fit_transform(df)
  Count_data = Count_data.astype(np.uint8)
  cv_dataframe=pd.DataFrame(Count_data.toarray(), columns=CountVec.get_feature_names_out(), index=df.index)  # <- HERE
  return cv_dataframe.astype(np.uint8)

df = BOW(df_reps)
y = df_Labels    # this is either 0 or 1
X = df
X_train, X_test, y_train, y_test = train_test_split(X, y)

clf = RandomForestClassifier(max_depth=100)
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)


# Here is the part for LIME

explainer = LimeTextExplainer()
exp = explainer.explain_instance(y_pred, clf.predict, num_features=10000)

How can I fix the LIME part so it actually gives me interoperability for y_pred results?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.