def train(self, binaryLabeledMessageList):
        globalClassifier = self._globalClassifier
        localClassifier = self._localClassifier

        trainLog = ""
        nFolds = 5

        msgList = map(lambda x: x[0], binaryLabeledMessageList)
        y = np.array(
            map(lambda x: 1 if x[1] == 'pos' else 0,
                binaryLabeledMessageList))

        #--- obtain global decision function list
        globalDFList = []
        for msg in msgList:
            v = globalClassifier.predictScore(msg)
            globalDFList.append(v['pos'])

        tt = tic()
        #--- obtain local decision function list (by cross-prediction)
        metaClassifier = None
        if (sum(y) < 2):
            #--- if there are less than 2 positive data points, set alpha=0
            trainLog += "There are less than 2 positive data points. using globalClassifier as the classifier\n"
            localClassifier = None
        else:
            #--- split into 5 and cross-predict decision function
            localDFList = [float('nan')] * len(binaryLabeledMessageList)
            folds = StratifiedKFold(y, nFolds)
            for trainIdx, testIdx in folds:
                train = [binaryLabeledMessageList[i] for i in trainIdx]
                test = [binaryLabeledMessageList[i] for i in testIdx]

                tmpClassifier = copy.deepcopy(localClassifier)
                tmpClassifier.train(train)

                curDFList = []
                for x in test:
                    v = tmpClassifier.predictScore(x[0])
                    curDFList.append(v['pos'])

                for i in range(len(test)):
                    localDFList[testIdx[i]] = curDFList[i]
            assert(countTruth(lambda x: np.isnan(x), localDFList) == 0)

            #--- train SVC!!
            #- prepare X
            X = np.hstack(
                [np.matrix(globalDFList).T,
                 np.matrix(localDFList).T])
            metaClassifier = LinearSVC(
                loss='l2', penalty='l1', dual=False, tol=1e-6,
                random_state=0)
            metaClassifier.fit(X, y)
            trainLog += "Trained a meta classifier:\n"
            coef = metaClassifier.coef_[0]
            trainLog += "  coef for (global, local): (%.6f, %.6f)\n" % (
                coef[0], coef[1])
            trainLog += "  intercept: %.6f\n" % (metaClassifier.intercept_)

            #--- train local classifier using all data
            localClassifier.train(binaryLabeledMessageList)
            trainLog += "Trained a meta classifier"

        elapsed = toc(tt)
        trainLog += "Time taken for training: %.3f (sec)\n" % elapsed

        self._metaClassifier = metaClassifier
        self._trainLog = trainLog

        #--- learn sigmoid
        yDeci = [self.predictScore(msg)['pos']
                 for msg in binaryLabeledMessageList]
        yy = [1 if v == 1 else -1 for v in y]
        [A, B] = platt.SigmoidTrain(yDeci, yy)
        plattModel = [A, B]

        self._plattModel = plattModel
        pass
dataset/ETHPy150Open dssg/ushine-learning/dssg/classifier.py/DssgBinaryClassifierAdaptiveSVC.train/original