asreview-insights


Nameasreview-insights JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/asreview/asreview-insights
SummaryInsight tools for the ASReview project
upload_time2022-12-09 15:00:00
maintainer
docs_urlNone
authorASReview LAB developers
requires_python
license
keywords asreview plot insights
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ASReview Insights

[![PyPI version](https://badge.fury.io/py/asreview-insights.svg)](https://badge.fury.io/py/asreview-insights) [![Downloads](https://pepy.tech/badge/asreview-insights)](https://pepy.tech/project/asreview-insights) ![PyPI - License](https://img.shields.io/pypi/l/asreview-insights) ![Deploy and release](https://github.com/asreview/asreview-insights/workflows/Deploy%20and%20release/badge.svg) ![Build status](https://github.com/asreview/asreview-insights/workflows/test-suite/badge.svg) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6626069.svg)](https://doi.org/10.5281/zenodo.6626069)


This official extension to [ASReview
LAB](https://github.com/asreview/asreview) extends the software with tools for
[plotting](#plot-types) and extracting the [statistical results](#metrics) of
several [performance metrics](#performance-metrics). The extension is
especially useful in combination with the [simulation
functionality](https://asreview.readthedocs.io/en/latest/simulation_overview.html)
of ASReview LAB.


❣️ ASReview Insights is the successor to
[ASReview-visualization](https://pypi.org/project/asreview-visualization/).
ASReview insights is available for [ASReview
LAB](https://github.com/asreview/asreview/discussions/975) version 1 or later.
Use ASReview visualization for versions 0.x.

## Installation

ASReview Insights can be installed from PyPI:

``` bash
pip install asreview-insights
```

After installation, check if the `asreview-insights` package is listed as an
extension. Use the following command:

```bash
asreview --help
```

It should list the 'plot' subcommand and the 'metrics' subcommand.

## Performance metrics

The ASReview Insights extension is useful for measuring the performance of
active learning models on collections of binary labeled text. The extension
can be used after performing a simulation study that involves mimicking the
screening process with a specific model. As it is already known which records
are labeled relevant, the simulation can automatically reenact the screening
process as if a screener were using active learning. The performance of one or
multiple models can be measured by different metrics and the
ASReview Insights extension can plot or compute the values for such metrics
from ASReview project files.

The recall is the proportion of relevant records that have been found at a
certain point during the screening phase. It is sometimes also called the
proportion of Relevant Record Found (RRF) after screening an X% of the total
records. For example, the RRF@10 is the recall (i.e., the proportion of the
total number of relevant records) at screening 10% of the total number of
records available in the dataset.

A variation is the Extra Relevant records Found (ERF), which is the proportion
of relevant records found after correcting for the number of relevant records
found via random screening (assuming a uniform distribution of relevant
records).

The Work Saved over Sampling (WSS) is a measure of "the work saved over and
above the work saved by simple sampling for a given level of recall" ([Cohen
et al., 2006]((https://doi.org/10.1197/jamia.m1929)). It is defined as the
proportion of records a screener does **not** have to screen compared to
random reading after providing the prior knowledge used to train the first
iteration of the model. The WSS is typically measured at a recall of .95
(WSS@95), reflecting the proportion of records saved by using active learning
at the cost of failing to identify .05 of relevant publications.

The following plot illustrates the differences between the metrics Recall
(y-axis), WSS (blue line), and ERF (red line). The dataset contains 1.000
hypothetical records with labels. The stepped line on the diagonal is the
naive labeling approach (screening randomly sorted records).

![ASReview metrics explained](https://github.com/asreview/asreview-insights/blob/master/docs/stats_explainer.png)


Both recall and WSS are sensitive to the position of the cutoff value and the
distribution of the data. Moreover, the WSS makes assumptions about the
acceptable recall level whereas this level might depend on the research
question at hand. Therefore, [Ferdinands et al.
(2020)](https://doi.org/10.31219/osf.io/w6qbg) proposed two new metrics: (1)
the Time to Discover a relevant record as the fraction of records needed
to screen to detect this record (TD); and (2) the Average Time to Discover
(ATD) as an indicator of how many records need to be screened on average to
find all relevant records in the dataset.


## Basic usage

The ASReview Insights package extends ASReview LAB with two new subcommands
(see `asreview --help`): [`plot`](#plot) and [`metrics`](#metrics). The plots
and metrics are derived from an ASReview project file. The ASReview file
(extension `.asreview`) can be
[exported](https://asreview.readthedocs.io/en/latest/manage.html#export-project)
from ASReview LAB after a
[simulation](https://asreview.readthedocs.io/en/latest/simulation_overview.html),
or it is generated from running a [simulation via the command
line](https://asreview.readthedocs.io/en/latest/simulation_cli.html).

For example, an ASReview can be generated with:


```python
asreview simulate benchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview --init_seed 535
```

To use the most basic options of the ASReview Insights extension, run

```bash
asreview plot recall YOUR_ASREVIEW_FILE.asreview
```
where `recall` is the type of the plot, or

```bash
asreview metrics sim_van_de_schoot_2017.asreview
```

More options are described in the sections below. All options can be
obtained via `asreview plot --help` or `asreview metrics --help`.

## `Plot`

### Plot types

#### `recall`

The recall is an important metric to study the performance of active learning
algorithms in the context of information retrieval. ASReview Insights
offers a straightforward command line interface to plot a "recall curve". The
recall curve is the recall at any moment in the active learning process.

To plot the recall curve, you need a ASReview file (extension `.asreview`).To
plot the recall, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by
your ASReview file name.):

```bash
asreview plot recall YOUR_ASREVIEW_FILE.asreview
```

The following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in
the benchmark platform (command `asreview simulate
benchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).

![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_recall_sim_van_de_schoot_2017_stop_if_min.png)

On the vertical axis, you find the recall (i.e, the proportion of the relevant
records) after every labeling decision. The horizontal axis shows the
proportion of  total number of records in the dataset. The steeper the recall
curve, the higher the performance of active learning when comparted to random
screening. The recall curve can also be used to estimate stopping criteria, see
the discussions in [#557](https://github.com/asreview/asreview/discussions/557) and [#1115](https://github.com/asreview/asreview/discussions/1115).


```bash
asreview plot recall YOUR_ASREVIEW_FILE.asreview
```

#### `wss`

The Work Saved over Sampling (WSS) metric is an useful metric to study the
performance of active learning alorithms compared with a naive (random order)
approach at a given level of recall. ASReview Insights offers a
straightforward command line interface to plot the WSS at any level of recall.

To plot the WSS curve, you need a ASReview file (extension `.asreview`). To
plot the WSS, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by your
ASReview file name.):

```bash
asreview plot wss YOUR_ASREVIEW_FILE.asreview
```

The following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in
the benchmark platform (command `asreview simulate
benchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).

![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_wss_default_sim_van_de_schoot_2017_stop_if_min.png)

On the vertical axis, you find the WSS after every labeling decision. The
recall is displayed on the horizontal axis. As shown in the figure, the
WSS is linearly related to the recall.


#### `erf`

The Extra Relevant Records found is a derivative of the recall and presents
the proportion of relevant records found after correcting for the number of
relevant records found via random screening (assuming a uniform distribution
of relevant records).

To plot the WSS curve, you need a ASReview file (extension `.asreview`). To
plot the WSS, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by your
ASReview file name.):


```bash
asreview plot erf YOUR_ASREVIEW_FILE.asreview
```

The following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in
the benchmark platform (command `asreview simulate
benchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).

![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_erf_default_sim_van_de_schoot_2017_stop_if_min.png)

On the vertical axis, you find the ERF after every labeling decision. The
horizontal axis shows the proportion of  total number of records in the
dataset. The steep increase of the ERF in the beginning of the process is
related to the steep recall curve.

### Plotting CLI

Optional arguments for the command line are `--priors` to include prior
knowledge, `--x_absolute` and `--y_absolute` to use absolute axes.

See `asreview plot -h` for all command line arguments.


### Plotting API

To make use of the more advanced features, you can make use of the Python API.
The advantage is that you can tweak every single element of the plot in the
way you like. The following examples show how the Python API can be used. They
make use of matplotlib extensively. See the [Introduction to
Matplotlib](https://matplotlib.org/stable/tutorials/introductory/usage.html)
for examples on using the API.

The following example show how to plot the recall with the API and save the
result. The plot is saved using the matplotlib API.

```python
import matplotlib.pyplot as plt

from asreview import open_state
from asreviewcontrib.insights.plot import plot_recall

with open_state("example.asreview") as s:

    fig, ax = plt.subplots()

    plot_recall(ax, s)

    fig.savefig("example.png")
```

Other options are `plot_wss` and `plot_erf`.

#### Example: Customize plot

It's straightforward to customize the plots if you are familiar with
`matplotlib`. The following example shows how to update the title of the plot.

```python
import matplotlib.pyplot as plt

from asreview import open_state
from asreviewcontrib.insights.plot import plot_wss

with open_state("example.asreview") as s:

    fig, ax = plt.subplots()
    plot_wss(ax, s)

    plt.title("WSS with custom title")

    fig.savefig("example_custom_title.png")
```

![WSS with custom title](https://github.com/asreview/asreview-insights/blob/master/docs/example_custom_title.png)

#### Example: Prior knowledge

It's possible to include prior knowledge to your plot. By default, prior
knowledge is excluded from the plot.

```python
import matplotlib.pyplot as plt

from asreview import open_state
from asreviewcontrib.insights.plot import plot_wss

with open_state("example.asreview") as s:

    fig, ax = plt.subplots()
    plot_wss(ax, s, priors=True)

```

#### Example: Relative versus absolute axes

By default, all axes in ASReview Insights are relative. The API can be used to
change this behavior. The arguments are identical for each plot function.

```python
import matplotlib.pyplot as plt

from asreview import open_state
from asreviewcontrib.insights.plot import plot_wss

with open_state("example.asreview") as s:

    fig, ax = plt.subplots()
    plot_wss(ax, s, x_absolute=True, y_absolute=True)

    fig.savefig("example_absolute_axis.png")
```

![Recall with absolute axes](https://github.com/asreview/asreview-insights/blob/master/docs/example_absolute_axes.png)


#### Example: Multiple curves in one plot

It is possible to have multiple curves in one plot by using the API,
and add a legend.

```python
import matplotlib.pyplot as plt

from asreview import open_state
from asreviewcontrib.insights.plot import plot_recall


fig, ax = plt.subplots()

with open_state("tests/asreview_files/sim_van_de_schoot_2017_1.asreview") as s1:
    plot_recall(ax, s1)

with open_state("tests/asreview_files/"
                "sim_van_de_schoot_2017_logistic.asreview") as s2:
    plot_recall(ax, s2)

ax.lines[0].set_label("Naive Bayes")
ax.lines[2].set_label("Logistic")
ax.legend()

fig.savefig("docs/example_multiple_lines.png")
```
![Recall with multiple lines](https://github.com/asreview/asreview-insights/blob/master/docs/example_multiple_lines.png)

## `metrics`

The `metrics` subcommand in ASReview Insights can be used to compute metrics
at given values. The easiest way to get compute metrics for a ASReview project
file is with the following command don the command line:

```
asreview metrics sim_van_de_schoot_2017.asreview
```

which results in

```
    "asreviewVersion": "1.0",
    "apiVersion": "1.0",
    "data": {
        "items": [
            {
                "id": "recall",
                "title": "Recall",
                "value": [
                    [
                        0.1,
                        1.0
                    ],
                    [
                        0.25,
                        1.0
                    ],
                    [
                        0.5,
                        1.0
                    ],
                    [
                        0.75,
                        1.0
                    ],
                    [
                        0.9,
                        1.0
                    ]
                ]
            },
            {
                "id": "wss",
                "title": "Work Saved over Sampling",
                "value": [
                    [
                        0.95,
                        0.8913851624373686
                    ]
                ]
            },
            {
                "id": "erf",
                "title": "Extra Relevant record Found",
                "value": [
                    [
                        0.1,
                        0.9047619047619048
                    ]
                ]
            },
            {
                "id": "atd",
                "title": "Average time to discovery",
                "value": 101.71428571428571
            },
            {
                "id": "td",
                "title": "Time to discovery",
                "value": [
                    [
                        3898,
                        22
                    ],
                    [
                        284,
                        23
                    ],
                    [
                        592,
                        25
                    ],
                    ...
                    [
                        2382,
                        184
                    ],
                    [
                        5479,
                        224
                    ],
                    [
                        3316,
                        575
                    ]
                ]
            }
        ]
    }
}
```

Each available item has two values. The first value is the value at which the
metric is computed. In the plots above, this is the x-axis. The second value
is the results of the metric. Some metrics are computed for multiple values.

| Metric | Description pos. 1 | Description pos. 2 | Default |
|---|---|---|---|
| `recall` | Labels | Recall | 0.1, 0.25, 0.5, 0.75, 0.9 |
| `wss` | Recall | Work Saved over Sampling at recall | 0.95 |
| `erf` | Labels | ERF | 0.10 |
| `atd` | Average time to discovery (in label actions) | - | - |
| `td` | Row number (starting at 0) | Number of records labeled | - |


### Override default values

It is possible to override the default values of `asreview metrics`. See
`asreview metrics -h` for more information or see the example below.

```
asreview metrics sim_van_de_schoot_2017.asreview --wss 0.9 0.95
```

```
{
    "asreviewVersion": "1.0",
    "apiVersion": "1.0",
    "data": {
        "items": [
            {
                "id": "recall",
                "title": "Recall",
                "value": [
                    [
                        0.1,
                        1.0
                    ],
                    [
                        0.25,
                        1.0
                    ],
                    [
                        0.5,
                        1.0
                    ],
                    [
                        0.75,
                        1.0
                    ],
                    [
                        0.9,
                        1.0
                    ]
                ]
            },
            {
                "id": "wss",
                "title": "Work Saved over Sampling",
                "value": [
                    [
                        0.9,
                        0.8474220139001132
                    ],
                    [
                        0.95,
                        0.8913851624373686
                    ]
                ]
            },
            {
                "id": "erf",
                "title": "Extra Relevant record Found",
                "value": [
                    [
                        0.1,
                        0.9047619047619048
                    ]
                ]
            },
            {
                "id": "atd",
                "title": "Average time to discovery",
                "value": 101.71428571428571
            },
            {
                "id": "td",
                "title": "Time to discovery",
                "value": [
                    [
                        3898,
                        22
                    ],
                    [
                        284,
                        23
                    ],
                    [
                        592,
                        25
                    ],
                    ...
                    [
                        2382,
                        184
                    ],
                    [
                        5479,
                        224
                    ],
                    [
                        3316,
                        575
                    ]
                ]
            }
        ]
    }
}
```

### Save metrics to file

Metrics can be saved to a file in the JSON format. Use the flag `-o` or
`--output`.

```
asreview metrics sim_van_de_schoot_2017.asreview -o my_file.json
```

### Metrics CLI

Optional arguments for the command line are `--priors` to include prior
knowledge, `--x_absolute` and `--y_absolute` to use absolute axes.

See `asreview metrics -h` for all command line arguments.

### Metrics API

Metrics are easily accesible with the ASReview Insights API.

Compute the recall after reading half of the dataset.

```python

from asreview import open_state
from asreviewcontrib.insights.metrics import recall

with open_state("example.asreview") as s:

    print(recall(s, 0.5))
```

Other metrics are available like `wss` and `erf`.

#### Example: Prior knowledge

It's possible to include prior knowledge to your metric. By default, prior
knowledge is excluded from the metric.

```python

from asreview import open_state
from asreviewcontrib.insights.metrics import recall

with open_state("example.asreview") as s:

    print(recall(s, 0.5, priors=True))
```

## License

This extension is published under the [MIT license](/LICENSE).

## Contact

This extension is part of the ASReview project ([asreview.ai](https://asreview.ai)). It is maintained by the
maintainers of ASReview LAB. See [ASReview
LAB](https://github.com/asreview/asreview) for contact information and more
resources.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asreview/asreview-insights",
    "name": "asreview-insights",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "asreview plot insights",
    "author": "ASReview LAB developers",
    "author_email": "asreview@uu.nl",
    "download_url": "https://files.pythonhosted.org/packages/27/e4/f6f7847067f83f65e3a9e326559acf6b14dd16f6c943aced281d80201b3e/asreview-insights-1.1.2.tar.gz",
    "platform": null,
    "description": "# ASReview Insights\n\n[![PyPI version](https://badge.fury.io/py/asreview-insights.svg)](https://badge.fury.io/py/asreview-insights) [![Downloads](https://pepy.tech/badge/asreview-insights)](https://pepy.tech/project/asreview-insights) ![PyPI - License](https://img.shields.io/pypi/l/asreview-insights) ![Deploy and release](https://github.com/asreview/asreview-insights/workflows/Deploy%20and%20release/badge.svg) ![Build status](https://github.com/asreview/asreview-insights/workflows/test-suite/badge.svg) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6626069.svg)](https://doi.org/10.5281/zenodo.6626069)\n\n\nThis official extension to [ASReview\nLAB](https://github.com/asreview/asreview) extends the software with tools for\n[plotting](#plot-types) and extracting the [statistical results](#metrics) of\nseveral [performance metrics](#performance-metrics). The extension is\nespecially useful in combination with the [simulation\nfunctionality](https://asreview.readthedocs.io/en/latest/simulation_overview.html)\nof ASReview LAB.\n\n\n\u2763\ufe0f ASReview Insights is the successor to\n[ASReview-visualization](https://pypi.org/project/asreview-visualization/).\nASReview insights is available for [ASReview\nLAB](https://github.com/asreview/asreview/discussions/975) version 1 or later.\nUse ASReview visualization for versions 0.x.\n\n## Installation\n\nASReview Insights can be installed from PyPI:\n\n``` bash\npip install asreview-insights\n```\n\nAfter installation, check if the `asreview-insights` package is listed as an\nextension. Use the following command:\n\n```bash\nasreview --help\n```\n\nIt should list the 'plot' subcommand and the 'metrics' subcommand.\n\n## Performance metrics\n\nThe ASReview Insights extension is useful for measuring the performance of\nactive learning models on collections of binary labeled text. The extension\ncan be used after performing a simulation study that involves mimicking the\nscreening process with a specific model. As it is already known which records\nare labeled relevant, the simulation can automatically reenact the screening\nprocess as if a screener were using active learning. The performance of one or\nmultiple models can be measured by different metrics and the\nASReview Insights extension can plot or compute the values for such metrics\nfrom ASReview project files.\n\nThe recall is the proportion of relevant records that have been found at a\ncertain point during the screening phase. It is sometimes also called the\nproportion of Relevant Record Found (RRF) after screening an X% of the total\nrecords. For example, the RRF@10 is the recall (i.e., the proportion of the\ntotal number of relevant records) at screening 10% of the total number of\nrecords available in the dataset.\n\nA variation is the Extra Relevant records Found (ERF), which is the proportion\nof relevant records found after correcting for the number of relevant records\nfound via random screening (assuming a uniform distribution of relevant\nrecords).\n\nThe Work Saved over Sampling (WSS) is a measure of \"the work saved over and\nabove the work saved by simple sampling for a given level of recall\" ([Cohen\net al., 2006]((https://doi.org/10.1197/jamia.m1929)). It is defined as the\nproportion of records a screener does **not** have to screen compared to\nrandom reading after providing the prior knowledge used to train the first\niteration of the model. The WSS is typically measured at a recall of .95\n(WSS@95), reflecting the proportion of records saved by using active learning\nat the cost of failing to identify .05 of relevant publications.\n\nThe following plot illustrates the differences between the metrics Recall\n(y-axis), WSS (blue line), and ERF (red line). The dataset contains 1.000\nhypothetical records with labels. The stepped line on the diagonal is the\nnaive labeling approach (screening randomly sorted records).\n\n![ASReview metrics explained](https://github.com/asreview/asreview-insights/blob/master/docs/stats_explainer.png)\n\n\nBoth recall and WSS are sensitive to the position of the cutoff value and the\ndistribution of the data. Moreover, the WSS makes assumptions about the\nacceptable recall level whereas this level might depend on the research\nquestion at hand. Therefore, [Ferdinands et al.\n(2020)](https://doi.org/10.31219/osf.io/w6qbg) proposed two new metrics: (1)\nthe Time to Discover a relevant record as the fraction of records needed\nto screen to detect this record (TD); and (2) the Average Time to Discover\n(ATD) as an indicator of how many records need to be screened on average to\nfind all relevant records in the dataset.\n\n\n## Basic usage\n\nThe ASReview Insights package extends ASReview LAB with two new subcommands\n(see `asreview --help`): [`plot`](#plot) and [`metrics`](#metrics). The plots\nand metrics are derived from an ASReview project file. The ASReview file\n(extension `.asreview`) can be\n[exported](https://asreview.readthedocs.io/en/latest/manage.html#export-project)\nfrom ASReview LAB after a\n[simulation](https://asreview.readthedocs.io/en/latest/simulation_overview.html),\nor it is generated from running a [simulation via the command\nline](https://asreview.readthedocs.io/en/latest/simulation_cli.html).\n\nFor example, an ASReview can be generated with:\n\n\n```python\nasreview simulate benchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview --init_seed 535\n```\n\nTo use the most basic options of the ASReview Insights extension, run\n\n```bash\nasreview plot recall YOUR_ASREVIEW_FILE.asreview\n```\nwhere `recall` is the type of the plot, or\n\n```bash\nasreview metrics sim_van_de_schoot_2017.asreview\n```\n\nMore options are described in the sections below. All options can be\nobtained via `asreview plot --help` or `asreview metrics --help`.\n\n## `Plot`\n\n### Plot types\n\n#### `recall`\n\nThe recall is an important metric to study the performance of active learning\nalgorithms in the context of information retrieval. ASReview Insights\noffers a straightforward command line interface to plot a \"recall curve\". The\nrecall curve is the recall at any moment in the active learning process.\n\nTo plot the recall curve, you need a ASReview file (extension `.asreview`).To\nplot the recall, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by\nyour ASReview file name.):\n\n```bash\nasreview plot recall YOUR_ASREVIEW_FILE.asreview\n```\n\nThe following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in\nthe benchmark platform (command `asreview simulate\nbenchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).\n\n![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_recall_sim_van_de_schoot_2017_stop_if_min.png)\n\nOn the vertical axis, you find the recall (i.e, the proportion of the relevant\nrecords) after every labeling decision. The horizontal axis shows the\nproportion of  total number of records in the dataset. The steeper the recall\ncurve, the higher the performance of active learning when comparted to random\nscreening. The recall curve can also be used to estimate stopping criteria, see\nthe discussions in [#557](https://github.com/asreview/asreview/discussions/557) and [#1115](https://github.com/asreview/asreview/discussions/1115).\n\n\n```bash\nasreview plot recall YOUR_ASREVIEW_FILE.asreview\n```\n\n#### `wss`\n\nThe Work Saved over Sampling (WSS) metric is an useful metric to study the\nperformance of active learning alorithms compared with a naive (random order)\napproach at a given level of recall. ASReview Insights offers a\nstraightforward command line interface to plot the WSS at any level of recall.\n\nTo plot the WSS curve, you need a ASReview file (extension `.asreview`). To\nplot the WSS, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by your\nASReview file name.):\n\n```bash\nasreview plot wss YOUR_ASREVIEW_FILE.asreview\n```\n\nThe following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in\nthe benchmark platform (command `asreview simulate\nbenchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).\n\n![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_wss_default_sim_van_de_schoot_2017_stop_if_min.png)\n\nOn the vertical axis, you find the WSS after every labeling decision. The\nrecall is displayed on the horizontal axis. As shown in the figure, the\nWSS is linearly related to the recall.\n\n\n#### `erf`\n\nThe Extra Relevant Records found is a derivative of the recall and presents\nthe proportion of relevant records found after correcting for the number of\nrelevant records found via random screening (assuming a uniform distribution\nof relevant records).\n\nTo plot the WSS curve, you need a ASReview file (extension `.asreview`). To\nplot the WSS, use this syntax (Replace `YOUR_ASREVIEW_FILE.asreview` by your\nASReview file name.):\n\n\n```bash\nasreview plot erf YOUR_ASREVIEW_FILE.asreview\n```\n\nThe following plot is the result of simulating the [`van_de_schoot_2017`](https://github.com/asreview/systematic-review-datasets/tree/master/datasets/van_de_Schoot_2017) in\nthe benchmark platform (command `asreview simulate\nbenchmark:van_de_schoot_2017 -s sim_van_de_schoot_2017.asreview`).\n\n![Recall plot of Van de Schoot 2017](https://github.com/asreview/asreview-insights/blob/master/figures/tests_erf_default_sim_van_de_schoot_2017_stop_if_min.png)\n\nOn the vertical axis, you find the ERF after every labeling decision. The\nhorizontal axis shows the proportion of  total number of records in the\ndataset. The steep increase of the ERF in the beginning of the process is\nrelated to the steep recall curve.\n\n### Plotting CLI\n\nOptional arguments for the command line are `--priors` to include prior\nknowledge, `--x_absolute` and `--y_absolute` to use absolute axes.\n\nSee `asreview plot -h` for all command line arguments.\n\n\n### Plotting API\n\nTo make use of the more advanced features, you can make use of the Python API.\nThe advantage is that you can tweak every single element of the plot in the\nway you like. The following examples show how the Python API can be used. They\nmake use of matplotlib extensively. See the [Introduction to\nMatplotlib](https://matplotlib.org/stable/tutorials/introductory/usage.html)\nfor examples on using the API.\n\nThe following example show how to plot the recall with the API and save the\nresult. The plot is saved using the matplotlib API.\n\n```python\nimport matplotlib.pyplot as plt\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.plot import plot_recall\n\nwith open_state(\"example.asreview\") as s:\n\n    fig, ax = plt.subplots()\n\n    plot_recall(ax, s)\n\n    fig.savefig(\"example.png\")\n```\n\nOther options are `plot_wss` and `plot_erf`.\n\n#### Example: Customize plot\n\nIt's straightforward to customize the plots if you are familiar with\n`matplotlib`. The following example shows how to update the title of the plot.\n\n```python\nimport matplotlib.pyplot as plt\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.plot import plot_wss\n\nwith open_state(\"example.asreview\") as s:\n\n    fig, ax = plt.subplots()\n    plot_wss(ax, s)\n\n    plt.title(\"WSS with custom title\")\n\n    fig.savefig(\"example_custom_title.png\")\n```\n\n![WSS with custom title](https://github.com/asreview/asreview-insights/blob/master/docs/example_custom_title.png)\n\n#### Example: Prior knowledge\n\nIt's possible to include prior knowledge to your plot. By default, prior\nknowledge is excluded from the plot.\n\n```python\nimport matplotlib.pyplot as plt\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.plot import plot_wss\n\nwith open_state(\"example.asreview\") as s:\n\n    fig, ax = plt.subplots()\n    plot_wss(ax, s, priors=True)\n\n```\n\n#### Example: Relative versus absolute axes\n\nBy default, all axes in ASReview Insights are relative. The API can be used to\nchange this behavior. The arguments are identical for each plot function.\n\n```python\nimport matplotlib.pyplot as plt\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.plot import plot_wss\n\nwith open_state(\"example.asreview\") as s:\n\n    fig, ax = plt.subplots()\n    plot_wss(ax, s, x_absolute=True, y_absolute=True)\n\n    fig.savefig(\"example_absolute_axis.png\")\n```\n\n![Recall with absolute axes](https://github.com/asreview/asreview-insights/blob/master/docs/example_absolute_axes.png)\n\n\n#### Example: Multiple curves in one plot\n\nIt is possible to have multiple curves in one plot by using the API,\nand add a legend.\n\n```python\nimport matplotlib.pyplot as plt\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.plot import plot_recall\n\n\nfig, ax = plt.subplots()\n\nwith open_state(\"tests/asreview_files/sim_van_de_schoot_2017_1.asreview\") as s1:\n    plot_recall(ax, s1)\n\nwith open_state(\"tests/asreview_files/\"\n                \"sim_van_de_schoot_2017_logistic.asreview\") as s2:\n    plot_recall(ax, s2)\n\nax.lines[0].set_label(\"Naive Bayes\")\nax.lines[2].set_label(\"Logistic\")\nax.legend()\n\nfig.savefig(\"docs/example_multiple_lines.png\")\n```\n![Recall with multiple lines](https://github.com/asreview/asreview-insights/blob/master/docs/example_multiple_lines.png)\n\n## `metrics`\n\nThe `metrics` subcommand in ASReview Insights can be used to compute metrics\nat given values. The easiest way to get compute metrics for a ASReview project\nfile is with the following command don the command line:\n\n```\nasreview metrics sim_van_de_schoot_2017.asreview\n```\n\nwhich results in\n\n```\n    \"asreviewVersion\": \"1.0\",\n    \"apiVersion\": \"1.0\",\n    \"data\": {\n        \"items\": [\n            {\n                \"id\": \"recall\",\n                \"title\": \"Recall\",\n                \"value\": [\n                    [\n                        0.1,\n                        1.0\n                    ],\n                    [\n                        0.25,\n                        1.0\n                    ],\n                    [\n                        0.5,\n                        1.0\n                    ],\n                    [\n                        0.75,\n                        1.0\n                    ],\n                    [\n                        0.9,\n                        1.0\n                    ]\n                ]\n            },\n            {\n                \"id\": \"wss\",\n                \"title\": \"Work Saved over Sampling\",\n                \"value\": [\n                    [\n                        0.95,\n                        0.8913851624373686\n                    ]\n                ]\n            },\n            {\n                \"id\": \"erf\",\n                \"title\": \"Extra Relevant record Found\",\n                \"value\": [\n                    [\n                        0.1,\n                        0.9047619047619048\n                    ]\n                ]\n            },\n            {\n                \"id\": \"atd\",\n                \"title\": \"Average time to discovery\",\n                \"value\": 101.71428571428571\n            },\n            {\n                \"id\": \"td\",\n                \"title\": \"Time to discovery\",\n                \"value\": [\n                    [\n                        3898,\n                        22\n                    ],\n                    [\n                        284,\n                        23\n                    ],\n                    [\n                        592,\n                        25\n                    ],\n                    ...\n                    [\n                        2382,\n                        184\n                    ],\n                    [\n                        5479,\n                        224\n                    ],\n                    [\n                        3316,\n                        575\n                    ]\n                ]\n            }\n        ]\n    }\n}\n```\n\nEach available item has two values. The first value is the value at which the\nmetric is computed. In the plots above, this is the x-axis. The second value\nis the results of the metric. Some metrics are computed for multiple values.\n\n| Metric | Description pos. 1 | Description pos. 2 | Default |\n|---|---|---|---|\n| `recall` | Labels | Recall | 0.1, 0.25, 0.5, 0.75, 0.9 |\n| `wss` | Recall | Work Saved over Sampling at recall | 0.95 |\n| `erf` | Labels | ERF | 0.10 |\n| `atd` | Average time to discovery (in label actions) | - | - |\n| `td` | Row number (starting at 0) | Number of records labeled | - |\n\n\n### Override default values\n\nIt is possible to override the default values of `asreview metrics`. See\n`asreview metrics -h` for more information or see the example below.\n\n```\nasreview metrics sim_van_de_schoot_2017.asreview --wss 0.9 0.95\n```\n\n```\n{\n    \"asreviewVersion\": \"1.0\",\n    \"apiVersion\": \"1.0\",\n    \"data\": {\n        \"items\": [\n            {\n                \"id\": \"recall\",\n                \"title\": \"Recall\",\n                \"value\": [\n                    [\n                        0.1,\n                        1.0\n                    ],\n                    [\n                        0.25,\n                        1.0\n                    ],\n                    [\n                        0.5,\n                        1.0\n                    ],\n                    [\n                        0.75,\n                        1.0\n                    ],\n                    [\n                        0.9,\n                        1.0\n                    ]\n                ]\n            },\n            {\n                \"id\": \"wss\",\n                \"title\": \"Work Saved over Sampling\",\n                \"value\": [\n                    [\n                        0.9,\n                        0.8474220139001132\n                    ],\n                    [\n                        0.95,\n                        0.8913851624373686\n                    ]\n                ]\n            },\n            {\n                \"id\": \"erf\",\n                \"title\": \"Extra Relevant record Found\",\n                \"value\": [\n                    [\n                        0.1,\n                        0.9047619047619048\n                    ]\n                ]\n            },\n            {\n                \"id\": \"atd\",\n                \"title\": \"Average time to discovery\",\n                \"value\": 101.71428571428571\n            },\n            {\n                \"id\": \"td\",\n                \"title\": \"Time to discovery\",\n                \"value\": [\n                    [\n                        3898,\n                        22\n                    ],\n                    [\n                        284,\n                        23\n                    ],\n                    [\n                        592,\n                        25\n                    ],\n                    ...\n                    [\n                        2382,\n                        184\n                    ],\n                    [\n                        5479,\n                        224\n                    ],\n                    [\n                        3316,\n                        575\n                    ]\n                ]\n            }\n        ]\n    }\n}\n```\n\n### Save metrics to file\n\nMetrics can be saved to a file in the JSON format. Use the flag `-o` or\n`--output`.\n\n```\nasreview metrics sim_van_de_schoot_2017.asreview -o my_file.json\n```\n\n### Metrics CLI\n\nOptional arguments for the command line are `--priors` to include prior\nknowledge, `--x_absolute` and `--y_absolute` to use absolute axes.\n\nSee `asreview metrics -h` for all command line arguments.\n\n### Metrics API\n\nMetrics are easily accesible with the ASReview Insights API.\n\nCompute the recall after reading half of the dataset.\n\n```python\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.metrics import recall\n\nwith open_state(\"example.asreview\") as s:\n\n    print(recall(s, 0.5))\n```\n\nOther metrics are available like `wss` and `erf`.\n\n#### Example: Prior knowledge\n\nIt's possible to include prior knowledge to your metric. By default, prior\nknowledge is excluded from the metric.\n\n```python\n\nfrom asreview import open_state\nfrom asreviewcontrib.insights.metrics import recall\n\nwith open_state(\"example.asreview\") as s:\n\n    print(recall(s, 0.5, priors=True))\n```\n\n## License\n\nThis extension is published under the [MIT license](/LICENSE).\n\n## Contact\n\nThis extension is part of the ASReview project ([asreview.ai](https://asreview.ai)). It is maintained by the\nmaintainers of ASReview LAB. See [ASReview\nLAB](https://github.com/asreview/asreview) for contact information and more\nresources.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Insight tools for the ASReview project",
    "version": "1.1.2",
    "split_keywords": [
        "asreview",
        "plot",
        "insights"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "dbf7b6c56805c7dcc7656a6d301ad0bf",
                "sha256": "55cc52fbfd69d463d895d009c63ad93da8cb41d668bc2f67b257600925315f15"
            },
            "downloads": -1,
            "filename": "asreview_insights-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dbf7b6c56805c7dcc7656a6d301ad0bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17454,
            "upload_time": "2022-12-09T14:59:58",
            "upload_time_iso_8601": "2022-12-09T14:59:58.370765Z",
            "url": "https://files.pythonhosted.org/packages/7a/a5/64642e0d49211320218a7e7eae73aa0a071ba8bcbcc4393f80de6463de2b/asreview_insights-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1f642b4865dbd86bcbd654396c24f839",
                "sha256": "4c3baececbb3162cd20c50be38951fa274cdcb3be5ce9a03834bed35a11c8062"
            },
            "downloads": -1,
            "filename": "asreview-insights-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1f642b4865dbd86bcbd654396c24f839",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 32070,
            "upload_time": "2022-12-09T15:00:00",
            "upload_time_iso_8601": "2022-12-09T15:00:00.809370Z",
            "url": "https://files.pythonhosted.org/packages/27/e4/f6f7847067f83f65e3a9e326559acf6b14dd16f6c943aced281d80201b3e/asreview-insights-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-09 15:00:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "asreview",
    "github_project": "asreview-insights",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "asreview-insights"
}
        
Elapsed time: 0.02195s