modAL icon indicating copy to clipboard operation
modAL copied to clipboard

Query By Committee with multi-column output prediction

Open somang opened this issue 5 years ago • 1 comments

Hi, I was working on a project which would predict multi-column (multi-category) Y, using Query By Committee function. in learner.py The numpy.unique raised a few issues, and it seemed like if there are different sized arrays, then the numpy.concatenate would raise issues.

For example, My known_classes were: ([array([4.]), array([1., 3.]), array([4.]), array([4., 5.])], [array([3., 4.]), array([1., 4.]), array([3., 4.]), array([4., 5.])]) But then,

Traceback (most recent call last):

File "<__array_function__ internals>", line 6, in concatenate
ValueError: all the input arrays must have same number of dimensions, 
but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s)

Therefore, my workaround was to give a parameter in _set_classes() function and that

        if given_classes.size == 0: # if class definitions are given
            self.classes_ = np.unique(np.concatenate(known_classes, axis=0), axis=0)        
        else:
            self.classes_ = given_classes

so I could simply feed in what my labels would be...

However, it would be great if there can be a more elegant solution to this.

somang avatar Feb 05 '20 22:02 somang

Hey, I have the exact same problem. But I have trouble reproducing your code can you please help me with that

Edit: Thanks got it

0-hero avatar May 24 '20 16:05 0-hero