def _calc_Q_table(self, label_index, unlabel_index, oracles, pred_unlab, n_neighbors=10, eval_cost=False):
    'Query from oracles. Return the Q table and the oracle name/index of each row of Q_table.\n\n        Parameters\n        ----------\n        label_index: {list, np.ndarray, IndexCollection}\n            The indexes of labeled samples.\n\n        unlabel_index: {list, np.ndarray, IndexCollection}\n            The indexes of unlabeled samples.\n\n        oracles: {list, alipy.oracle.Oracles}\n            An alipy.oracle.Oracle object that contains all the\n            available oracles or a list of oracles.\n            Each oracle should be a alipy.oracle.Oracle object.\n\n        predict: : 2d array, shape [n_samples, n_classes]\n            The probabilistic prediction matrix for the unlabeled set.\n\n        n_neighbors: int, optional (default=10)\n            How many neighbors of the selected instance will be used\n            to evaluate the oracles.\n\n        eval_cost: bool, optional (default=False)\n            To evaluate the cost of oracles or use the cost provided by oracles.\n\n        Returns\n        -------\n        Q_table: 2D array\n            The Q table.\n\n        oracle_ind_name_dict: dict\n            The oracle name/index of each row of Q_table.\n        '
    if ((self.X is None) or (self.y is None)):
        raise Exception('Data matrix is not provided, use select_by_prediction_mat() instead.')
    assert isinstance(unlabel_index, collections.Iterable)
    assert isinstance(label_index, collections.Iterable)
    unlabel_index = np.asarray(unlabel_index)
    label_index = np.asarray(label_index)
    num_of_neighbors = n_neighbors
    if (len(unlabel_index) <= 1):
        return unlabel_index
    Q_table = np.zeros((len(oracles), len(unlabel_index)))
    spv = np.shape(pred_unlab)
    rx = np.partition(pred_unlab, (spv[1] - 1), axis=1)
    rx = (1 - rx[:, (spv[1] - 1)])
    for (unlab_ind, unlab_ins_ind) in enumerate(unlabel_index):
        (nn_dist, nn_of_selected_ins) = self._nntree.kneighbors(X=self.X[unlab_ins_ind].reshape(1, (- 1)), n_neighbors=num_of_neighbors, return_distance=True)
        nn_dist = nn_dist[0]
        nn_of_selected_ins = nn_of_selected_ins[0]
        nn_of_selected_ins = self._ini_ind[nn_of_selected_ins]
        oracles_score = []
        for (ora_ind, ora_name) in enumerate(self._oracles_iterset):
            oracle = oracles[ora_name]
            (labels, cost) = oracle.query_by_index(nn_of_selected_ins)
            oracles_score.append((sum([(nn_dist[i] * (labels[i] == self.y[nn_of_selected_ins[i]])) for i in range(num_of_neighbors)]) / num_of_neighbors))
            (labels, cost) = oracle.query_by_index(label_index)
            if eval_cost:
                oracles_cost = (sum([(labels[i] == self.y[label_index[i]]) for i in range(len(label_index))]) / len(label_index))
            else:
                oracles_cost = cost[0]
            Q_table[(ora_ind, unlab_ind)] = ((oracles_score[ora_ind] * rx[unlab_ind]) / max(oracles_cost, 0.0001))
    return (Q_table, self._oracle_ind_name_dict)
Query from oracles. Return the Q table and the oracle name/index of each row of Q_table.

Parameters
----------
label_index: {list, np.ndarray, IndexCollection}
    The indexes of labeled samples.

unlabel_index: {list, np.ndarray, IndexCollection}
    The indexes of unlabeled samples.

oracles: {list, alipy.oracle.Oracles}
    An alipy.oracle.Oracle object that contains all the
    available oracles or a list of oracles.
    Each oracle should be a alipy.oracle.Oracle object.

predict: : 2d array, shape [n_samples, n_classes]
    The probabilistic prediction matrix for the unlabeled set.

n_neighbors: int, optional (default=10)
    How many neighbors of the selected instance will be used
    to evaluate the oracles.

eval_cost: bool, optional (default=False)
    To evaluate the cost of oracles or use the cost provided by oracles.

Returns
-------
Q_table: 2D array
    The Q table.

oracle_ind_name_dict: dict
    The oracle name/index of each row of Q_table.
def _calc_Q_table(self, label_index, unlabel_index, oracles, pred_unlab, n_neighbors=10, eval_cost=False):
    'Query from oracles. Return the Q table and the oracle name/index of each row of Q_table.\n\n        Parameters\n        ----------\n        label_index: {list, np.ndarray, IndexCollection}\n            The indexes of labeled samples.\n\n        unlabel_index: {list, np.ndarray, IndexCollection}\n            The indexes of unlabeled samples.\n\n        oracles: {list, alipy.oracle.Oracles}\n            An alipy.oracle.Oracle object that contains all the\n            available oracles or a list of oracles.\n            Each oracle should be a alipy.oracle.Oracle object.\n\n        predict: : 2d array, shape [n_samples, n_classes]\n            The probabilistic prediction matrix for the unlabeled set.\n\n        n_neighbors: int, optional (default=10)\n            How many neighbors of the selected instance will be used\n            to evaluate the oracles.\n\n        eval_cost: bool, optional (default=False)\n            To evaluate the cost of oracles or use the cost provided by oracles.\n\n        Returns\n        -------\n        Q_table: 2D array\n            The Q table.\n\n        oracle_ind_name_dict: dict\n            The oracle name/index of each row of Q_table.\n        '
    if ((self.X is None) or (self.y is None)):
        raise Exception('Data matrix is not provided, use select_by_prediction_mat() instead.')
    assert isinstance(unlabel_index, collections.Iterable)
    assert isinstance(label_index, collections.Iterable)
    unlabel_index = np.asarray(unlabel_index)
    label_index = np.asarray(label_index)
    num_of_neighbors = n_neighbors
    if (len(unlabel_index) <= 1):
        return unlabel_index
    Q_table = np.zeros((len(oracles), len(unlabel_index)))
    spv = np.shape(pred_unlab)
    rx = np.partition(pred_unlab, (spv[1] - 1), axis=1)
    rx = (1 - rx[:, (spv[1] - 1)])
    for (unlab_ind, unlab_ins_ind) in enumerate(unlabel_index):
        (nn_dist, nn_of_selected_ins) = self._nntree.kneighbors(X=self.X[unlab_ins_ind].reshape(1, (- 1)), n_neighbors=num_of_neighbors, return_distance=True)
        nn_dist = nn_dist[0]
        nn_of_selected_ins = nn_of_selected_ins[0]
        nn_of_selected_ins = self._ini_ind[nn_of_selected_ins]
        oracles_score = []
        for (ora_ind, ora_name) in enumerate(self._oracles_iterset):
            oracle = oracles[ora_name]
            (labels, cost) = oracle.query_by_index(nn_of_selected_ins)
            oracles_score.append((sum([(nn_dist[i] * (labels[i] == self.y[nn_of_selected_ins[i]])) for i in range(num_of_neighbors)]) / num_of_neighbors))
            (labels, cost) = oracle.query_by_index(label_index)
            if eval_cost:
                oracles_cost = (sum([(labels[i] == self.y[label_index[i]]) for i in range(len(label_index))]) / len(label_index))
            else:
                oracles_cost = cost[0]
            Q_table[(ora_ind, unlab_ind)] = ((oracles_score[ora_ind] * rx[unlab_ind]) / max(oracles_cost, 0.0001))
    return (Q_table, self._oracle_ind_name_dict)