77import inspect
88import textwrap
99from io import StringIO
10- from typing import ClassVar , Dict , Optional , Type , get_type_hints
10+ from typing import Dict , Optional , Type
1111
1212import attr
1313import pandas as pd
@@ -37,7 +37,7 @@ def manage_docstring(obj):
3737 attributes : Dict [str , Annotation ] = {}
3838 new_annotations = {}
3939
40- for key , value in get_type_hints (obj ).items ():
40+ for key , value in getattr (obj , '__annotations__' , {} ).items ():
4141 if isinstance (value , Annotation ):
4242 attributes [key ] = value
4343 if value .type is not None :
@@ -64,37 +64,101 @@ def manage_docstring(obj):
6464 return obj
6565
6666
67- PERFORMERS_SKILLS = Annotation (
68- type = pd .Series ,
69- title = 'Predicted skills for each performer' ,
70- description = textwrap .dedent ("A series of performers' skills indexed by performers" ),
67+ # Input data descriptions
68+
69+
70+ EMBEDDED_DATA = Annotation (
71+ type = pd .DataFrame ,
72+ title = "Performers' outputs with their embeddings" ,
73+ description = 'A pandas.DataFrame containing `task`, `performer`, `output` and `embedding` columns.'
7174)
7275
73- PROBAS = Annotation (
76+ LABELED_DATA = Annotation (
7477 type = pd .DataFrame ,
75- title = 'Estimated label probabilities' ,
78+ title = "Performers' labeling results" ,
79+ description = 'A pandas.DataFrame containing `task`, `performer` and `label` columns.' ,
80+ )
81+
82+
83+ PAIRWISE_DATA = Annotation (
84+ type = pd .DataFrame ,
85+ title = "Performers' pairwise comparison results" ,
7686 description = textwrap .dedent ('''
77- A frame indexed by `task` and a column for every label id found
78- in `data` such that `result.loc[task, label]` is the probability of `task`'s
79- true label to be equal to `label`.
80- ''' ),
87+ A pandas.DataFrame containing `performer`, `left`, `right`, and `label` columns'.
88+ For each row `label` must be equal to either `left` or `right`.
89+ ''' )
8190)
8291
83- PRIORS = Annotation (
92+
93+ # Commonly used types
94+
95+ LABEL_PRIORS = Annotation (
8496 type = pd .Series ,
8597 title = 'A prior label distribution' ,
86- description = "A series of labels' probabilities indexed by labels" ,
98+ description = textwrap .dedent ('''
99+ A pandas.Series indexed by labels and holding corresponding label's
100+ probability of occurrence. Each probability is between 0 and 1,
101+ all probabilities should sum up to 1
102+ ''' ),
103+ )
104+
105+ LABEL_SCORES = Annotation (
106+ type = pd .Series ,
107+ title = "'Labels' scores" ,
108+ description = "A pandas.Series index by labels and holding corresponding label's scores" ,
109+ )
110+
111+ TASKS_EMBEDDINGS = Annotation (
112+ type = pd .DataFrame ,
113+ title = "Tasks' embeddings" ,
114+ description = textwrap .dedent ("A pandas.DataFrame indexed by `task` with a single column `embedding`." ),
87115)
88116
89117TASKS_LABELS = Annotation (
90118 type = pd .DataFrame ,
91- title = 'Estimated labels' ,
119+ title = "Tasks' most likely true labels" ,
92120 description = textwrap .dedent ('''
93- A pandas.DataFrame indexed by `task` with a single column `label` containing
94- ` tasks` 's most probable label for last fitted data, or None otherwise .
121+ A pandas.Series indexed by `task` such that `labels.loc[task]`
122+ is the tasks's most likely true label .
95123 ''' ),
96124)
97125
126+ TASKS_LABEL_PROBAS = Annotation (
127+ type = pd .DataFrame ,
128+ title = "Tasks' true label probability distributions" ,
129+ description = textwrap .dedent ('''
130+ A pandas.DataFrame indexed by `task` such that `result.loc[task, label]`
131+ is the probability of `task`'s true label to be equal to `label`. Each
132+ probability is between 0 and 1, all task's probabilities should sum up to 1
133+ ''' ),
134+ )
135+
136+ TASKS_LABEL_SCORES = Annotation (
137+ type = pd .DataFrame ,
138+ title = "Tasks' true label scores" ,
139+ description = textwrap .dedent ('''
140+ A pandas.DataFrame indexed by `task` such that `result.loc[task, label]`
141+ is the score of `label` for `task`.
142+ ''' ),
143+ )
144+
145+ TASKS_TRUE_LABELS = Annotation (
146+ type = pd .Series ,
147+ title = "Tasks' ground truth labels" ,
148+ description = textwrap .dedent ('''
149+ A pandas.Series indexed by `task` such that `labels.loc[task]`
150+ is the tasks's ground truth label.
151+ ''' ),
152+ )
153+
154+
155+ SKILLS = Annotation (
156+ type = pd .Series ,
157+ title = "Performers' skills" ,
158+ description = "A pandas.Series index by performers and holding corresponding performer's skill" ,
159+ )
160+
161+
98162ERRORS = Annotation (
99163 type = pd .DataFrame ,
100164 title = "Performers' error matrices" ,
@@ -106,19 +170,28 @@ def manage_docstring(obj):
106170 ''' ),
107171)
108172
109- DATA = Annotation (
173+
174+ WEIGHTED_DATA = Annotation (
110175 type = pd .DataFrame ,
111176 title = 'Input data' ,
112- description = 'A pandas.DataFrame containing `task`, `performer` and `label` columns' ,
177+ description = 'A pandas.DataFrame containing `task`, `performer`, `label` and optionally `weight` columns' ,
178+ )
179+
180+ WEIGHTS = Annotation (
181+ type = pd .Series ,
182+ title = 'Task weights' ,
183+ description = 'A pandas.Series indexed by `task` containing task weights'
113184)
114185
115186
116- def _make_opitonal_classlevel (annotation : Annotation ):
117- return attr .evolve (annotation , type = ClassVar [ Optional [annotation .type ] ])
187+ def _make_opitonal (annotation : Annotation ):
188+ return attr .evolve (annotation , type = Optional [annotation .type ])
118189
119190
120- OPTIONAL_CLASSLEVEL_PERFORMERS_SKILLS = _make_opitonal_classlevel (PERFORMERS_SKILLS )
121- OPTIONAL_CLASSLEVEL_PROBAS = _make_opitonal_classlevel (PROBAS )
122- OPTIONAL_CLASSLEVEL_PRIORS = _make_opitonal_classlevel (PRIORS )
123- OPTIONAL_CLASSLEVEL_TASKS_LABELS = _make_opitonal_classlevel (TASKS_LABELS )
124- OPTIONAL_CLASSLEVEL_ERRORS = _make_opitonal_classlevel (ERRORS )
191+ OPTIONAL_SCORES = _make_opitonal (TASKS_LABEL_SCORES )
192+ OPTIONAL_SKILLS = _make_opitonal (SKILLS )
193+ OPTIONAL_PROBAS = _make_opitonal (TASKS_LABEL_PROBAS )
194+ OPTIONAL_PRIORS = _make_opitonal (LABEL_PRIORS )
195+ OPTIONAL_LABELS = _make_opitonal (TASKS_LABELS )
196+ OPTIONAL_ERRORS = _make_opitonal (ERRORS )
197+ OPTIONAL_WEIGHTS = _make_opitonal (WEIGHTS )
0 commit comments