(self, label_index, unlabel_index, model=None, batch_size=1)
return self.select_by_prediction_mat(unlabel_index=unlabel_index, predict=pv,
                                             batch_size=batch_size)
Select indexes from the unlabel_index for querying.

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

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

        model: object, optional (default=None)
            Current classification model, should have the 'predict_proba' method for probabilistic output.
            If not provided, LogisticRegression with default parameters implemented by sklearn will be used.

        batch_size: int, optional (default=1)
            Selection batch size.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
Select indexes from the unlabel_index for querying.
Select indexes from the unlabel_index for querying .
def select(self, label_index, unlabel_index, model=None, batch_size=1):
        """Select indexes from the unlabel_index for querying.

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

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

        model: object, optional (default=None)
            Current classification model, should have the 'predict_proba' method for probabilistic output.
            If not provided, LogisticRegression with default parameters implemented by sklearn will be used.

        batch_size: int, optional (default=1)
            Selection batch size.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
        """
        assert (batch_size > 0)
        assert (isinstance(unlabel_index, collections.Iterable))
        unlabel_index = np.asarray(unlabel_index)
        if len(unlabel_index) <= batch_size:
            return unlabel_index

        # get unlabel_x
        if self.X is None:
            raise Exception('Data matrix is not provided, use select_by_prediction_mat() instead.')
        if model is None:
            model = LogisticRegression(solver='liblinear')
            model.fit(self.X[label_index if isinstance(label_index, (list, np.ndarray)) else label_index.index],
                      self.y[label_index if isinstance(label_index, (list, np.ndarray)) else label_index.index])
        unlabel_x = self.X[unlabel_index, :]
        ##################################
        if self.measure == 'distance_to_boundary':
            if not hasattr(model, 'decision_function'):
                raise TypeError(
                    'model object must implement decision_function methods in distance_to_boundary measure.')
            pv = np.absolute(model.decision_function(unlabel_x))
            spv = np.shape(pv)
            assert (len(spv) in [1, 2])
            if len(spv) == 2:
                if spv[1] != 1:
                    raise Exception('1d or 2d with 1 column array is expected, but received: \n%s' % str(pv))
                else:
                    pv = np.absolute(np.array(pv).flatten())
            return unlabel_index[nsmallestarg(pv, batch_size)]

        pv, _ = _get_proba_pred(unlabel_x, model)
        return self.select_by_prediction_mat(unlabel_index=unlabel_index, predict=pv,
                                             batch_size=batch_size)
def select ( self , label_index , unlabel_index , model = None , batch_size = 1 ) : assert ( batch_size > 0 ) assert ( isinstance ( unlabel_index , collections . Iterable ) ) unlabel_index = np . asarray ( unlabel_index ) if len ( unlabel_index ) <= batch_size : return unlabel_index # get unlabel_x if self . X is None : raise Exception ( 'Data matrix is not provided, use select_by_prediction_mat() instead.' ) if model is None : model = LogisticRegression ( solver = 'liblinear' ) model . fit ( self . X [ label_index if isinstance ( label_index , ( list , np . ndarray ) ) else label_index . index ] , self . y [ label_index if isinstance ( label_index , ( list , np . ndarray ) ) else label_index . index ] ) unlabel_x = self . X [ unlabel_index , : ] ################################## if self . measure == 'distance_to_boundary' : if not hasattr ( model , 'decision_function' ) : raise TypeError ( 'model object must implement decision_function methods in distance_to_boundary measure.' ) pv = np . absolute ( model . decision_function ( unlabel_x ) ) spv = np . shape ( pv ) assert ( len ( spv ) in [ 1 , 2 ] ) if len ( spv ) == 2 : if spv [ 1 ] != 1 : raise Exception ( '1d or 2d with 1 column array is expected, but received: \n%s' % str ( pv ) ) else : pv = np . absolute ( np . array ( pv ) . flatten ( ) ) return unlabel_index [ nsmallestarg ( pv , batch_size ) ] pv , _ = _get_proba_pred ( unlabel_x , model ) return self . select_by_prediction_mat ( unlabel_index = unlabel_index , predict = pv , batch_size = batch_size )