peerannot 0.0.1.post38__tar.gz → 0.0.1.post40__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {peerannot-0.0.1.post38/peerannot.egg-info → peerannot-0.0.1.post40}/PKG-INFO +1 -1
  2. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/README.rst +1 -1
  3. peerannot-0.0.1.post40/VERSION.txt +1 -0
  4. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/__init__.py +4 -0
  5. peerannot-0.0.1.post38/peerannot/models/aggregation/Wawa.py → peerannot-0.0.1.post40/peerannot/models/aggregation/IWMV.py +7 -8
  6. peerannot-0.0.1.post40/peerannot/models/aggregation/Wawa.py +38 -0
  7. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/plantnet.py +3 -2
  8. peerannot-0.0.1.post40/peerannot/runners/datasets.py +164 -0
  9. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40/peerannot.egg-info}/PKG-INFO +1 -1
  10. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot.egg-info/SOURCES.txt +2 -0
  11. peerannot-0.0.1.post40/tests/test_filecreation.py +156 -0
  12. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/tests/test_models.py +19 -3
  13. peerannot-0.0.1.post38/VERSION.txt +0 -1
  14. peerannot-0.0.1.post38/peerannot/runners/datasets.py +0 -44
  15. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/LICENSE +0 -0
  16. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/__init__.py +0 -0
  17. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/helpers/__init__.py +0 -0
  18. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/helpers/converters.py +0 -0
  19. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/helpers/helpers_visu.py +0 -0
  20. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/helpers/networks.py +0 -0
  21. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/helpers/simulations_strategies.py +0 -0
  22. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/agg_deep/CoNAL.py +0 -0
  23. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/agg_deep/Crowdlayer.py +0 -0
  24. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/agg_deep/__init__.py +0 -0
  25. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/DS.py +0 -0
  26. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/DS_clust.py +0 -0
  27. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/GLAD.py +0 -0
  28. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/MV.py +0 -0
  29. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/NaiveSoft.py +0 -0
  30. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/WDS.py +0 -0
  31. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/__init__.py +0 -0
  32. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/aggregation/twothird.py +0 -0
  33. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/AUM.py +0 -0
  34. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/Spam_score.py +0 -0
  35. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/WAUM.py +0 -0
  36. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/WAUM_perworker.py +0 -0
  37. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/__init__.py +0 -0
  38. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/entropy.py +0 -0
  39. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/krippendorff_alpha.py +0 -0
  40. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/identification/trace_confusion.py +0 -0
  41. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/models/template.py +0 -0
  42. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/runners/__init__.py +0 -0
  43. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/runners/identify.py +0 -0
  44. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/runners/run.py +0 -0
  45. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/runners/simulate.py +0 -0
  46. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/runners/train.py +0 -0
  47. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/training/__init__.py +0 -0
  48. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot/training/load_data.py +0 -0
  49. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot.egg-info/dependency_links.txt +0 -0
  50. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot.egg-info/entry_points.txt +0 -0
  51. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot.egg-info/requires.txt +0 -0
  52. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/peerannot.egg-info/top_level.txt +0 -0
  53. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/setup.cfg +0 -0
  54. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/setup.py +0 -0
  55. {peerannot-0.0.1.post38 → peerannot-0.0.1.post40}/tests/test_identification.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: peerannot
3
- Version: 0.0.1.post38
3
+ Version: 0.0.1.post40
4
4
  Summary: Crowdsourcing library
5
5
  Download-URL: https://github.com/peerannot/peerannot.git
6
6
  Maintainer: Tanguy Lefort
@@ -166,4 +166,4 @@ The ``dataset.py`` is not mandatory but is here to facilitate the dataset's inst
166
166
  .. |Documentation| image:: https://github.com/peerannot/peerannot.github.io/actions/workflows/deploy-jekyll.yml/badge.svg
167
167
  :target: https://peerannot.github.io
168
168
  .. |Codecov| image:: https://codecov.io/gh/peerannot/peerannot/graph/badge.svg?token=3U77QPSODB
169
- :target: https://codecov.io/gh/peerannot/peerannot
169
+ :target: https://codecov.io/gh/peerannot/peerannot
@@ -0,0 +1 @@
1
+ 0.0.1-40
@@ -6,7 +6,10 @@ from .aggregation.GLAD import GLAD
6
6
  from .aggregation.WDS import WDS
7
7
  from .aggregation.twothird import TwoThird
8
8
  from .aggregation.plantnet import PlantNet
9
+
9
10
  from .aggregation.Wawa import Wawa
11
+ from .aggregation.IWMV import IWMV
12
+
10
13
  from .identification.WAUM_perworker import WAUM_perworker
11
14
  from .identification.WAUM import WAUM
12
15
  from .identification.AUM import AUM
@@ -26,6 +29,7 @@ agg_strategies = {
26
29
  "WDS": WDS,
27
30
  "PlantNet": PlantNet,
28
31
  "TwoThird": TwoThird,
32
+ "IWMV": IWMV,
29
33
  "Wawa": Wawa,
30
34
  }
31
35
 
@@ -4,16 +4,13 @@ Majority voting
4
4
  =========================
5
5
  Most answered label per task
6
6
  """
7
+
7
8
  from ..template import CrowdModel
8
9
  import numpy as np
9
10
  from tqdm.auto import tqdm
10
11
 
11
- # implementatio of
12
- # https://github.com/Toloka/crowd-kit/blob/v1.2.1/crowdkit/aggregation/classification/wawa.py
13
- # that takes into account large sparse datasets
14
-
15
12
 
16
- class Wawa(CrowdModel):
13
+ class IWMV(CrowdModel):
17
14
  def __init__(self, answers, n_classes=2, sparse=False, **kwargs):
18
15
  super().__init__(answers)
19
16
  self.n_classes = n_classes
@@ -63,7 +60,7 @@ class Wawa(CrowdModel):
63
60
  def accuracy_by_mv(self):
64
61
  worker_score = np.zeros(self.n_workers)
65
62
  worker_n_ans = np.zeros(self.n_workers)
66
- for (task_id, mv_lab) in zip(self.answers.keys(), self.ans):
63
+ for task_id, mv_lab in zip(self.answers.keys(), self.ans):
67
64
  for worker, lab in self.answers[task_id].items():
68
65
  if int(lab) == mv_lab:
69
66
  worker_score[int(worker)] += 1
@@ -76,10 +73,12 @@ class Wawa(CrowdModel):
76
73
  )
77
74
  self.worker_score = worker_score
78
75
 
79
- def run(self, **kwargs):
76
+ def run(self, nb_iter=10, **kwargs):
80
77
  self.MV(weight=np.ones(self.n_workers))
81
78
  self.accuracy_by_mv()
82
- self.MV(weight=self.worker_score)
79
+ for _ in range(nb_iter):
80
+ self.MV(weight=self.worker_score)
81
+ self.accuracy_by_mv()
83
82
 
84
83
  def get_answers(self):
85
84
  """Get labels obtained with majority voting aggregation
@@ -0,0 +1,38 @@
1
+ """
2
+ =========================
3
+ Majority voting
4
+ =========================
5
+ Most answered label per task
6
+ """
7
+
8
+ from ..aggregation.IWMV import IWMV
9
+ import numpy as np
10
+ from tqdm.auto import tqdm
11
+
12
+ # implementatio of
13
+ # https://github.com/Toloka/crowd-kit/blob/v1.2.1/crowdkit/aggregation/classification/wawa.py
14
+ # that takes into account large sparse datasets
15
+
16
+
17
+ class Wawa(IWMV):
18
+ def __init__(self, answers, n_classes=2, sparse=False, **kwargs):
19
+ super().__init__(answers, n_classes, sparse, **kwargs)
20
+
21
+ def run(self, **kwargs):
22
+ super().run(1, **kwargs)
23
+
24
+ def get_answers(self):
25
+ """Get labels obtained with majority voting aggregation
26
+
27
+ :return: Most answered labels per task
28
+ :rtype: numpy.ndarray
29
+ """
30
+ return np.array(self.ans)
31
+
32
+ def get_probas(self):
33
+ """Get labels obtained with majority voting aggregation
34
+
35
+ :return: Most answered labels per task
36
+ :rtype: numpy.ndarray
37
+ """
38
+ return self.get_answers()
@@ -3,6 +3,7 @@
3
3
  PlantNet consensus
4
4
  ===================================
5
5
  """
6
+
6
7
  from ..template import CrowdModel
7
8
  import numpy as np
8
9
  import warnings
@@ -99,7 +100,7 @@ class PlantNet(CrowdModel):
99
100
  self.n_classes = n_classes
100
101
  self.authors = authors
101
102
  if self.authors is None:
102
- self.authors = -np.ones(self.n_workers)
103
+ self.authors = -np.ones(len(self.answers), dtype=int)
103
104
  else:
104
105
  self.authors = np.loadtxt(self.authors, dtype=int)
105
106
  if kwargs.get("dataset", None):
@@ -227,7 +228,7 @@ class PlantNet(CrowdModel):
227
228
  self.get_n(valid, init_yhat)
228
229
  if np.sum(np.abs(self.n_j - n_j)) / self.n_task <= epsilon and step > 5:
229
230
  break
230
- self.labels_hat = yhat
231
+ self.labels_hat = yhat if maxiter > 1 else init_yhat
231
232
  self.valid = valid
232
233
  self.weights = weights
233
234
  self.conf = conf
@@ -0,0 +1,164 @@
1
+ # based on https://benchopt.github.io CLI
2
+ import click
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import importlib.util
6
+ import inspect
7
+ import sys
8
+
9
+ datasets = click.Group(
10
+ name="Running peerannot datasets",
11
+ help="Commands related to datasets that can be used with the PeerAnnot library",
12
+ )
13
+
14
+
15
+ @datasets.command(
16
+ help="Install dataset from `.py` file",
17
+ epilog="""Each dataset is a folder with:
18
+
19
+ \b
20
+ - name.py: python file containing how to download and format data
21
+ - answers.json: json file containing each task voted labels
22
+ - metadata.json: all metadata for dataset, at least the name, n_task and n_classes""",
23
+ )
24
+ @click.argument(
25
+ "path",
26
+ type=click.Path(),
27
+ )
28
+ @click.option(
29
+ "--no-task",
30
+ is_flag=True,
31
+ help="True if no task is associated with the dataset",
32
+ # (only an answers file as in the krippendorff example dataset)
33
+ )
34
+ @click.option(
35
+ "--answers-format",
36
+ default=0,
37
+ type=click.INT,
38
+ help="annotation file format",
39
+ # 0 == Rodrigues matrix format, 1 == JSON answers/worker format, 2 == JSON worker/answers format
40
+ )
41
+ @click.option(
42
+ "--answers",
43
+ default="",
44
+ type=click.Path(exists=False),
45
+ help="annotation file",
46
+ )
47
+ @click.option(
48
+ "--metadata",
49
+ default="",
50
+ type=click.Path(exists=False),
51
+ help="metadata information file",
52
+ )
53
+ @click.option(
54
+ "--label-names",
55
+ default="",
56
+ type=click.Path(exists=False),
57
+ help="path to label names files",
58
+ )
59
+ @click.option(
60
+ "--files-path",
61
+ default="",
62
+ type=click.Path(exists=False),
63
+ help="path to train filenames",
64
+ )
65
+ @click.option(
66
+ "--train-path",
67
+ default="",
68
+ type=click.Path(exists=False),
69
+ help="path to train data",
70
+ )
71
+ @click.option(
72
+ "--test-ground-truth-format",
73
+ default=-1,
74
+ type=click.INT,
75
+ help="annotation file format",
76
+ # 0 == Rodrigues matrix format, 1 == JSON answers/worker format, 2 == JSON worker/answers format
77
+ )
78
+ @click.option(
79
+ "--test-ground-truth",
80
+ default="",
81
+ type=click.Path(exists=False),
82
+ help="test ground truth file",
83
+ )
84
+ @click.option(
85
+ "--test-path",
86
+ default="",
87
+ type=click.Path(exists=False),
88
+ help="path to test data",
89
+ )
90
+ @click.option(
91
+ "--val-path",
92
+ default="",
93
+ type=click.Path(exists=False),
94
+ help="path to val data",
95
+ )
96
+ def install(
97
+ path,
98
+ no_task,
99
+ answers_format,
100
+ answers,
101
+ metadata,
102
+ label_names,
103
+ files_path,
104
+ train_path,
105
+ test_ground_truth_format,
106
+ test_ground_truth,
107
+ test_path,
108
+ val_path,
109
+ ):
110
+ """Download and install dataset
111
+
112
+ :param path: path to python file including the class with method `setfolders` to install the data
113
+ :type path: click.Path
114
+ """
115
+ pathFilename = Path(path).resolve().as_posix().split("/")[-1].split(".")[0]
116
+ if pathFilename == "customDataset":
117
+ if not no_task:
118
+ if train_path == "":
119
+ click.echo("Please provide a valid train path")
120
+ sys.exit(1)
121
+ if files_path == "":
122
+ click.echo("Please provide a valid filenames path")
123
+ sys.exit(1)
124
+ if answers == "":
125
+ click.echo("Please provide a valid answers file")
126
+ sys.exit(1)
127
+ if test_ground_truth_format == -1:
128
+ test_ground_truth_format = answers_format
129
+
130
+ spec = importlib.util.spec_from_file_location("dataset", path)
131
+ mydata = importlib.util.module_from_spec(spec)
132
+ sys.modules["dataset"] = mydata
133
+ spec.loader.exec_module(mydata)
134
+ mm = [
135
+ (name, cls)
136
+ for name, cls in inspect.getmembers(mydata, inspect.isclass)
137
+ if cls.__module__ == "dataset"
138
+ ][0]
139
+ df = mm[1]()
140
+ df.setfolders(
141
+ no_task,
142
+ answers_format,
143
+ answers,
144
+ metadata,
145
+ label_names,
146
+ files_path,
147
+ train_path,
148
+ test_ground_truth_format,
149
+ test_ground_truth,
150
+ test_path,
151
+ val_path,
152
+ )
153
+ else:
154
+ spec = importlib.util.spec_from_file_location("dataset", path)
155
+ mydata = importlib.util.module_from_spec(spec)
156
+ sys.modules["dataset"] = mydata
157
+ spec.loader.exec_module(mydata)
158
+ mm = [
159
+ (name, cls)
160
+ for name, cls in inspect.getmembers(mydata, inspect.isclass)
161
+ if cls.__module__ == "dataset"
162
+ ][0]
163
+ df = mm[1]()
164
+ df.setfolders()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: peerannot
3
- Version: 0.0.1.post38
3
+ Version: 0.0.1.post40
4
4
  Summary: Crowdsourcing library
5
5
  Download-URL: https://github.com/peerannot/peerannot.git
6
6
  Maintainer: Tanguy Lefort
@@ -23,6 +23,7 @@ peerannot/models/agg_deep/__init__.py
23
23
  peerannot/models/aggregation/DS.py
24
24
  peerannot/models/aggregation/DS_clust.py
25
25
  peerannot/models/aggregation/GLAD.py
26
+ peerannot/models/aggregation/IWMV.py
26
27
  peerannot/models/aggregation/MV.py
27
28
  peerannot/models/aggregation/NaiveSoft.py
28
29
  peerannot/models/aggregation/WDS.py
@@ -46,5 +47,6 @@ peerannot/runners/simulate.py
46
47
  peerannot/runners/train.py
47
48
  peerannot/training/__init__.py
48
49
  peerannot/training/load_data.py
50
+ tests/test_filecreation.py
49
51
  tests/test_identification.py
50
52
  tests/test_models.py
@@ -0,0 +1,156 @@
1
+ import numpy as np
2
+ from pathlib import Path
3
+ import os
4
+ import os.path
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+
9
+
10
+ dir_toydata = Path(__file__).parents[1] / "datasets" / "toy-data"
11
+
12
+
13
+ def verify_json(path):
14
+ with open(path, "r") as f:
15
+ answers = json.load(f)
16
+
17
+ with open(dir_toydata / "answers.json", "r") as f:
18
+ answers_sure = json.load(f)
19
+
20
+ assert answers == answers_sure
21
+
22
+
23
+ def test_custom_creation():
24
+ dir_train = dir_toydata / "train"
25
+ dir_test = dir_toydata / "test"
26
+ dir_val = dir_toydata / "val"
27
+ dir_temp = dir_toydata / "temp"
28
+
29
+ # Test the answers txt format (Rodrigues matrix format), with a test set and a val set
30
+ os.makedirs(dir_temp)
31
+ currentPath = Path(__file__).parents[1] / "datasets" / "customDataset.py"
32
+ result = subprocess.run(
33
+ [
34
+ "peerannot",
35
+ "install",
36
+ Path(__file__).parents[1] / "datasets" / "customDataset.py",
37
+ "--train-path",
38
+ dir_train,
39
+ "--test-path",
40
+ dir_test,
41
+ "--val-path",
42
+ dir_val,
43
+ "--answers",
44
+ dir_toydata / "answers.txt",
45
+ "--files-path",
46
+ dir_toydata / "filenames.txt",
47
+ "--label-names",
48
+ dir_toydata / "labelNames.txt",
49
+ ],
50
+ capture_output=True,
51
+ cwd=dir_temp,
52
+ )
53
+ nb_files = len([name for name in os.listdir(dir_temp)])
54
+ assert nb_files == 6
55
+
56
+ nb_labels = len([name for name in os.listdir(dir_temp / "train")])
57
+ assert nb_labels == 2
58
+
59
+ nb_data = len([name for name in os.listdir(dir_temp / "train" / "smiles")])
60
+ assert nb_data == 2
61
+
62
+ verify_json(dir_temp / "answers.json")
63
+ shutil.rmtree(dir_temp) # cleanup
64
+
65
+ ############################################################################
66
+
67
+ # Test the Peerannot answers format (task->worker), with a train and no val and test set
68
+ os.makedirs(dir_temp)
69
+ result = subprocess.run(
70
+ [
71
+ "peerannot",
72
+ "install",
73
+ Path(__file__).parents[1] / "datasets" / "customDataset.py",
74
+ "--train-path",
75
+ dir_train,
76
+ "--answers-format",
77
+ "1",
78
+ "--files-path",
79
+ dir_toydata / "filenames.txt",
80
+ "--answers",
81
+ dir_toydata / "answers.json",
82
+ "--label-names",
83
+ dir_toydata / "labelNames.txt",
84
+ ],
85
+ capture_output=True,
86
+ cwd=dir_temp,
87
+ )
88
+ nb_files = len(
89
+ [
90
+ name
91
+ for name in os.listdir(dir_temp)
92
+ # if os.path.isfile(os.path.join(dir_temp, name))
93
+ ]
94
+ )
95
+ assert nb_files == 4
96
+ verify_json(dir_temp / "answers.json")
97
+ shutil.rmtree(dir_temp) # cleanup
98
+
99
+ ############################################################################
100
+
101
+ # Test the Peerannot answers format (task->worker), with a test, train and no val set
102
+ os.makedirs(dir_temp)
103
+ result = subprocess.run(
104
+ [
105
+ "peerannot",
106
+ "install",
107
+ Path(__file__).parents[1] / "datasets" / "customDataset.py",
108
+ "--train-path",
109
+ dir_train,
110
+ "--test-path",
111
+ dir_test,
112
+ "--answers-format",
113
+ "1",
114
+ "--answers",
115
+ dir_toydata / "answers.json",
116
+ "--label-names",
117
+ dir_toydata / "labelNames.txt",
118
+ "--files-path",
119
+ dir_toydata / "filenames.txt",
120
+ ],
121
+ capture_output=True,
122
+ cwd=dir_temp,
123
+ )
124
+ verify_json(dir_temp / "answers.json")
125
+ shutil.rmtree(dir_temp) # cleanup
126
+
127
+ ############################################################################
128
+
129
+ # Test the Peerannot inverse answers format (worker->task), with no sets
130
+ os.makedirs(dir_temp)
131
+ result = subprocess.run(
132
+ [
133
+ "peerannot",
134
+ "install",
135
+ Path(__file__).parents[1] / "datasets" / "customDataset.py",
136
+ "--answers-format",
137
+ "2",
138
+ "--answers",
139
+ dir_toydata / "answers_inversed.json",
140
+ "--no-task",
141
+ ],
142
+ capture_output=True,
143
+ cwd=dir_temp,
144
+ )
145
+ nb_files = len(
146
+ [
147
+ name
148
+ for name in os.listdir(dir_temp)
149
+ # if os.path.isfile(os.path.join(dir_temp, name))
150
+ ]
151
+ )
152
+ assert nb_files == 1
153
+
154
+ verify_json(dir_temp / "answers.json")
155
+ shutil.rmtree(dir_temp) # cleanup
156
+ # assert True == False
@@ -19,7 +19,7 @@ def test_mv():
19
19
  from peerannot.models import MV
20
20
 
21
21
  for sparse_ in sparse:
22
- mv = MV(ANSWERS, n_classses=2, sparse=sparse_)
22
+ mv = MV(ANSWERS, n_classes=2, sparse=sparse_)
23
23
  y = mv.get_answers()
24
24
  expected = np.array([1, 0, 1])
25
25
  assert all([e == y_ for e, y_ in zip(expected, y)])
@@ -55,12 +55,28 @@ def test_wawa():
55
55
 
56
56
  sparse = [True, False]
57
57
  for sparse_ in sparse:
58
- wawa = Wawa(ANSWERS, n_classses=2, n_workers=4, sparse=sparse_)
58
+ wawa = Wawa(ANSWERS, n_classes=2, n_workers=4, sparse=sparse_)
59
59
  wawa.run()
60
60
  y = wawa.get_answers()
61
61
  expected = np.array([1, 0, 1])
62
62
  assert np.isclose((wawa.worker_score - np.array([1 / 2, 1, 1, 1 / 2])).sum(), 0)
63
63
  assert all([e == y_ for e, y_ in zip(expected, y)])
64
+ # assert True == False
65
+
66
+
67
+ def test_IWMV():
68
+ from peerannot.models import IWMV
69
+
70
+ sparse = [True, False]
71
+ for sparse_ in sparse:
72
+ wawa_it = IWMV(ANSWERS, n_classes=2, n_workers=4, sparse=sparse_)
73
+ wawa_it.run(10)
74
+ y = wawa_it.get_answers()
75
+ expected = np.array([1, 0, 1])
76
+ assert np.isclose(
77
+ (wawa_it.worker_score - np.array([1 / 2, 1, 1, 1 / 2])).sum(), 0
78
+ )
79
+ assert all([e == y_ for e, y_ in zip(expected, y)])
64
80
 
65
81
 
66
82
  def test_twothird():
@@ -68,7 +84,7 @@ def test_twothird():
68
84
 
69
85
  sparse = [True, False]
70
86
  for sparse_ in sparse:
71
- two = TwoThird(ANSWERS, n_classses=2, n_workers=4, sparse=sparse_)
87
+ two = TwoThird(ANSWERS, n_classes=2, n_workers=4, sparse=sparse_)
72
88
  y = two.get_answers()
73
89
  expected = np.array([1, 0, 1])
74
90
  assert all([e == y_ for e, y_ in zip(expected, y)])
@@ -1 +0,0 @@
1
- 0.0.1-38
@@ -1,44 +0,0 @@
1
- # based on https://benchopt.github.io CLI
2
- import click
3
- from pathlib import Path
4
- import numpy as np
5
- import importlib.util
6
- import inspect
7
- import sys
8
-
9
- datasets = click.Group(
10
- name="Running peerannot datasets",
11
- help="Commands related to datasets that can be used with the PeerAnnot library",
12
- )
13
-
14
-
15
- @datasets.command(
16
- help="Install dataset from `.py` file",
17
- epilog="""Each dataset is a folder with:
18
-
19
- \b
20
- - name.py: python file containing how to download and format data
21
- - answers.json: json file containing each task voted labels
22
- - metadata.json: all metadata for dataset, at least the name, n_task and n_classes""",
23
- )
24
- @click.argument(
25
- "path",
26
- type=click.Path(),
27
- )
28
- def install(path):
29
- """Download and install dataset
30
-
31
- :param path: path to python file including the class with method `setfolders` to install the data
32
- :type path: click.Path
33
- """
34
- spec = importlib.util.spec_from_file_location("dataset", path)
35
- mydata = importlib.util.module_from_spec(spec)
36
- sys.modules["dataset"] = mydata
37
- spec.loader.exec_module(mydata)
38
- mm = [
39
- (name, cls)
40
- for name, cls in inspect.getmembers(mydata, inspect.isclass)
41
- if cls.__module__ == "dataset"
42
- ][0]
43
- df = mm[1]()
44
- df.setfolders()