megnet.utils.general module

Operation utilities on lists and arrays

expand_1st(x: numpy.ndarray) → numpy.ndarray[source]

Adding an extra first dimension

Parameters

x – (np.array)

Returns

(np.array)

fast_label_binarize(value: List, labels: List) → List[int][source]

Faster version of label binarize

label_binarize from scikit-learn is slow when run 1 label at a time. label_binarize also is efficient for large numbers of classes, which is not common in megnet

Parameters
  • value – Value to encode

  • labels (list) – Possible class values

Returns

List of integers

Return type

([int])

to_list(x: Union[collections.abc.Iterable, numpy.ndarray]) → List[source]

If x is not a list, convert it to list