cblearn.utils.check_query_response#
- cblearn.utils.check_query_response(query, response=None, result_format=None, standard=True)[source]#
Input validation for query formats.
Checks query-response pair for shape and datatype. Converts query from/to list (T-STE style) and tensor (sparse matrix) format. For query list, converts from/to different ordered, boolean or count responses.
- Parameters:
query (ndarray | COO | spmatrix) – Either array_like with index-query or sparse matrix.
response (ndarray | None) – Optional response per index-triplet.
result_format (str | Tuple[QueryFormat, ResponseFormat] | None) – Format of result
standard (bool) – If true, then assures that for every triplet (i, j, k): j < k This is ignored for format=’list-order’.
- Returns:
If format=’tensor-count’, a three-dimensional sparse.COO matrix is returned. The three dimensions all have size ‘n_objects’. The entry query[i, j, k] indicates the response on ij <= jk. It is -1 if wrong, 0 if undecidable, and 1 if correct.
If format=’list-order’, a numpy array of shape (n_samples, 3) is returned. Each row (i, j, k) indicates, ij <= ik.
If format=’list-count’, two numpy arrays are of shape (n_samples, 3) and n_samples are returned. The first array contains index-query (i, j, k). The second array elements represent the response as described above for format=’tensor-count’.
If response_format=’list-boolean’, same as for response_format=’list-count’. The responses are True/False instead of 1/-1.
- Raises:
ValueError – If the array_like input has the wrong shape, or response format cannot be converted. This happens e.g. if undecided (0) responses, should be converted to ordered or boolean responses.
- Return type: