How to use the asreview.settings.ASReviewSettings function in asreview

To help you get started, we’ve selected a few asreview examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github msdslab / automated-systematic-review / tests / test_state.py View on Github external
def check_write_state(tmpdir, state_file):
    if state_file is not None:
        state_fp = os.path.join(tmpdir, state_file)
    else:
        state_fp = None

    settings = ASReviewSettings(mode="simulate", model="nb",
                                query_strategy="rand_max",
                                balance_strategy="simple",
                                feature_extraction="tfidf")

    n_records = 6
    n_half = int(n_records/2)
    start_labels = np.full(n_records, np.nan, dtype=np.int)
    labels = np.zeros(n_records, dtype=np.int)
    labels[::2] = np.ones(n_half, dtype=np.int)
    methods = np.full((n_records), "initial")
    methods[2::] = np.full((int(n_records-2)), "random")
    methods[2::2] = np.full((int((n_records-2)/2)), "max")

    with open_state(state_fp) as state:
        state.settings = settings
        state.set_labels(start_labels)
github msdslab / automated-systematic-review / asreview / hdf5_logging.py View on Github external
if read_only:
            mode = 'r'
        else:
            mode = 'a'

        Path(fp).parent.mkdir(parents=True, exist_ok=True)
        self.f = h5py.File(fp, mode)
        try:
            log_version = self.f.attrs['version'].decode("ascii")
            if log_version != self.version:
                raise ValueError(
                    f"Log cannot be read: logger version {self.version}, "
                    f"logfile version {log_version}.")
            settings_dict = json.loads(self.f.attrs['settings'])
            if "mode" in settings_dict:
                self.settings = ASReviewSettings(**settings_dict)
        except KeyError:
            self.create_structure()
github msdslab / automated-systematic-review / asreview / review / factory.py View on Github external
prior_dataset=[],
                 new=False,
                 **kwargs
                 ):
    """Get a review object from arguments.

    See __main__.py for a description of the arguments.
    """
    as_data = create_as_data(dataset, included_dataset, excluded_dataset,
                             prior_dataset, new=new)

    if len(as_data) == 0:
        raise ValueError("Supply at least one dataset"
                         " with at least one record.")

    cli_settings = ASReviewSettings(
        model=model, n_instances=n_instances, n_queries=n_queries,
        n_papers=n_papers, n_prior_included=n_prior_included,
        n_prior_excluded=n_prior_excluded, query_strategy=query_strategy,
        balance_strategy=balance_strategy,
        feature_extraction=feature_extraction,
        mode=mode, data_fp=None,
        abstract_only=abstract_only)
    cli_settings.from_file(config_file)

    if state_file is not None:
        with open_state(state_file) as state:
            if state.is_empty():
                state.settings = cli_settings
            settings = state.settings
    else:
        settings = cli_settings
github msdslab / automated-systematic-review / asreview / review / base.py View on Github external
def settings(self):
        """Get an ASReview settings object"""
        extra_kwargs = {}
        if hasattr(self, 'n_prior_included'):
            extra_kwargs['n_prior_included'] = self.n_prior_included
        if hasattr(self, 'n_prior_excluded'):
            extra_kwargs['n_prior_excluded'] = self.n_prior_excluded
        return ASReviewSettings(
            mode=self.name, model=self.model.name,
            query_strategy=self.query_model.name,
            balance_strategy=self.balance_model.name,
            feature_extraction=self.feature_model.name,
            n_instances=self.n_instances,
            n_queries=self.n_queries,
            n_papers=self.n_papers,
            model_param=self.model.param,
            query_param=self.query_model.param,
            balance_param=self.balance_model.param,
            feature_param=self.feature_model.param,
            data_name=self.as_data.data_name,
            **extra_kwargs)
github msdslab / automated-systematic-review / asreview / state / hdf5.py View on Github external
def settings(self):
        settings = self.f.attrs.get('settings', None)
        if settings is None:
            return None
        settings_dict = json.loads(settings)
        return ASReviewSettings(**settings_dict)
github msdslab / automated-systematic-review / asreview / state / dict.py View on Github external
def settings(self):
        settings = self._state_dict.get("settings", None)
        if settings is None:
            return None
        return ASReviewSettings(**settings)