#NEWLINE# def predict( self , X ) : #NEWLINE# #INDENT# 'Perform classification on test vectors X.\n\n        Parameters\n        ----------\n        X : {array-like, sparse matrix}, shape = [n_samples, n_features]\n            Input vectors, where n_samples is the number of samples\n            and n_features is the number of features.\n\n        Returns\n        -------\n        y : array, shape = [n_samples] or [n_samples, n_outputs]\n            Predicted target values for X.\n        ' #NEWLINE# if ( not hasattr ( self , 'classes_' ) ) : #NEWLINE# #INDENT# raise ValueError ( 'DummyClassifier not fitted.' ) #NEWLINE# #UNINDENT# X = check_array ( X , accept_sparse = [ 'csr' , 'csc' , 'coo' ] ) #NEWLINE# n_samples = int ( X . shape [ 0 ] ) #NEWLINE# rs = check_random_state ( self . random_state ) #NEWLINE# n_classes_ = self . n_classes_ #NEWLINE# classes_ = self . classes_ #NEWLINE# class_prior_ = self . class_prior_ #NEWLINE# constant = self . constant #NEWLINE# if ( self . n_outputs_ == 1 ) : #NEWLINE# #INDENT# n_classes_ = [ n_classes_ ] #NEWLINE# classes_ = [ classes_ ] #NEWLINE# class_prior_ = [ class_prior_ ] #NEWLINE# constant = [ constant ] #NEWLINE# #UNINDENT# if ( self . strategy == 'stratified' ) : #NEWLINE# #INDENT# proba = self . predict_proba ( X ) #NEWLINE# if ( self . n_outputs_ == 1 ) : #NEWLINE# #INDENT# proba = [ proba ] #NEWLINE# #UNINDENT# #UNINDENT# if self . sparse_output_ : #NEWLINE# #INDENT# class_prob = None #NEWLINE# if ( self . strategy in ( 'most_frequent' , 'prior' ) ) : #NEWLINE# #INDENT# classes_ = [ np . array ( [ cp . argmax ( ) ] ) for cp in class_prior_ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'stratified' ) : #NEWLINE# #INDENT# class_prob = class_prior_ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'uniform' ) : #NEWLINE# #INDENT# raise ValueError ( 'Sparse target prediction is not supported with the uniform strategy' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'constant' ) : #NEWLINE# #INDENT# classes_ = [ np . array ( [ c ] ) for c in constant ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# y = random_choice_csc ( n_samples , classes_ , class_prob , self . random_state ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy in ( 'most_frequent' , 'prior' ) ) : #NEWLINE# #INDENT# y = np . tile ( [ classes_ [ k ] [ class_prior_ [ k ] . argmax ( ) ] for k in range ( self . n_outputs_ ) ] , [ n_samples , 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'stratified' ) : #NEWLINE# #INDENT# y = np . vstack ( ( classes_ [ k ] [ proba [ k ] . argmax ( axis = 1 ) ] for k in range ( self . n_outputs_ ) ) ) . T #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'uniform' ) : #NEWLINE# #INDENT# ret = [ classes_ [ k ] [ rs . randint ( n_classes_ [ k ] , size = n_samples ) ] for k in range ( self . n_outputs_ ) ] #NEWLINE# y = np . vstack ( ret ) . T #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . strategy == 'constant' ) : #NEWLINE# #INDENT# y = np . tile ( self . constant , ( n_samples , 1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( self . n_outputs_ == 1 ) and ( not self . output_2d_ ) ) : #NEWLINE# #INDENT# y = np . ravel ( y ) #NEWLINE# #UNINDENT# #UNINDENT# return y