-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
27 lines (22 loc) · 837 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import division
import numpy as np
#create list of true labels for generating classifier outputs
#nr_classes: number of possible class labels
#nr_examples_per_class: number of examples we want to generate of each class
#the length of the resulting list is nr_classes x nr_examples_per_class (1,...,1,2,...,2,3,...)
def create_true_labels(nr_classes, nr_examples_per_class):
labels = []
for i in range(nr_classes):
cur_label = i + 1
for j in range(nr_examples_per_class):
labels.append(cur_label)
labels = np.array(labels)
return labels
#fuse according to Independent Opinion Pool
#dists: array of categorical distributions to fuse
#returns the fused categorical distribution
def iop(dists):
prod = 1
for d in dists:
prod *= d
return prod / np.sum(prod)