

.. _sphx_glr_auto_examples_inspection:

.. _inspection_examples:

Inspection
----------

Examples related to the :mod:`sklearn.inspection` module.



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In linear models, the target value is modeled as a linear combination of the features (see the linear_model User Guide section for a description of a set of linear models available in scikit-learn). Coefficients in multiple linear models represent the relationship between the given feature, X_i and the target, y, assuming that all the other features remain constant (conditional dependence). This is different from plotting X_i versus y and fitting a linear relationship: in that case all possible values of the other features are taken into account in the estimation (marginal dependence).">

.. only:: html

  .. image:: /auto_examples/inspection/images/thumb/sphx_glr_plot_linear_model_coefficient_interpretation_thumb.png
    :alt:

  :doc:`/auto_examples/inspection/plot_linear_model_coefficient_interpretation`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Common pitfalls in the interpretation of coefficients of linear models</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Machine Learning models are great for measuring statistical associations. Unfortunately, unless we&#x27;re willing to make strong assumptions about the data, those models are unable to infer causal effects.">

.. only:: html

  .. image:: /auto_examples/inspection/images/thumb/sphx_glr_plot_causal_interpretation_thumb.png
    :alt:

  :doc:`/auto_examples/inspection/plot_causal_interpretation`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Failure of Machine Learning to infer causal effects</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Partial dependence plots show the dependence between the target function [2]_ and a set of features of interest, marginalizing over the values of all other features (the complement features). Due to the limits of human perception, the size of the set of features of interest must be small (usually, one or two) thus they are usually chosen among the most important features.">

.. only:: html

  .. image:: /auto_examples/inspection/images/thumb/sphx_glr_plot_partial_dependence_thumb.png
    :alt:

  :doc:`/auto_examples/inspection/plot_partial_dependence`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Partial Dependence and Individual Conditional Expectation Plots</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we will compare the impurity-based feature importance of RandomForestClassifier with the permutation importance on the titanic dataset using permutation_importance. We will show that the impurity-based feature importance can inflate the importance of numerical features.">

.. only:: html

  .. image:: /auto_examples/inspection/images/thumb/sphx_glr_plot_permutation_importance_thumb.png
    :alt:

  :doc:`/auto_examples/inspection/plot_permutation_importance`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Permutation Importance vs Random Forest Feature Importance (MDI)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we compute the permutation_importance of the features to a trained RandomForestClassifier using the breast_cancer_dataset. The model can easily get about 97% accuracy on a test dataset. Because this dataset contains multicollinear features, the permutation importance shows that none of the features are important, in contradiction with the high test accuracy.">

.. only:: html

  .. image:: /auto_examples/inspection/images/thumb/sphx_glr_plot_permutation_importance_multicollinear_thumb.png
    :alt:

  :doc:`/auto_examples/inspection/plot_permutation_importance_multicollinear`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Permutation Importance with Multicollinear or Correlated Features</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /auto_examples/inspection/plot_linear_model_coefficient_interpretation
   /auto_examples/inspection/plot_causal_interpretation
   /auto_examples/inspection/plot_partial_dependence
   /auto_examples/inspection/plot_permutation_importance
   /auto_examples/inspection/plot_permutation_importance_multicollinear

