Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.84 KB

3.example.md

File metadata and controls

62 lines (43 loc) · 1.84 KB

Run a scikit-learn example

The scikit-learn documentation relies heavily on code examples to demonstrate how to use the package with actual data, typically on standard public datasets.

All scikit-learn examples are gathered in the examples/ folder and its subfolders.

They are used to automatically generate the pages of the example gallery on the project website:

https://scikit-learn.org/stable/auto_examples/index.html

The goal of this exercise is to get familiar navigating in those examples and executing them either from the command-line or from with-in VS Code, leveraging the built-in matplotlib integration.

In particular, we will consider the following example file:

which renders as:

Note: how to generate the HTML documentation will be presented later.

From the command line

$ cd scikit-learn
$ ls examples
$ ls examples/inspection
$ python examples/inspection/plot_permutation_importance.py

The text output should be displayed directly in the terminal, while the graphical output will pop-up in a new window managed by matplotlib. If you have not already installed matplotlib and pandas, you can do it with conda:

$ conda install matplotlib pandas

Hint: at any moment use the pwd command to find where you are. pwd stands for "Path to Working Directory". For instance here is a typical output one would get on a Linux machine:

$ pwd
/home/YOUR-NAME/code/scikit-learn

From VS Code

  • ctrl-p "plot permutation importance" then

  • Ctrl-Shift-P "Run Current File in Python Interactive Window"