Skip to content

Commit 0fde5ab

Browse files
committed
feat: examples for AadaptivePredictor
1 parent d7d3e67 commit 0fde5ab

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

autointent/modules/prediction/_adaptive.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,35 @@ class AdaptivePredictor(PredictionModule):
4545
:ivar _r: Scaling factor for thresholds.
4646
:ivar tags: List of Tag objects for mutually exclusive classes.
4747
:ivar name: Name of the predictor, defaults to "adaptive".
48+
49+
Parameters
50+
----------
51+
search_space : list[float], optional
52+
List of threshold scaling factors to search for optimal performance.
53+
Defaults to a range between 0 and 1.
54+
55+
Examples
56+
--------
57+
>>> from autointent.modules import AdaptivePredictor
58+
>>> import numpy as np
59+
>>> scores = np.array([[0.8, 0.1, 0.4], [0.2, 0.9, 0.5]])
60+
>>> labels = [[1, 0, 0], [0, 1, 0]]
61+
>>> search_space = [0.1, 0.2, 0.3, 0.5, 0.7]
62+
>>> predictor = AdaptivePredictor(search_space=search_space)
63+
>>> predictor.fit(scores, labels)
64+
>>> predictions = predictor.predict(scores)
65+
>>> print(predictions)
66+
[[1 0 0]
67+
[0 1 0]]
68+
69+
>>> # Save and load the predictor
70+
>>> predictor.dump("path/to/save")
71+
>>> predictor_loaded = AdaptivePredictor()
72+
>>> predictor_loaded.load("path/to/save")
73+
>>> predictions = predictor_loaded.predict(scores)
74+
>>> print(predictions)
75+
[[1 0 0]
76+
[0 1 0]]
4877
"""
4978

5079
metadata_dict_name = "metadata.json"

0 commit comments

Comments
 (0)