Commits

Jernej Kos  committed 0f034c8

Ensure that the passed in testing instance is a NumPy array as some models have issues with Pandas datatypes. Also clear the figure before generating a new one, otherwise all figures are overlayed.

  • Participants
  • Parent commits 91c1441

Comments (0)

Files changed (1)

File explainer.py

   cls_typ = instance.dtypes[-1].type
   features = list(data.columns[:-1])
   instance = instance[features]
-  prediction = cls_typ(model.predict(instance)[0])
+  prediction = cls_typ(model.predict(np.asarray(instance))[0])
   p_index = sorted(data[data.columns[-1]].unique()).index(prediction)
   data = data[features]
 
   :param filename: File where the output visualization should be
     saved to
   """
+  plt.clf()
   plt.figure(1, figsize = (6, 4))
   left_bar = plt.axes((0.1, 0.1, 0.85, 0.7))
   result['explanation'] = result['explanation'][::-1]