I use a dataset for white Whine and one column "Quality" of it for classification purpose. I want to map the results 4 and 5 as "bad" and 6 to 8 as "good" classification. Right now it only maps 4 to "bad" and 5 to "good" and the rest as "Other" (see picture below).
Did try to change the values for class-names and some other stuff but it didnt work out. I am not sure at which point i have to do the mapping.
from sklearn.model_selection import train_test_split
# Train/Test split for white and red Wine dataset
# axis=1 argument specifies to drop a column and not a row
whiteX = whiteWine.drop('quality', axis=1)
whiteY = whiteWine['quality']
whiteX_train, whiteX_test, whiteY_train, whiteY_test = train_test_split(
whiteX, whiteY, test_size=0.2, random_state=42
)
modelWhite = RandomForestClassifier(random_state=42)
modelWhite.fit(whiteX_train, whiteY_train)
score = modelWhite.score(whiteX_test, whiteY_test)
explainerWhite = lime_tabular.LimeTabularExplainer(
training_data=np.array(whiteX_train),
feature_names=whiteX_train.columns,
class_names=['bad', 'good'],
mode='classification'
)
expWhite = explainerWhite.explain_instance(
data_row=whiteX_test.iloc[3],
predict_fn=modelWhite.predict_proba
)
expWhite.show_in_notebook(show_table=True)