Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Samoed committed Nov 23, 2024
1 parent 2580cde commit 4bc38fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions autointent/metrics/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ def scoring_log_likelihood(labels: LABELS_VALUE_TYPE, scores: SCORES_VALUE_TYPE,
r"""
Supports multiclass and multilabel cases.
Multiclass case
Multiclass case:
Mean negative cross-entropy for each utterance classification result:
.. math::
\frac{1}{\ell}\sum_{i=1}^{\ell}\log(s[y[i]])
where ``s[y[i]]`` is a predicted score of ``i``th utterance having ground truth label
where ``s[y[i]]`` is the predicted score of the ``i``-th utterance having the ground truth label.
Multilabel case
Multilabel case:
Mean negative binary cross-entropy:
.. math::
\frac{1}{\ell}\sum_{i=1}^\ell\sum_{c=1}^C\Big[y[i,c]\cdot\log(s[i,c])+(1-y[i,c])\cdot\log(1-s[i,c])\Big]
where ``s[i,c]`` is a predicted score of ``i``'th utterance having ground truth label ``c``
where ``s[i,c]`` is the predicted score of the ``i``-th utterance having the ground truth label ``c``.
:param labels: ground truth labels for each utterance
:param scores: for each utterance, this list contains scores for each of `n_classes` classes
:param eps: small value to avoid division by zero
:return: Score of the scoring metric
:param labels: Ground truth labels for each utterance.
:param scores: For each utterance, a list containing scores for each of `n_classes` classes.
:param eps: A small value to avoid division by zero.
:return: Score of the scoring metric.
"""
labels_array, scores_array = transform(labels, scores)
scores_array[scores_array == 0] = eps
Expand Down
8 changes: 8 additions & 0 deletions tutorials/pipeline_optimization/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import importlib.resources as ires
from pathlib import Path
from typing import Literal
from uuid import uuid4

from autointent.configs.optimization_cli import (
DataConfig,
Expand All @@ -22,6 +23,13 @@
TaskType = Literal["multiclass", "multilabel", "description"]


def setup_environment() -> tuple[str, str, str]:
logs_dir = ires.files("tests").joinpath("logs") / str(uuid4())
db_dir = logs_dir / "db"
dump_dir = logs_dir / "modules_dump"
return db_dir, dump_dir, logs_dir


def get_search_space_path(task_type: TaskType) -> None:
return ires.files("tests.assets.configs").joinpath(f"{task_type}.yaml")

Expand Down

0 comments on commit 4bc38fb

Please sign in to comment.