ranking/pu_learning.py
def score(self, websites): 
        """
        Note: Use all unlabelled websites as negatives but no more than 20x the positives """
        """
        neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
        neg = self._convert_to_svmlight(neg, -1)

        if not self.model:
            max_neg = min(20*len(self.pos), len(neg))
            train = neg[:max_neg]
            print "Number of unlabelled examples: ", len(train)
            print "Training the classifier..."
            train.extend(self.pos) 
            self.model = svmlight.learn(train, type='classification', verbosity=0, cost_ratio=self.cost_ratio, C=self.c)
        """
        print "Scoring..."
        if not self.clf:
            print "Error. Classifier must be trained"
        test = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
        test = self._convert_to_svmlight(test, -1) # The label does not matter 
        predicts = svmlight.classify(self.clf, test)
        results = [(websites[i], predicts[i]) for i in xrange(len(websites))]
        return results

        Note: Use all unlabelled websites as negatives but no more than 20x the positives 
Use all unlabelled websites as negatives but no more than 20x the positives
Use all unlabelled websites as negatives but no more than 20x the positives
def score(self, websites): 
        print "Scoring..."
        if not self.clf:
            print "Error. Classifier must be trained"
        test = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
        test = self._convert_to_svmlight(test, -1) 
        predicts = svmlight.classify(self.clf, test)
        results = [(websites[i], predicts[i]) for i in xrange(len(websites))]
        return results
def score ( self , websites ) : """
        neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
        neg = self._convert_to_svmlight(neg, -1)

        if not self.model:
            max_neg = min(20*len(self.pos), len(neg))
            train = neg[:max_neg]
            print "Number of unlabelled examples: ", len(train)
            print "Training the classifier..."
            train.extend(self.pos) 
            self.model = svmlight.learn(train, type='classification', verbosity=0, cost_ratio=self.cost_ratio, C=self.c)
        """ print "Scoring..." if not self . clf : print "Error. Classifier must be trained" test = np . array ( [ w . get_vsm ( self . vectorizer , self . text_type ) for w in websites ] ) test = self . _convert_to_svmlight ( test , - 1 ) predicts = svmlight . classify ( self . clf , test ) results = [ ( websites [ i ] , predicts [ i ] ) for i in xrange ( len ( websites ) ) ] return results
Note: Use all unlabelled websites as negatives but no more than 20x the positives
Note : Use all unlabelled websites as negatives but no more than 20x the positives
"""
        Note: Use all unlabelled websites as negatives but no more than 20x the positives """ """
        neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
        neg = self._convert_to_svmlight(neg, -1)

        if not self.model:
            max_neg = min(20*len(self.pos), len(neg))
            train = neg[:max_neg]
            print "Number of unlabelled examples: ", len(train)
            print "Training the classifier..."
            train.extend(self.pos) 
            self.model = svmlight.learn(train, type='classification', verbosity=0, cost_ratio=self.cost_ratio, C=self.c)
        """ # The label does not matter 
self
websites