entropy module

class datumaro.plugins.sampler.algorithm.entropy.SampleEntropy(data, inference)[source]

Entropy is a class that inherits an Sampler, calculates an uncertainty score based on an entropy, and get samples based on that score.

__init__(data, inference)[source]

Constructor function

Parameters
  • data – Receive the data format in pd.DataFrame format. ImageID is an essential element for data.

  • inference – Receive the inference format in the form of pd.DataFrame. ImageID and ClassProbability are essential for inferences.

get_sample(method: str, k: int, n: int = 3) pandas.core.frame.DataFrame[source]

A function that extracts sample data and returns it.

Parameters
  • method

    • ‘topk’ - It extracts the k sample data with the highest uncertainty.

    • ’lowk’ - It extracts the k sample data with the lowest uncertainty.

    • ’randomk’ - Extract and return random k sample data.

  • k – number of sample data

  • n – Parameters to be used in the randtopk method, Variable to first extract data of multiple n of k.

Returns

pd.DataFrame

Return type

Extracted sample data

_get_sample_mixed(method: str, k: int, n: int = 3) pandas.core.frame.DataFrame[source]

A function that extracts sample data and returns it.

Parameters
  • method

    • ‘mixk’: Return top-k and low-k halves based on uncertainty.

    • ’randomtopk’: Randomly extract n*k and return k with high uncertainty.

  • k – number of sample data

  • n – Number to extract n * k from total data according to n, and top-k from it

Returns

pd.DataFrame

Return type

Extracted sample data

_rank_images() pandas.core.frame.DataFrame[source]

A internal function that ranks the inference data based on uncertainty. :returns: inference data sorted by uncertainty. pd.DataFrame