(self, label_index, unlabel_index, model=None, batch_size=1)
return unlabel_index[nsmallestarg(scores, 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))
        assert (isinstance(label_index, collections.Iterable))
        unlabel_index = np.asarray(unlabel_index)
        label_index = np.asarray(label_index)
        if len(unlabel_index) <= batch_size:
            return unlabel_index

        # get unlabel_x
        if self.X is None or self.y is None:
            raise Exception('Data matrix is not provided.')
        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]
        label_y = self.y[label_index]
        ##################################

        classes = np.unique(self.y)
        pv, spv = _get_proba_pred(unlabel_x, model)
        scores = []
        for i in range(spv[0]):
            new_train_inds = np.append(label_index, unlabel_index[i])
            new_train_X = self.X[new_train_inds, :]
            unlabel_ind = list(unlabel_index)
            unlabel_ind.pop(i)
            new_unlabel_X = self.X[unlabel_ind, :]
            score = []
            for yi in classes:
                new_model = copy.deepcopy(model)
                new_model.fit(new_train_X, np.append(label_y, yi))
                prob = new_model.predict_proba(new_unlabel_X)
                score.append(pv[i, yi] * self.log_loss(prob))
            scores.append(np.sum(score))

        return unlabel_index[nsmallestarg(scores, batch_size)]
def select ( self , label_index , unlabel_index , model = None , batch_size = 1 ) : assert ( batch_size > 0 ) assert ( isinstance ( unlabel_index , collections . Iterable ) ) assert ( isinstance ( label_index , collections . Iterable ) ) unlabel_index = np . asarray ( unlabel_index ) label_index = np . asarray ( label_index ) if len ( unlabel_index ) <= batch_size : return unlabel_index # get unlabel_x if self . X is None or self . y is None : raise Exception ( 'Data matrix is not provided.' ) 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 ] label_y = self . y [ label_index ] ################################## classes = np . unique ( self . y ) pv , spv = _get_proba_pred ( unlabel_x , model ) scores = [ ] for i in range ( spv [ 0 ] ) : new_train_inds = np . append ( label_index , unlabel_index [ i ] ) new_train_X = self . X [ new_train_inds , : ] unlabel_ind = list ( unlabel_index ) unlabel_ind . pop ( i ) new_unlabel_X = self . X [ unlabel_ind , : ] score = [ ] for yi in classes : new_model = copy . deepcopy ( model ) new_model . fit ( new_train_X , np . append ( label_y , yi ) ) prob = new_model . predict_proba ( new_unlabel_X ) score . append ( pv [ i , yi ] * self . log_loss ( prob ) ) scores . append ( np . sum ( score ) ) return unlabel_index [ nsmallestarg ( scores , batch_size ) ]