Skip to main content

Makita workflow tool for the ASReview project

Project description

ASReview Makita

PyPI version Downloads PyPI - License Deploy and release Build status DOI

ASReviews' Makita (MAKe IT Automatic) is a workflow generator for simulation studies using the command line interface of ASReview LAB. Makita can be used to effortlessly generate the framework and code for your simulation study.

A simulation involves mimicking the screening process for a systematic review of a human in interaction with an Active learning model (i.e., a combination of a feature extractor, classifier, balancing method, and a query strategy). The simulation reenacts the screening process as if a researcher were using active learning. The performance of one or multiple model(s) can then be measured by performance metrics, such as the Work Saved over Sampling, recall at a given point in the screening process, or the average time to discover a relevant record.

Using Makita templates, different study structures can be generated to fit the needs of your very own study. If your study requires a unique template, you can create a new one and use it instead.

With ASReview LAB, you can simulate with the web interface, the Python API, or the Command Line Interface (CLI). Makita makes use of the CLI.

What Makita does:

  • Setting up a workflow for running a large-scale simulation study
  • Preparing a Github repository
  • Automating the many lines of code needed
  • Creating a batch script for running the simulation study with just one line of code
  • Making your research fully reproducible
  • Allowing you to add templates to accommodate your own specific research question

What Makita does not do:

  • Executing jobs or tasks itself
  • Being a black-box
  • Writing your paper

For a tutorial on using Makita we refer to the Exercise on Using the ASReview Simulation Mode.

Installation

Install the Makita extension with pip:

pip install asreview-makita

For upgrading, use:

pip install --upgrade asreview-makita

After installing the extension, ASReview should automatically detect Makita. If installed correctly, asreview --help should list Makita as an option.

Getting started

You can create the framework and code for your own simulation study in 4 steps.

  1. Create an project folder on your computer.
  2. Create a subfolder named data and fill it using one or more datasets.
  3. Using your preferred command line tool, cd into the project folder.
  4. Create a simulation study from a template found in the list of templates via
asreview makita template NAME_OF_TEMPLATE

where NAME_OF_TEMPLATE is one of the templates (e.g. asreview makita template arfi).

Your simulation study is now properly set up and ready for use. To start the simulations, execute the following shell script in the project folder:

sh jobs.sh

The jobs.sh script is a shell script that runs all jobs in the project folder.

Windows support

For Windows users, ASReview Makita offers support for batch files. Use the -f option to generate a jobs.bat script instead of the default jobs.sh script.

asreview makita template basic -f jobs.bat

Alternatively, Windows CMD does not support the sh command, and a bash shell is required. You can use tools such as Git Bash, Cygwin, WSL, etc. to run the jobs.sh script instead.

Templates

The following table gives an overview of the available templates. See Getting started for instructions on usage.

Note: If no seed is set with the template command, the default seed is used. While this is important for the reproducibility of the results, it may lead to long-term bias. To avoid seed-related bias across different simulation studies, a seed should be for the prior records and models.

Basic template

command: basic

The basic template prepares a script for conducting a simulation study with one run using the default model settings, and two randomly chosen priors (one relevant and one irrelevant record).

optional arguments:

  -h, --help                                       show this help message and exit
  -f OUTPUT_FILE                                   File with jobs
  -s DATA_FOLDER                                   Dataset folder
  -o OUTPUT_FOLDER                                 Output folder
  --init_seed INIT_SEED                            Seed of the priors. Seed is set by default!
  --model_seed MODEL_SEED                          Seed of the models. Seed is set by default!
  --template TEMPLATE                              Overwrite template with template file path.
  --n_runs N_RUNS                                  Number of runs

ARFI template

command: arfi

The ARFI template (All relevant, fixed irrelevant) prepares a script for running a simulation study in such a way that for every relevant record 1 run will be executed with 10 randomly chosen irrelevant records which are kept constant over runs. When multiple datasets are available the template orders the tasks in the job file per dataset.

optional arguments:

  -h, --help                                       show this help message and exit
  -f OUTPUT_FILE                                   File with jobs
  -s DATA_FOLDER                                   Dataset folder
  -o OUTPUT_FOLDER                                 Output folder
  --init_seed INIT_SEED                            Seed of the priors. Seed is set by default!
  --model_seed MODEL_SEED                          Seed of the models. Seed is set by default!
  --template TEMPLATE                              Overwrite template with template file path.
  --n_priors N_PRIORS                              Number of priors

Multiple models template

command: multiple_models

The multiple model template prepares a script for running a simulation study comparing multiple models for one dataset and a fixed set of priors (one relevant and one irrelevant record; identical across models).

optional arguments:

  -h, --help                                       Show this help message and exit
  -f OUTPUT_FILE                                   File with jobs
  -s DATA_FOLDER                                   Dataset folder
  -o OUTPUT_FOLDER                                 Output folder
  --init_seed INIT_SEED                            Seed of the priors. Seed is set by default!
  --model_seed MODEL_SEED                          Seed of the models. Seed is set by default!
  --template TEMPLATE                              Overwrite template with template file path.
  --classifiers CLASSIFIERS [CLASSIFIERS ...]                           Classifiers to use
  --feature_extractors FEATURE_EXTRACTOR [FEATURE_EXTRACTORS ...]   Feature extractors to use
  --impossible_models IMPOSSIBLE_MODELS [IMPOSSIBLE_MODELS ...]         Model combinations to exclude

The default models are:

classifiers           ["logistic", "nb", "rf", "svm"]
feature_extractors   ["doc2vec", "sbert", "tfidf"]
impossible_models     [["nb", "doc2vec"], ["nb", "sbert"]]

Example command: If you want to generate a multiple models template with classifiers logistic and nb, and feature extraction tfidf, you can use the following command:

asreview makita template multiple_models --classifiers logistic nb --feature_extractors tfidf

Advanced usage

Create and use custom templates

It is possible to overwrite the internal templates. This can be useful for simulation studies with different needs.

  1. Select an existing template that looks similar to your needs. For example, you want to run ARFI with a different model, then you pick the ARFI template.
  2. Download the template you selected in step 1 from the Github repository. Template files have the following structure template_*.txt.template. For the ARFI example, the template is template_arfi.txt.template.
  3. Save the downloaded template somewhere on your computer. The template is a so-called "Jinja" template. The template consists of ASReview command line commands combined with jinja syntax. The Jinja syntax is very intuitive. See this Cheatsheet.
  4. Edit the Jinja template to your needs.
  5. Run the custom template with the command line option --template PATH_TO_MY_TEMPLATE.txt.template. For the ARFI example, this would be asreview makita template arfi --template PATH_TO_MY_TEMPLATE.txt.template. Please keep in mind that you follow the usual steps for running a template.
  6. A jobs.sh file should be in the your folder.

Please contribute your templates back to the project by making a Pull Request. Then, we can integrate it in the core of the makita package.

Add and use scripts

Makita can add scripts to your repository. The scripts are mainly pre- and postprocessing scripts. These scripts are not (yet) available in any existing ASReview software. Therefore, they can be added manually with asreview makita add-script NAME_OF_SCRIPT.

For example, the results from ASReview datatools are merged via the script merge_descriptives.py (or merge_metrics.py for ASReview insights), using:

  1. Collect statistics (with template)
  2. Run asreview makita add-script merge_descriptives.py
  3. Run python scripts/merge_descriptives.py

Use -s (source) and -o (output) to tweak paths.

Some scripts are added automatically to the folder, as they are part of the template. For example, the get_plot.py script is added to the generated folder when using any template, as it is used to generate the plots.

Still, get_plot.py can be used on its own, as it is a standalone script. To use it, use -s (source) and -o (output) to tweak paths.

Adding a legend to the plot can be done with the -l or --show_legend flag, with the labels clustered on any of the following: 'filename', 'model', 'query_strategy', 'balance_strategy', 'feature_extraction', 'n_instances', 'stop_if', 'n_prior_included', 'n_prior_excluded', 'model_param', 'query_param', 'feature_param', 'balance_param'

Available scripts

The following scripts are available:

  • get_plot.py
  • get_settings_from_state.py
  • merge_descriptives.py
  • merge_metrics.py
  • merge_tds.py
  • split_data_with_multiple_labels.py [DEPRECATED]

License

This extension is published under the MIT license.

Contact

This extension is part of the ASReview project (asreview.ai). It is maintained by the maintainers of ASReview LAB. See ASReview LAB for contact information and more resources.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asreview-makita-0.6.3.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

asreview_makita-0.6.3-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file asreview-makita-0.6.3.tar.gz.

File metadata

  • Download URL: asreview-makita-0.6.3.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for asreview-makita-0.6.3.tar.gz
Algorithm Hash digest
SHA256 c66ba61ff398c7b831f80cf77926edb9911943e14995ab37a65a46ebe2750e56
MD5 b7eb5a229036e312d441b05bafe4c7d2
BLAKE2b-256 3a004e449fb712cf0b04d879260d95940d016ed4fab4350ca8353914f1b3b6cc

See more details on using hashes here.

File details

Details for the file asreview_makita-0.6.3-py3-none-any.whl.

File metadata

File hashes

Hashes for asreview_makita-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f6e94a08cc896e67728cb8e76a52fb41b093b134c3989de99654b7890700acbc
MD5 c7a228e14fcd56cf3a6d0a6af557d674
BLAKE2b-256 27800f9e06666a3adfb01ce662fb36af0f83c18440ea507a74578e82611d66c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page