Oracles (skquery.oracle)

This module contains simple oracles that answer the queries made by active clustering algorithms. They can be used either for direct interaction with a user, or for producing automated answers based on a labeling of the data.

class skquery.oracle.MLCLOracle(budget=10, truth=None)[source]

Oracle for pairwise queries.

Parameters

budgetint, default=10

Maximum number of queries the oracle will answer.

trutharray-like, default=None

Ground truth labeling that emulates a human oracle.

Attributes

queriesint

Number of queries answered by the oracle so far.

budgetint

Maximum number of queries the oracle will answer.

trutharray-like, default=None

Ground truth labeling that emulates a human oracle.

query(i, j)[source]

Query the oracle to find out whether two points should be in the same cluster.

Parameters

iint

Index of first data point.

jint

Index of second data point.

Returns

answerbool

Answer to the query.

Raises

NoAnswerError

If the oracle doesn’t give an answer, i.e. they don’t know what to answer.

class skquery.oracle.TripletOracle(budget=10, truth=None)[source]

Oracle for triplet queries. Inspired from the formalization in [1].

Parameters

budgetint, default=10

Maximum number of queries the oracle will answer.

trutharray-like, default=None

Ground truth labeling that emulates a human oracle.

Attributes

queriesint

Number of queries answered by the oracle so far.

budgetint

Maximum number of queries the oracle will answer.

trutharray-like, default=None

Ground truth labeling that emulates a human oracle.

References

[1] Xiong, S., Pei, Y., Rosales, R., Fern, X. Z. Active Learning from Relative Comparisons, IEEE Transactions on Knowledge and Data Engineering, vol. 27, nᵒ 12, p. 3166‑3175, dec. 2015, doi: 10.1109/TKDE.2015.2462365.

query(i, j, k)[source]

Query the oracle on the relation between a triplet of points.

Parameters

iint

Index of first data point, the reference.

jint

Index of second data point, the assumed positive example.

kint

Index of third data point, the assumed negative example.

Returns

answerbool

Answer to the query.

Raises

NoAnswerError

If the oracle doesn’t give an answer, i.e. they don’t know what to answer.