#NEWLINE# def output( self , X , mode = 'votes' ) : #NEWLINE# #INDENT# "Returns the output of all classifiers packed in a numpy array.\n       \n        This method calculates the output of each classifier, and stores them\n        in a array-like shape. The specific shape and the meaning of each element\n        is defined by argument `mode`. \n\n        (1) 'labels': each classifier will return a single label prediction\n        for each sample in X, therefore the ensemble output will be a 2d-array\n        of shape (n_samples, n_classifiers), with elements being the class labels.\n\n        (2) 'probs': each classifier will return the posterior probabilities of each\n        class (i.e. instead of returning a single choice it will return the\n        probabilities of each class label being the right one). The ensemble output\n        will be a 3d-array with shape (n_samples, n_classes, n_classifiers), with\n        each element being the probability of a specific class label being right on a\n        given sample according to one the classifiers. This mode can be used with\n        any combination rule.\n\n        (3) 'votes': each classifier will return votes for each class label (i.e.\n        a binary representation, where the chosen class label will have one vote\n        and the other labels will have zero votes. The ensemble output will be\n        a binary 3d-array with shape (n_samples, n_classes, n_classifiers), with\n        the elements being the votes. This mode is mainly used in combining the\n        classifiers output by using majority vote rule.\n\n        Parameters\n        ----------\n        X: array-like, shape = [n_samples, n_features]\n                The test input samples.\n\n        mode: string, optional(default='labels')\n                The type of output given by each classifier.  \n                'labels' | 'probs' | 'votes'\n            \n            \n        " #NEWLINE# if ( mode == 'labels' ) : #NEWLINE# #INDENT# out = np . zeros ( ( X . shape [ 0 ] , len ( self . classifiers ) ) ) #NEWLINE# for ( i , clf ) in enumerate ( self . classifiers ) : #NEWLINE# #INDENT# out [ : , i ] = clf . predict ( X ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# n_classes = len ( self . get_classes ( ) ) #NEWLINE# out = np . zeros ( ( X . shape [ 0 ] , n_classes , len ( self . classifiers ) ) ) #NEWLINE# for ( i , c ) in enumerate ( self . classifiers ) : #NEWLINE# #INDENT# if ( mode == 'probs' ) : #NEWLINE# #INDENT# tmp = c . predict_proba ( X ) #NEWLINE# out [ : , : , c ] = tmp #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( mode == 'votes' ) : #NEWLINE# #INDENT# tmp = c . predict ( X ) #NEWLINE# votes = transform2votes ( tmp , n_classes ) #NEWLINE# out [ : , : , i ] = votes #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return out