Cristian Arteaga
Cristian Arteaga
  • 2
  • 33 298
Interpretable Machine Learning for Image Classification with LIME - 5 Min. Tutorial with Python Code
This is a step by step tutorial with Python code that explains how LIME works for image classification tasks. The notebook shown in this video can be downloaded from the blog section of my website: arteagac.github.io/blog.html
The previous video about the basics of LIME can be found here:
th-cam.com/video/vz_fkVkoGFM/w-d-xo.html
มุมมอง: 6 601

วีดีโอ

Interpretable Machine Learning with LIME - How LIME works? 10 Min. Tutorial with Python Code
มุมมอง 27K5 ปีที่แล้ว
This is a step by step tutorial with python code that explains the details behind Interpretable Machine Learning with LIME (Local Interpretable Model-Agnostic Explanations). The python code and slides can be found in the blog section of my website: arteagac.github.io/blog

ความคิดเห็น

  • @sajidhussain3618
    @sajidhussain3618 11 หลายเดือนก่อน

    When working with RGB images, LIME works seamlessly. However, when dealing with CT or X-ray images, certain challenges may arise.

  • @AU-oy6qg
    @AU-oy6qg ปีที่แล้ว

    hey, the videos was great. just want to know is it possible to apply this method on image segmentation models like UNet.?please reply.

  • @RiuHayabusa15
    @RiuHayabusa15 ปีที่แล้ว

    Hello thanks for the video, the image preprocessing is the same if i am using a VGG model? Thanks a lot

    • @cristianarteaga
      @cristianarteaga ปีที่แล้ว

      That is correct! LIME is model agnostic, which means you can use any image classification model and it would work the same.

    • @RiuHayabusa15
      @RiuHayabusa15 ปีที่แล้ว

      @@cristianarteaga and this sentence "Xi = (Xi - 0.5)*2" in the image, is it independent of the model? i really appreciate your answer.

    • @cristianarteaga
      @cristianarteaga ปีที่แล้ว

      @@RiuHayabusa15 Good point, that part is actually specific for the Inception model, as this model applies that specific transformation for pre-processing. For other models you do not need that transformation.

    • @RiuHayabusa15
      @RiuHayabusa15 ปีที่แล้ว

      @@cristianarteaga Okey i get it, thanks a lot for your help

  • @francescfolch6513
    @francescfolch6513 ปีที่แล้ว

    Muy buen video. La explicacion de los coeficientes es lo que podria ampliarse, dibujando el vector (-1.37, -0.6) centrado en el punto en cuestión, que debe ser perpendicular a la tangente a la frontera en dicho punto

  • @upa240
    @upa240 2 ปีที่แล้ว

    Can you please explain why you choose y_linmodel = y_linmodel < 0.5 instead of the other way? I thought predictions greater than 0.5 should be assigned to class 1.

  • @saqibcs
    @saqibcs 2 ปีที่แล้ว

    Wow... Splendid .. love from 🇨🇦🇮🇳

  • @GChief117
    @GChief117 3 ปีที่แล้ว

    Dude, you just got a subscriber😎

  • @akashkewar
    @akashkewar 3 ปีที่แล้ว

    Amazing work, especially the coding part. Keep it up Cristian.

  • @schnitzelschatz
    @schnitzelschatz 3 ปีที่แล้ว

    This is gold

  • @neverlandisfar9194
    @neverlandisfar9194 3 ปีที่แล้ว

    Thank You! This is really helpful!

  • @ovegedion1790
    @ovegedion1790 3 ปีที่แล้ว

    another great video!

  • @ovegedion1790
    @ovegedion1790 3 ปีที่แล้ว

    great video! thanks!

  • @martinlearning1121
    @martinlearning1121 3 ปีที่แล้ว

    quite well explained! congrats

  • @AA-tm3ew
    @AA-tm3ew 3 ปีที่แล้ว

    Best explanation of lime...thank you

  • @RegsaGC
    @RegsaGC 3 ปีที่แล้ว

    This is such a good video. Actually illustrates the theory behind it. No use of libraries to do all the important work, yet it is still so short and easy to understand.

  • @장영달-v2y
    @장영달-v2y 3 ปีที่แล้ว

    wonderful video!

  • @JuneRacoon
    @JuneRacoon 3 ปีที่แล้ว

    The talking is just super fast, i agree that it's one of the best explanations of the topic out here but slowing down while speaking would really help. I had to listen multiple times to all sentences to finally get it.

    • @cristianarteaga
      @cristianarteaga 3 ปีที่แล้ว

      Thank you for the feedback. I will have it in mind for future videos. :)

    • @datakristen8500
      @datakristen8500 2 ปีที่แล้ว

      You can also adjust the speed of the playback.

    • @JuneRacoon
      @JuneRacoon 2 ปีที่แล้ว

      @@datakristen8500 that's true and how I did it but then some words are stretched out and the speech doesn't feel natural and it can be hard to listen to it.

  • @ghofraneghanmi4847
    @ghofraneghanmi4847 3 ปีที่แล้ว

    can you share the notebook?

    • @cristianarteaga
      @cristianarteaga 3 ปีที่แล้ว

      Sure! Here it is: nbviewer.jupyter.org/url/arteagac.github.io/blog/lime_image.ipynb

    • @ghofraneghanmi4847
      @ghofraneghanmi4847 3 ปีที่แล้ว

      @@cristianarteaga thank you and happy new year

    • @atejap
      @atejap 3 ปีที่แล้ว

      @@cristianarteaga not available anymore

    • @cristianarteaga
      @cristianarteaga 3 ปีที่แล้ว

      @@atejap I think the nbviewer website is temporarily down but you can see the original notebook in the following link: github.com/arteagac/arteagac.github.io/blob/master/blog/lime_image.ipynb

    • @atejap
      @atejap 3 ปีที่แล้ว

      ​@@cristianarteaga Tks so much.

  • @arkmishra7070
    @arkmishra7070 3 ปีที่แล้ว

    Can you please share the git link of the code

    • @cristianarteaga
      @cristianarteaga 3 ปีที่แล้ว

      Sure! github.com/arteagac/arteagac.github.io/blob/master/blog/lime.ipynb

  • @reeshabhkumarranjan1474
    @reeshabhkumarranjan1474 3 ปีที่แล้ว

    Thank you for explaining it so amazingly! Subscribed!

  • @hamzalebbar9105
    @hamzalebbar9105 3 ปีที่แล้ว

    Thank you for this clear explanation. Perfecto

  • @fawadmahdi
    @fawadmahdi 4 ปีที่แล้ว

    very good video and explanation

  • @melalastro
    @melalastro 4 ปีที่แล้ว

    Pruebo uno por uno? Las nuevas predicciones? O con ver una vez ya está?

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Hola @melalastro. No estoy seguro si entiendo bien tu pregunta pero si te refieres al nuevo dataset de perturbaciones que se genera, entonces si necesitas predecir la clase para cada una de las perturbaciones. Recuerda que la idea general detras de LIME es ver como se comportan las predicciones de tu modelo de machine learning en el vecindario de la instancia que quieres explicar. Por tanto, el vecindario que creas con perturbaciones requiere evaluar la predicion de cada perturbacion. Si tienes dudas adicionales puedes comunicarte por este medio.

    • @melalastro
      @melalastro 4 ปีที่แล้ว

      @@cristianarteaga gracias por contestar, me refiero a la localidad, si tengo 200 registros para entrenar, miro algunos para darle interpretabikidad al modelo, o solo lo uso para cada nueva predicción?

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Entiendo tu pregunta. Dado que LIME es un methodo para explicaciones locales (un registro al tiempo), para poder darle una interpretacion global al modelo (usando todos tus registros) tienes que recurrir a estrategias adicionales. Por ejemplo : 1. Una estrategia es usar Submodular-Pick LIME (SP-LIME) que es mencionada en el paper original de LIME (section 4). SP-LIME busca seleccionar una muestra representativa de tus registros para asi observar un comportamiento general del modelo. 2.Otra estrategia es agregar las explicaciones individuales para producir una explicacion global como se sugiere en este paper: arxiv.org/pdf/1907.03039.pdf

    • @melalastro
      @melalastro 4 ปีที่แล้ว

      @@cristianarteaga muchas gracias!!!

    • @melalastro
      @melalastro 4 ปีที่แล้ว

      @@cristianarteaga muy bueno todo! mil gracias

  • @raghvendrasingh116
    @raghvendrasingh116 4 ปีที่แล้ว

    This is amazing! this video solved a lot of doubts i had :)

  • @jorjiang1
    @jorjiang1 4 ปีที่แล้ว

    i think one problem of skimage.segmentation.quickshift could be that, because it is dividing images into patches with similar colors, and often the critical boundary is also the boundary of the superpixel, and often those boundaries are exactly the most important information for cnn to make a decision. turn a super pixel on and off did not remove that boundary, thus not turn those critical features on or off, it might be better just use a random segmentation

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      You have a good point. It would be interesting to test the effect of different segmentation strategies on the quality of the explanations.

  • @jorjiang1
    @jorjiang1 4 ปีที่แล้ว

    hi, really great explanation with the code, i have two question: 1. i suspect lime probably would not work well with predictions with high confidence (far away from decision boundary), is the correct??? i have tried in your notebook, instead of the blue dot near the decision boundary i have change it to the middle of the positive blob, and the linear model predicted everything on the map to be positive and the coefficient are both negligible, as if it's telling me: "nothing needs to be explained, everything in the world is a positive class". 2. would it make more sense in that case (nothing could be explained locally) we slowly increase the kernel size and get a relative more globe explanation, as long as the data in the kernel range is relative leaner separable, which we can informed by the performance of linear model

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Hello. Thanks for your comment. Sorry for the late reply. 1) Your interpretation for areas far from the decision boundary makes sense. In fact, due to issues like the one you mention, LIME may not perform well for certain continuous features. For that reason, the python library LIME uses discretization by default for continuous variables (see github.com/marcotcr/lime/issues/68). 2) I am not sure whether it is a good idea to increase the kernel size to a point where a more "global" explanation is obtained. I think sticking to a "local" scope is better because the linear surrogate model you are estimating may not behave very well when you move very far from the surrounding area of the point you want to explain.

  • @OmerBoehm
    @OmerBoehm 4 ปีที่แล้ว

    Many thanks for the explanations and the code walk through , it helped a lot !

  • @DouglasLuan
    @DouglasLuan 4 ปีที่แล้ว

    Excellent, Cristian. Muchas gracias and I wish you great success!

  • @GarveRagnara
    @GarveRagnara 4 ปีที่แล้ว

    Best explanation of Lime on the internet!

  • @장재은-b6i
    @장재은-b6i 4 ปีที่แล้ว

    Thanks for useful lecture! However, what should I do if the dataset has categorical feature?

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Hello! Thanks for your comment. With categorical features it is even easier. To create perturbations you simply create a random vector of zeroes and ones instead of sampling from the mean and std. dev. of your features. Let's say you have a binary categorical feature called "gender" (1: female, 0: male). The LIME random perturbation for the feature "gender" will use 0 to represent that you perturb your feature (flip it to the opposite value) and 1 represents you don't perturb it. You can clearly see this concept on another tutorial where I apply to LIME explanations of image classifications (th-cam.com/video/ENa-w65P1xM/w-d-xo.html). You can assume that each superpixel in the image is a binary categorical feature that is turned on and off with random perturbations and then it is evaluated how the presence of absence of these features affect the predictions. This exact concept of turning on and off categorical features applies to your question.

    • @장재은-b6i
      @장재은-b6i 4 ปีที่แล้ว

      Cristian Arteaga thank you very much. your explanation is so useful. I have one more question. If i discretize continuous feature, the process is same with categrical feature?

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      That is correct! When you discretize a continuous feature you generate LIME perturbations using the same process used for categorical features. A discretized feature is just a feature converted to categorical using percentiles.

  • @naveen3046
    @naveen3046 4 ปีที่แล้ว

    Very very informative excellent explanation

  • @heraneyaz7053
    @heraneyaz7053 4 ปีที่แล้ว

    I am getting this error when i load the image NameError Traceback (most recent call last) <ipython-input-1-f74400c02a17> in <module> ----> 1 Xi = skimage.io.imread("arteagac.github.io/blog/lime_image/img/cat-and-dog.jpg") 2 Xi = skimage.transform.resize(Xi, (299,299)) 3 Xi = (Xi - 0.5)*2 #Inception pre-processing 4 skimage.io.imshow(Xi/2+0.5) # Show image before inception preprocessing NameError: name 'skimage' is not defined

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Hi Hera. You are right. Thank you for pointing this out. The error was that the import for skimage.io should be "import skimage.io" instead of "import skimage". I have updated the notebook and made sure it works. You can check the updated version in the blog section of my website arteagac.github.io/blog.html . You can also open it in Google Colab for quick testing.

  • @VALedu11
    @VALedu11 4 ปีที่แล้ว

    This is the exact explanation that I needed. Thank you very much for this. Your video has cleared much of my understanding of LIME

  • @dlazar711
    @dlazar711 4 ปีที่แล้ว

    Hey, amazing video, thanks. This year I started with Data Analysis and Machine Learning course. Will this work even when I change your model with our neural network hot dog / not hot dog classifier? :D The concept of LIME interpreting the model's results should be the same right? :)

    • @cristianarteaga
      @cristianarteaga 4 ปีที่แล้ว

      Hey David. Yes, it will work once you replace the model with your hotdog classifier. If you want to do a quick test, you can use the Jupyter notebook I wrote arteagac.github.io/blog.html. However, for more stable results, I recommend you to check the LIME Python library: github.com/marcotcr/lime.

  • @VicMolTube
    @VicMolTube 5 ปีที่แล้ว

    Great tutorial! Thanks for sharing.

  • @miguelalba2106
    @miguelalba2106 5 ปีที่แล้ว

    Muy buen tutorial!!