Skip to content

Commit cca9c0d

Browse files
authored
fix: fixed link functions (#69)
1 parent 272e1d4 commit cca9c0d

File tree

26 files changed

+82
-82
lines changed

26 files changed

+82
-82
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,11 @@ test-docs: docs
3838
serve-docs: docs
3939
$(poetry) python -m http.server -d docs/build/html 8333
4040

41+
.PHONY: clean-docs
42+
clean-docs:
43+
rm -rf docs/build
44+
rm -rf docs/source/autoapi
45+
rm -rf docs/source/tutorials
46+
4147
.PHONY: all
4248
all: lint

autointent/context/data_handler/_dataset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from datasets import ClassLabel, Sequence, concatenate_datasets, get_dataset_config_names, load_dataset
99
from datasets import Dataset as HFDataset
10-
from typing_extensions import Self
1110

1211
from autointent.custom_types import LabelType
1312

@@ -141,7 +140,7 @@ def dump(self) -> dict[str, list[dict[str, Any]]]:
141140
"""
142141
return {split_name: split.to_list() for split_name, split in self.items()}
143142

144-
def encode_labels(self) -> Self:
143+
def encode_labels(self) -> "Dataset":
145144
"""
146145
Encode dataset labels into one-hot or multilabel format.
147146
@@ -152,7 +151,7 @@ def encode_labels(self) -> Self:
152151
self._encoded_labels = True
153152
return self
154153

155-
def to_multilabel(self) -> Self:
154+
def to_multilabel(self) -> "Dataset":
156155
"""
157156
Convert dataset labels to multilabel format.
158157

autointent/context/data_handler/_schemas.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
from pydantic import BaseModel, model_validator
7-
from typing_extensions import Self
87

98
from autointent.custom_types import LabelType
109

@@ -34,7 +33,7 @@ class Sample(BaseModel):
3433
label: LabelType | None = None
3534

3635
@model_validator(mode="after")
37-
def validate_sample(self) -> Self:
36+
def validate_sample(self) -> "Sample":
3837
"""
3938
Validate the sample after model instantiation.
4039
@@ -48,7 +47,7 @@ def validate_sample(self) -> Self:
4847
"""
4948
return self._validate_label()
5049

51-
def _validate_label(self) -> Self:
50+
def _validate_label(self) -> "Sample":
5251
"""
5352
Validate the `label` field of the sample.
5453

autointent/context/data_handler/_validation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""File with definitions of DatasetReader and DatasetValidator."""
22

33
from pydantic import BaseModel, model_validator
4-
from typing_extensions import Self
54

65
from ._schemas import Intent, Sample
76

@@ -21,7 +20,7 @@ class DatasetReader(BaseModel):
2120
intents: list[Intent] = []
2221

2322
@model_validator(mode="after")
24-
def validate_dataset(self) -> Self:
23+
def validate_dataset(self) -> "DatasetReader":
2524
"""
2625
Validate the dataset by ensuring intents and data splits are consistent.
2726
@@ -33,7 +32,7 @@ def validate_dataset(self) -> Self:
3332
self._validate_split(split)
3433
return self
3534

36-
def _validate_intents(self) -> Self:
35+
def _validate_intents(self) -> "DatasetReader":
3736
"""
3837
Validate the intents by checking their IDs for sequential order.
3938
@@ -52,7 +51,7 @@ def _validate_intents(self) -> Self:
5251
raise ValueError(message)
5352
return self
5453

55-
def _validate_split(self, split: list[Sample]) -> Self:
54+
def _validate_split(self, split: list[Sample]) -> "DatasetReader":
5655
"""
5756
Validate a dataset split to ensure all sample labels reference valid intent IDs.
5857

autointent/metrics/retrieval.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def retrieval_map(query_labels: LABELS_VALUE_TYPE, candidates_labels: CANDIDATE_
115115
Calculate the mean average precision at position k.
116116
117117
The Mean Average Precision (MAP) is computed as the average of the average precision
118-
(AP) scores for all queries. The average precision for a single query is calculated using
119-
the :func:`average_precision` function, which computes the precision at each rank
118+
(AP) scores for all queries. The average precision for a single query computes the precision at each rank
120119
position considering the top-k retrieved items.
121120
122121
MAP is given by:
@@ -192,8 +191,7 @@ def retrieval_map_intersecting(
192191
193192
The Mean Average Precision (MAP) for intersecting labels is computed as
194193
the average of the average precision (AP) scores for all queries. The average
195-
precision for a single query is calculated using the :func:`average_precision_intersecting`
196-
function, which considers the intersecting true and predicted labels for the
194+
precision for a single query considers the intersecting true and predicted labels for the
197195
top-k retrieved items.
198196
199197
MAP is given by:
@@ -226,8 +224,8 @@ def retrieval_map_macro(
226224
r"""
227225
Calculate the mean average precision at position k for the intersecting labels.
228226
229-
This function internally uses :func:`retrieval_map` to calculate the MAP for each query and then
230-
applies :func:`macrofy` to perform macro-averaging across multiple queries.
227+
This function internally uses :func:`retrieval_map` to calculate the MAP for each query and
228+
performs macro-averaging across multiple queries.
231229
232230
:param query_labels: For each query, this list contains its class labels
233231
:param candidates_labels: For each query, these lists contain class labels of items ranked by a retrieval model
@@ -372,7 +370,7 @@ def retrieval_hit_rate_macro(
372370
Calculate the hit rate at position k for the intersecting labels.
373371
374372
This function internally uses :func:`retrieval_hit_rate` to calculate the hit rate at position :math:`k`
375-
for each query and applies :func:`macrofy` to perform macro-averaging across multiple queries.
373+
for each query and performs macro-averaging across multiple queries.
376374
377375
:param query_labels: For each query, this list contains its class labels
378376
:param candidates_labels: For each query, these lists contain class labels of items ranked by a retrieval model
@@ -508,7 +506,7 @@ def retrieval_precision_macro(
508506
Calculate the precision at position k for the intersecting labels.
509507
510508
This function internally uses :func:`retrieval_precision` to calculate the precision at position :math:`k`
511-
for each query and applies :func:`macrofy` to perform macro-averaging across multiple queries.
509+
for each query and performs macro-averaging across multiple queries.
512510
513511
:param query_labels: For each query, this list contains its class labels
514512
:param candidates_labels: For each query, these lists contain class labels of items ranked by a retrieval model
@@ -685,8 +683,7 @@ def retrieval_ndcg_macro(
685683
r"""
686684
Calculate the Normalized Discounted Cumulative Gain (NDCG) at position k for the intersecting labels.
687685
688-
This function calculates NDCG using :func:`retrieval_ndcg` and applies it to each
689-
query using :func:`macrofy` to compute the macro-averaged score.
686+
This function calculates NDCG using :func:`retrieval_ndcg` and computes the macro-averaged score.
690687
691688
:param query_labels: For each query, this list contains its class labels
692689
:param candidates_labels: For each query, these lists contain class labels of items ranked by a retrieval model (from most to least relevant)
@@ -778,8 +775,7 @@ def retrieval_mrr_macro(
778775
r"""
779776
Calculate the Mean Reciprocal Rank (MRR) at position k for the intersecting labels.
780777
781-
This function calculates MRR using :func:`retrieval_mrr` and applies it to each
782-
query using :func:`macrofy` to compute the macro-averaged score.
778+
This function calculates MRR using :func:`retrieval_mrr` and computes the macro-averaged score.
783779
784780
:param query_labels: For each query, this list contains its class labels
785781
:param candidates_labels: For each query, these lists contain class labels of items ranked by a retrieval model (from most to least relevant)

autointent/metrics/scoring.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def _calculate_prediction_metric(
105105
r"""
106106
Calculate prediction metric.
107107
108-
This function applies the given prediction metric function :func:`func` to evaluate the predictions.
108+
This function applies the given prediction metric function `func` to evaluate the predictions.
109109
It transforms the inputs and computes predictions based on the input scores:
110-
- For multiclass classification, predictions are generated using :func:`np.argmax`.
110+
- For multiclass classification, predictions are generated using `np.argmax`.
111111
- For multilabel classification, predictions are generated using a threshold of 0.5.
112112
113113
:param func: prediction metric function
@@ -131,8 +131,8 @@ def scoring_accuracy(labels: LABELS_VALUE_TYPE, scores: SCORES_VALUE_TYPE) -> fl
131131
r"""
132132
Calculate accuracy for multiclass and multilabel classification.
133133
134-
This function computes accuracy by using :func:`prediction_accuracy` to evaluate predictions and
135-
:func:`calculate_prediction_metric` to handle the computation.
134+
This function computes accuracy by using :func:`autointent.metrics.prediction.prediction_accuracy`
135+
to evaluate predictions.
136136
137137
:param labels: ground truth labels for each utterance
138138
:param scores: for each utterance, this list contains scores for each of `n_classes` classes
@@ -145,8 +145,8 @@ def scoring_f1(labels: LABELS_VALUE_TYPE, scores: SCORES_VALUE_TYPE) -> float:
145145
r"""
146146
Calculate the F1 score for multiclass and multilabel classification.
147147
148-
This function computes the F1 score by using :func:`prediction_f1` to evaluate predictions and
149-
:func:`calculate_prediction_metric` to handle the computation.
148+
This function computes the F1 score by using :func:`autointent.metrics.prediction.prediction_f1`
149+
to evaluate predictions.
150150
151151
:param labels: Ground truth labels for each sample
152152
:param scores: For each sample, this list contains scores for each of `n_classes` classes
@@ -159,8 +159,8 @@ def scoring_precision(labels: LABELS_VALUE_TYPE, scores: SCORES_VALUE_TYPE) -> f
159159
r"""
160160
Calculate precision for multiclass and multilabel classification.
161161
162-
This function computes precision by using :func:`prediction_precision` to evaluate predictions and
163-
:func:`calculate_prediction_metric` to handle the computation.
162+
This function computes precision by using :func:`autointent.metrics.prediction.prediction_precision`
163+
to evaluate predictions.
164164
165165
:param labels: Ground truth labels for each sample
166166
:param scores: For each sample, this list contains scores for each of `n_classes` classes
@@ -173,8 +173,8 @@ def scoring_recall(labels: LABELS_VALUE_TYPE, scores: SCORES_VALUE_TYPE) -> floa
173173
r"""
174174
Calculate recall for multiclass and multilabel classification.
175175
176-
This function computes recall by using :func:`prediction_recall` to evaluate predictions and
177-
:func:`calculate_prediction_metric` to handle the computation.
176+
This function computes recall by using :func:`autointent.metrics.prediction.prediction_recall`
177+
to evaluate predictions.
178178
179179
:param labels: Ground truth labels for each sample
180180
:param scores: For each sample, this list contains scores for each of `n_classes` classes

autointent/modules/_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Any, Literal
55

66
import numpy.typing as npt
7-
from typing_extensions import Self
87

98
from autointent.context import Context
109
from autointent.context.optimization_info import Artifact
@@ -91,7 +90,7 @@ def predict_with_metadata(
9190

9291
@classmethod
9392
@abstractmethod
94-
def from_context(cls, context: Context, **kwargs: dict[str, Any]) -> Self:
93+
def from_context(cls, context: Context, **kwargs: dict[str, Any]) -> "Module":
9594
"""
9695
Initialize self from context.
9796

autointent/modules/_regexp.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from pathlib import Path
66
from typing import Any, Literal, TypedDict
77

8-
from typing_extensions import Self
9-
108
from autointent import Context
119
from autointent.context.data_handler._data_handler import RegexPatterns
1210
from autointent.context.data_handler._schemas import Intent
@@ -32,7 +30,7 @@ class RegExp(Module):
3230
"""Regular expressions based intent detection module."""
3331

3432
@classmethod
35-
def from_context(cls, context: Context) -> Self:
33+
def from_context(cls, context: Context) -> "RegExp":
3634
"""Initialize from context."""
3735
return cls()
3836

autointent/modules/prediction/_adaptive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import numpy as np
88
import numpy.typing as npt
99
from sklearn.metrics import f1_score
10-
from typing_extensions import Self
1110

1211
from autointent import Context
1312
from autointent.context.data_handler import Tag
@@ -86,7 +85,7 @@ def __init__(self, search_space: list[float] | None = None) -> None:
8685
self.search_space = search_space if search_space is not None else default_search_space
8786

8887
@classmethod
89-
def from_context(cls, context: Context, search_space: list[float] | None = None) -> Self:
88+
def from_context(cls, context: Context, search_space: list[float] | None = None) -> "AdaptivePredictor":
9089
"""
9190
Create an AdaptivePredictor instance using a Context object.
9291

autointent/modules/prediction/_argmax.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import numpy as np
88
import numpy.typing as npt
9-
from typing_extensions import Self
109

1110
from autointent import Context
1211
from autointent.context.data_handler import Tag
@@ -60,7 +59,7 @@ def __init__(self) -> None:
6059
"""Init."""
6160

6261
@classmethod
63-
def from_context(cls, context: Context) -> Self:
62+
def from_context(cls, context: Context) -> "ArgmaxPredictor":
6463
"""
6564
Initialize form context.
6665

0 commit comments

Comments
 (0)