(self, X)
return [predicted_label, { 'results' : results }]
Args:
        
            X: The query image, which is an array.
        
        Returns:
        
            A list with the classifier output. In this framework it is
            assumed, that the predicted class is always returned as first
            element. Moreover, this class returns the libsvm output for
            p_labels, p_acc and p_vals. The libsvm help states:
            
                p_labels: a list of predicted labels
                p_acc: a tuple including  accuracy (for classification), mean-squared 
                   error, and squared correlation coefficient (for regression).
                p_vals: a list of decision values or probability estimates (if '-b 1' 
                    is specified). If k is the number of classes, for decision values,
                    each element includes results of predicting k(k-1)/2 binary-class
                    SVMs. For probabilities, each element contains k values indicating
                    the probability that the testing instance is in each class.
                    Note that the order of classes here is the same as 'model.label'
                    field in the model structure.
Args:
        
            X: The query image, which is an array.
        
        Returns:
        
            A list with the classifier output. In this framework it is
            assumed, that the predicted class is always returned as first
            element. Moreover, this class returns the libsvm output for
            p_labels, p_acc and p_vals. The libsvm help states:
            
                p_labels: a list of predicted labels
                p_acc: a tuple including  accuracy (for classification), mean-squared 
                   error, and squared correlation coefficient (for regression).
                p_vals: a list of decision values or probability estimates (if '-b 1' 
                    is specified). If k is the number of classes, for decision values,
                    each element includes results of predicting k(k-1)/2 binary-class
                    SVMs. For probabilities, each element contains k values indicating
                    the probability that the testing instance is in each class.
                    Note that the order of classes here is the same as 'model.label'
                    field in the model structure.
Args : X : The query image which is an array . Returns : A list with the classifier output . In this framework it is assumed that the predicted class is always returned as first element . Moreover this class returns the libsvm output for p_labels p_acc and p_vals . The libsvm help states : p_labels : a list of predicted labels p_acc : a tuple including accuracy ( for classification ) mean - squared error and squared correlation coefficient ( for regression ) . p_vals : a list of decision values or probability estimates ( if - b 1 is specified ) . If k is the number of classes for decision values each element includes results of predicting k ( k - 1 ) / 2 binary - class SVMs . For probabilities each element contains k values indicating the probability that the testing instance is in each class . Note that the order of classes here is the same as model . label field in the model structure .
def predict(self, X):
        """
        
        Args:
        
            X: The query image, which is an array.
        
        Returns:
        
            A list with the classifier output. In this framework it is
            assumed, that the predicted class is always returned as first
            element. Moreover, this class returns the libsvm output for
            p_labels, p_acc and p_vals. The libsvm help states:
            
                p_labels: a list of predicted labels
                p_acc: a tuple including  accuracy (for classification), mean-squared 
                   error, and squared correlation coefficient (for regression).
                p_vals: a list of decision values or probability estimates (if '-b 1' 
                    is specified). If k is the number of classes, for decision values,
                    each element includes results of predicting k(k-1)/2 binary-class
                    SVMs. For probabilities, each element contains k values indicating
                    the probability that the testing instance is in each class.
                    Note that the order of classes here is the same as 'model.label'
                    field in the model structure.
        """
        # Turn the image into a row-vector:
        X = np.asarray(X).reshape(1,-1)
        # Predict the Probability:
        results = self.svm.predict_proba(X)[0]
        # Sorts the classes by probability:
        results_ordered_by_probability = map(lambda x: x[0], sorted(zip(self.svm.classes_, results), key=lambda x: x[1], reverse=True))
        # Take the first item as the predicted label:
        predicted_label = int(results_ordered_by_probability[0])

        return [predicted_label, { 'results' : results }]
def predict ( self , X ) : # Turn the image into a row-vector: X = np . asarray ( X ) . reshape ( 1 , - 1 ) # Predict the Probability: results = self . svm . predict_proba ( X ) [ 0 ] # Sorts the classes by probability: results_ordered_by_probability = map ( lambda x : x [ 0 ] , sorted ( zip ( self . svm . classes_ , results ) , key = lambda x : x [ 1 ] , reverse = True ) ) # Take the first item as the predicted label: predicted_label = int ( results_ordered_by_probability [ 0 ] ) return [ predicted_label , { 'results' : results } ]