This guide shows you how to interact with Squirro using a software package such as Jupyter Notebook. Specifically, it guides you through the process of installing the necessary software components and provides a sample Notebook to get you started.
It is assumed that you have already installed Python 3.6 or a more recent version. If you do not, please refer to an external guide on how to install Python on your computer.
Table of Contents
Table of Contents | ||||||||
---|---|---|---|---|---|---|---|---|
|
Prepare a Virtual Environment
Now that you have successfully installed Python, open up a console, and create a virtual environment:
Code Block | ||
---|---|---|
| ||
python -m venv ~/squirro-venv |
This virtual environment will be used to install any Python packages that you may need during your experiments with Squirro.
Please remember that you need to have this virtual environment activated in order to install new packages in it or use existing ones. You can always activate it by issuing the following command:
Code Block |
---|
source ~/squirro-venv/bin/activate |
For more information regarding virtual environments in Python, you can check the official guide, but the information in this page should be sufficient.
The next step is to install two packages in your virtual environment: Jupyter Notebook and SquirroClient.
Code Block | ||
---|---|---|
| ||
pip install SquirroClient notebook |
The SquirroClient
is the official Squirro SDK for Python. You can use it in order to programmatically interact with your Squirro instance. Its documentation can be found in the Squirro SDK for Python.
The Jupyter Notebook is an application that is widely used when conducting an EDA. In case that you prefer an alternative software package (such as JypyterLab) feel free to use it as well. The only restriction for it is that you need to be able to run Python code.
Launch the Jupyter Notebook server
You are ready to launch the Jupyter Notebook server:
Code Block |
---|
jupyter notebook |
Now you can either create a new notebook or use the one provided here to get you started.
Obtain a Personal Access Token
The last step that you need to do is to obtain a personal access token for interacting with Squirro and use it for authenticating the SquirroClient
. In order to get one, please head over to the address of your Squirro instance. Then, at the top right corner, click on your avatar, and select the option “My Account“.
...
On the left menu, choose the option “API Access“, and then click the “Generate” button of the “User Token” field.
...
Copy this token and set it as a value to the token
variable of the provided Jupyter notebook.
Get to work with a Ground Truth’s data
The provided Jupyter notebook shows you how to connect to a Squirro instance, and includes a basic demo using a SquirroClient
and some toy Ground Truth data, to get you started with an exploratory data analysis.
Firstly, you need to create a Ground Truth by using the AI Studio. Please refer to the relevant sections ([1, 2]) from the official documentation of AI Studio for what is a Ground Truth and how you can create one.
Then, by using the method get_groundtruth_labels
of the SquirroClient
and providing the id of the ground truth (groundtruth_id) and the id of the project that this ground truth belongs to (project_id), you can fetch all its labeled examples.
...
The complete demo can be found in the provided Jupyter notebookcan now be found at Interact With Squirro using Jupyter Notebooks on the Squirro Docs site.