#NEWLINE# def fit( self , X , y , sample_weight = None ) : #NEWLINE# #INDENT# '\n        Fit linear model.\n\n        Parameters\n        ----------\n        X : numpy array or sparse matrix of shape [n_samples,n_features]\n            Training data\n\n        y : numpy array of shape [n_samples, n_targets]\n            Target values\n\n        sample_weight : numpy array of shape [n_samples]\n            Individual weights for each sample\n\n            .. versionadded:: 0.17\n               parameter *sample_weight* support to LinearRegression.\n\n        Returns\n        -------\n        self : returns an instance of self.\n        ' #NEWLINE# n_jobs_ = self . n_jobs #NEWLINE# ( X , y ) = check_X_y ( X , y , accept_sparse = [ 'csr' , 'csc' , 'coo' ] , y_numeric = True , multi_output = True ) #NEWLINE# if ( ( sample_weight is not None ) and ( np . atleast_1d ( sample_weight ) . ndim > 1 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Sample weights must be 1D array or scalar' ) #NEWLINE# #UNINDENT# ( X , y , X_offset , y_offset , X_scale ) = self . _preprocess_data ( X , y , fit_intercept = self . fit_intercept , normalize = self . normalize , copy = self . copy_X , sample_weight = sample_weight ) #NEWLINE# if ( sample_weight is not None ) : #NEWLINE# #INDENT# ( X , y ) = _rescale_data ( X , y , sample_weight ) #NEWLINE# #UNINDENT# if sp . issparse ( X ) : #NEWLINE# #INDENT# if ( y . ndim < 2 ) : #NEWLINE# #INDENT# out = sparse_lsqr ( X , y ) #NEWLINE# self . coef_ = out [ 0 ] #NEWLINE# self . _residues = out [ 3 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# outs = Parallel ( n_jobs = n_jobs_ ) ( ( delayed ( sparse_lsqr ) ( X , y [ : , j ] . ravel ( ) ) for j in range ( y . shape [ 1 ] ) ) ) #NEWLINE# self . coef_ = np . vstack ( ( out [ 0 ] for out in outs ) ) #NEWLINE# self . _residues = np . vstack ( ( out [ 3 ] for out in outs ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( self . coef_ , self . _residues , self . rank_ , self . singular_ ) = linalg . lstsq ( X , y ) #NEWLINE# self . coef_ = self . coef_ . T #NEWLINE# #UNINDENT# if ( y . ndim == 1 ) : #NEWLINE# #INDENT# self . coef_ = np . ravel ( self . coef_ ) #NEWLINE# #UNINDENT# self . _set_intercept ( X_offset , out , X_scale ) #NEWLINE# return self