Giter Club home page Giter Club logo

machine_learning_interpretability_in_steel_industry's Introduction

Interpretability Methods for Machine Learning algorithms trained on Steel Industry data

In this repo it is present the work done in order to create an interpretable and explainable model which classify if an image of has a defect or not (binary model) or also the type of defect in the image (if any) (multi class model). For each model evaluation, inspection and interpretation techniques have been used.
The structure of the repo is the following:

  • data: folder where the images for training are present. there are also present two folder called binaryData and multiData which contain the metadata (.csv) used to get the images for training/validation/test
  • img: folder where useful images are saved
  • model: here all (cuda) parameters of the the binary and multi models are saved. In order to retrieve the model you need to initialize the same (pytorch) architecture, move in a cuda device and load the state dict.
  • notebooks_eda: folder where some Explorative Data Analysis notebooks are. It is possible to visualize some examples and the distribution of our data.
  • notebooks_interpretation: main focus of this work. Here are present some notebooks which try to fulfill this goal.
  • notebooks_models: folder where it is possible to evaluate the model, either singularly or by comparison.
  • results: .txt files of semantic segmentation evaluation metrics
  • scripts: python scripts used to train models
  • src: where python functions or classes are defined

Major requirements

  • Python (3.6)
  • torch
  • torchvision
  • numpy
  • matplotlib
  • sklearn
  • scipy
  • pandas
  • argparse
  • captum
  • shap
  • cv2
  • PIL
  • json

1. Data overview

2. Binary Model

2.a) Model

The final model is a reduced version of the pre-trained Squeeze Net v1.1, with the last three FIRE modules deleted, fine tuned on our dataset and augmented using gaussian noise. It reaches 0.941 accuracy, 0.944 f1-score and an AUC of 0.983 on the test set. This metrics where around 0.18 points greater than a baseline model (Logistic Regression).

Architecture of the final model FIG. Architecture of SqueezeNet adapted to out problem: the last three fire modules have been deleted

2.b) Inspection and interpretability techniques

Different inspection and interpretability techniques have been performed in order to explore the model decision policies. Starting from neuron feature visualization and local interpretability methods comparison and ending with local explanations of the test images. Example of GradCAM local explanantions FIG. Different example of GradCAM application w.r.t the two classes. Red area excites the target neuron while blue ones inhibt it.

2.c) White-Stain Effect

A potentially spurious correlation has been found in the data. In fact, images with no defects had white stains in the surface and the model learned to distinguish these images by primarily looking for the presence of this stains.
The effect was so strong that attaching a white stains in an image with defects would make the model get confused and misclassify the example as with no defetcs White-Stain Effect FIG. Example of White-Stain Effect: in the left the original image is classified as with defects (red areas), while, when we attach a white stain over it (right), the model change its prediction and classify the image as with no defects. GradCAM enable us to check that the model is now looking more at the white-stains.

3. Multi Class Model

3.a) Model

For this problem, the same architecture of the binary model has been used. It reached an accuracy of 0.921, a balance accuracy of 0.904 a (weighted) F1-score of 0.924 and an AUC of 0.987.

3.b) Inspection and interpretability techniques

The same interpretability techniques of the binary case have been used in order to explore the model policies. Similar results andd conclusions have been reached. Post-processed output of GuidedGradCAM used as a semantic segmentation model FIG. Example of post-processed output of GuidedGradCAM used as a semantic segmentation model: we can see that interpretability methods can roughly identify the areas of defects.

4. Conclusion

The present work has showed how detect and classify defects in steel sheets is possible with discrete results and with efficient models, with few parameters. But, above all, we showed how explaining the model process and policies is not only possible but also important, since it enabled us to discovery unwanted and dangerous situations in the data (spurious correlation) and to provide a tool for human-machine interaction and communication, making the model an explainable and human-friendly recommendation system.

machine_learning_interpretability_in_steel_industry's People

Contributors

f-grimaldi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.