#NEWLINE# def fit( self , X , y , sample_weight = None ) : #NEWLINE# #INDENT# 'Fit the model according to the given training data.\n\n        Parameters\n        ----------\n        X : {array-like, sparse matrix}, shape (n_samples, n_features)\n            Training vector, where n_samples in the number of samples and\n            n_features is the number of features.\n\n        y : array-like, shape (n_samples,)\n            Target vector relative to X.\n\n        sample_weight : array-like, shape (n_samples,) optional\n            Array of weights that are assigned to individual samples.\n            If not provided, then each sample is given unit weight.\n\n            .. versionadded:: 0.17\n               *sample_weight* support to LogisticRegression.\n\n        Returns\n        -------\n        self : object\n            Returns self.\n        ' #NEWLINE# if ( ( not isinstance ( self . C , numbers . Number ) ) or ( self . C < 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Penalty term must be positive; got (C=%r)' % self . C ) ) #NEWLINE# #UNINDENT# if ( ( not isinstance ( self . max_iter , numbers . Number ) ) or ( self . max_iter < 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Maximum number of iteration must be positive; got (max_iter=%r)' % self . max_iter ) ) #NEWLINE# #UNINDENT# if ( ( not isinstance ( self . tol , numbers . Number ) ) or ( self . tol < 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Tolerance for stopping criteria must be positive; got (tol=%r)' % self . tol ) ) #NEWLINE# #UNINDENT# ( X , y ) = check_X_y ( X , y , accept_sparse = 'csr' , dtype = np . float64 , order = 'C' ) #NEWLINE# check_classification_targets ( y ) #NEWLINE# self . classes_ = np . unique ( y ) #NEWLINE# ( n_samples , n_features ) = X . shape #NEWLINE# _check_solver_option ( self . solver , self . multi_class , self . penalty , self . dual ) #NEWLINE# if ( self . solver == 'liblinear' ) : #NEWLINE# #INDENT# ( self . coef_ , self . intercept_ , n_iter_ ) = _fit_liblinear ( X , y , self . C , self . fit_intercept , self . intercept_scaling , self . class_weight , self . penalty , self . dual , self . verbose , self . max_iter , self . tol , self . random_state , sample_weight = sample_weight ) #NEWLINE# self . n_iter_ = np . array ( [ n_iter_ ] ) #NEWLINE# return self #NEWLINE# #UNINDENT# if ( self . solver == 'sag' ) : #NEWLINE# #INDENT# max_squared_sum = row_norms ( X , squared = True ) . max ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# max_squared_sum = None #NEWLINE# #UNINDENT# n_classes = len ( self . classes_ ) #NEWLINE# classes_ = self . classes_ #NEWLINE# if ( n_classes < 2 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'This solver needs samples of at least 2 classes in the data, but the data contains only one class: %r' % classes_ [ 0 ] ) ) #NEWLINE# #UNINDENT# if ( len ( self . classes_ ) == 2 ) : #NEWLINE# #INDENT# n_classes = 1 #NEWLINE# classes_ = classes_ [ 1 : ] #NEWLINE# #UNINDENT# if self . warm_start : #NEWLINE# #INDENT# warm_start_coef = getattr ( self , 'coef_' , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# warm_start_coef = None #NEWLINE# #UNINDENT# if ( ( warm_start_coef is not None ) and self . fit_intercept ) : #NEWLINE# #INDENT# warm_start_coef = np . append ( warm_start_coef , self . intercept_ [ : , np . newaxis ] , axis = 1 ) #NEWLINE# #UNINDENT# self . coef_ = list ( ) #NEWLINE# self . intercept_ = np . zeros ( n_classes ) #NEWLINE# if ( self . multi_class == 'multinomial' ) : #NEWLINE# #INDENT# classes_ = [ None ] #NEWLINE# warm_start_coef = [ warm_start_coef ] #NEWLINE# #UNINDENT# if ( warm_start_coef is None ) : #NEWLINE# #INDENT# warm_start_coef = ( [ None ] * n_classes ) #NEWLINE# #UNINDENT# path_func = delayed ( logistic_regression_path ) #NEWLINE# backend = ( 'threading' if ( self . solver == 'sag' ) else 'multiprocessing' ) #NEWLINE# fold_coefs_ = Parallel ( n_jobs = self . n_jobs , verbose = self . verbose , backend = backend ) ( ( path_func ( X , y , pos_class = class_ , Cs = [ self . C ] , fit_intercept = self . fit_intercept , tol = self . tol , verbose = self . verbose , solver = self . solver , copy = False , multi_class = self . multi_class , max_iter = self . max_iter , class_weight = self . class_weight , check_input = False , random_state = self . random_state , coef = warm_start_coef_ , max_squared_sum = max_squared_sum , sample_weight = sample_weight ) for ( class_ , warm_start_coef_ ) in zip ( classes_ , warm_start_coef ) ) ) #NEWLINE# ( fold_coefs_ , _ , n_iter_ ) = zip ( * fold_coefs_ ) #NEWLINE# self . n_iter_ = np . asarray ( n_iter_ , dtype = np . int32 ) [ : , 0 ] #NEWLINE# if ( self . multi_class == 'multinomial' ) : #NEWLINE# #INDENT# self . coef_ = fold_coefs_ [ 0 ] [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . coef_ = np . asarray ( fold_coefs_ ) #NEWLINE# self . coef_ = self . coef_ . reshape ( n_classes , ( n_features + int ( self . fit_intercept ) ) ) #NEWLINE# #UNINDENT# if self . fit_intercept : #NEWLINE# #INDENT# self . intercept_ = self . coef_ [ : , ( - 1 ) ] #NEWLINE# self . coef_ = self . coef_ [ : , : ( - 1 ) ] #NEWLINE# #UNINDENT# return self