Exemplo n.º 1
0
    def run_LR(self, rundir=None):
        """ Demo script that evaluates the supervised prediction
            performance of the p(t|d) (stored in theta.npy) of
            an the LDA model in `rundir`.
        """

        if not rundir:
            rundir = self.rundir

        ( (trainX,trainY,train_ids), (testX, testY,test_ids) ) = load_data(rundir, dataset=NIPSDIR)
        allX = np.vstack((trainX,testX))
        allY = np.concatenate((trainY,testY))

        if not self.LRparams:
            self.grid_search(allX,allY)

        lr = logistic_regression.train_lrpipe(trainX, trainY, self.LRparams)

        allLabels = load_labels(NIPSDIR)
        allTitles = load_titles(NIPSDIR)
        evaluate(lr, testX, testY, testTitles=allTitles[test_ids], testLabels=allLabels[test_ids])
Exemplo n.º 2
0
    def run_SVM(self, rundir=None):
        """ Demo script that evaluates the supervised prediction
            performance of the p(t|d) (stored in theta.npy) of
            an the LDA model in `rundir`.
        """

        if not rundir:
            rundir = self.rundir

        ( (trainX,trainY,train_ids), (testX, testY,test_ids) ) = load_data(rundir, dataset=NIPSDIR)
        allX = np.vstack((trainX,testX))
        allY = np.concatenate((trainY,testY))

        if not self.SVMparams:
            self.grid_search(allX,allY)

        sv = support_vector_machines.train_svpipe(trainX, trainY, self.SVMparams)

        allLabels = load_labels(NIPSDIR)
        allTitles = load_titles(NIPSDIR)
        evaluate(sv, testX, testY, testTitles=allTitles[test_ids], testLabels=allLabels[test_ids])