class_docstr: Lasso model fit with Lars using BIC or AIC for model selection
  
  The optimization objective for Lasso is::
  
  (1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1
  
  AIC is the Akaike information criterion and BIC is the Bayes
  Information criterion. Such criteria are useful to select the value
  of the regularization parameter by making a trade-off between the
  goodness of fit and the complexity of the model. A good model should
  explain well the data while being simple.
  
  Read more in the :ref:`User Guide <least_angle_regression>`.
  
  Parameters
  ----------
  criterion : 'bic' | 'aic'
      The type of criterion to use.
  
  fit_intercept : boolean
      whether to calculate the intercept for this model. If set
      to false, no intercept will be used in calculations
      (e.g. data is expected to be already centered).
  
  positive : boolean (default=False)
      Restrict coefficients to be >= 0. Be aware that you might want to
      remove fit_intercept which is set True by default.
      Under the positive restriction the model coefficients do not converge
      to the ordinary-least-squares solution for small values of alpha.
      Only coefficients up to the smallest alpha value (``alphas_[alphas_ >
      0.].min()`` when fit_path=True) reached by the stepwise Lars-Lasso
      algorithm are typically in congruence with the solution of the
      coordinate descent Lasso estimator.
      As a consequence using LassoLarsIC only makes sense for problems where
      a sparse solution is expected and/or reached.
  
  verbose : boolean or integer, optional
      Sets the verbosity amount
  
  normalize : boolean, optional, default False
      If True, the regressors X will be normalized before regression.
      This parameter is ignored when `fit_intercept` is set to False.
      When the regressors are normalized, note that this makes the
      hyperparameters learnt more robust and almost independent of the number
      of samples. The same property is not valid for standardized data.
      However, if you wish to standardize, please use
      `preprocessing.StandardScaler` before calling `fit` on an estimator
      with `normalize=False`.
  
  copy_X : boolean, optional, default True
      If True, X will be copied; else, it may be overwritten.
  
  precompute : True | False | 'auto' | array-like
      Whether to use a precomputed Gram matrix to speed up
      calculations. If set to ``'auto'`` let us decide. The Gram
      matrix can also be passed as argument.
  
  max_iter : integer, optional
      Maximum number of iterations to perform. Can be used for
      early stopping.
  
  eps : float, optional
      The machine-precision regularization in the computation of the
      Cholesky diagonal factors. Increase this for very ill-conditioned
      systems. Unlike the ``tol`` parameter in some iterative
      optimization-based algorithms, this parameter does not control
      the tolerance of the optimization.
  
  
  Attributes
  ----------
  coef_ : array, shape (n_features,)
      parameter vector (w in the formulation formula)
  
  intercept_ : float
      independent term in decision function.
  
  alpha_ : float
      the alpha parameter chosen by the information criterion
  
  n_iter_ : int
      number of iterations run by lars_path to find the grid of
      alphas.
  
  criterion_ : array, shape (n_alphas,)
      The value of the information criteria ('aic', 'bic') across all
      alphas. The alpha which has the smallest information criteria
      is chosen.
  
  Examples
  --------
  >>> from sklearn import linear_model
  >>> clf = linear_model.LassoLarsIC(criterion='bic')
  >>> clf.fit([[-1, 1], [0, 0], [1, 1]], [-1.1111, 0, -1.1111])
  ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
  LassoLarsIC(copy_X=True, criterion='bic', eps=..., fit_intercept=True,
        max_iter=500, normalize=True, positive=False, precompute='auto',
        verbose=False)
  >>> print(clf.coef_) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
  [ 0.  -1.11...]
  
  Notes
  -----
  The estimation of the number of degrees of freedom is given by:
  
  "On the degrees of freedom of the lasso"
  Hui Zou, Trevor Hastie, and Robert Tibshirani
  Ann. Statist. Volume 35, Number 5 (2007), 2173-2192.
  
  https://en.wikipedia.org/wiki/Akaike_information_criterion
  https://en.wikipedia.org/wiki/Bayesian_information_criterion
  
  See also
  --------
  lars_path, LassoLars, LassoLarsCV
class_docstr_tok: ["Lasso","model","fit","with","Lars","using","BIC","or","AIC","for","model","selection","The","optimization","objective","for","Lasso","is",":",":","(","1","\/","(","2","*","n_samples",")",")","*","||y","-","Xw||^2_2","+","alpha","*","||w||_1","AIC","is","the","Akaike","information","criterion","and","BIC","is","the","Bayes","Information","criterion",".","Such","criteria","are","useful","to","select","the","value","of","the","regularization","parameter","by","making","a","trade-off","between","the","goodness","of","fit","and","the","complexity","of","the","model",".","A","good","model","should","explain","well","the","data","while","being","simple",".","Read","more","in","the",":","ref",":","`","User","Guide","<","least_angle_regression",">","`",".","Parameters","--","--","--","--","--","criterion",":","'bic","'","|","'aic'","The","type","of","criterion","to","use",".","fit_intercept",":","boolean","whether","to","calculate","the","intercept","for","this","model",".","If","set","to","false",",","no","intercept","will","be","used","in","calculations","(","e.g",".","data","is","expected","to","be","already","centered",")",".","positive",":","boolean","(","default=False",")","Restrict","coefficients","to","be",">","=","0",".","Be","aware","that","you","might","want","to","remove","fit_intercept","which","is","set","True","by","default",".","Under","the","positive","restriction","the","model","coefficients","do","not","converge","to","the","ordinary-least-squares","solution","for","small","values","of","alpha",".","Only","coefficients","up","to","the","smallest","alpha","value","(","``","alphas_","[","alphas_",">","0",".","]",".min","(",")","``","when","fit_path=True",")","reached","by","the","stepwise","Lars-Lasso","algorithm","are","typically","in","congruence","with","the","solution","of","the","coordinate","descent","Lasso","estimator",".","As","a","consequence","using","LassoLarsIC","only","makes","sense","for","problems","where","a","sparse","solution","is","expected","and\/or","reached",".","verbose",":","boolean","or","integer",",","optional","Sets","the","verbosity","amount","normalize",":","boolean",",","optional",",","default","False","If","True",",","the","regressors","X","will","be","normalized","before","regression",".","This","parameter","is","ignored","when","`","fit_intercept","`","is","set","to","False",".","When","the","regressors","are","normalized",",","note","that","this","makes","the","hyperparameters","learnt","more","robust","and","almost","independent","of","the","number","of","samples",".","The","same","property","is","not","valid","for","standardized","data",".","However",",","if","you","wish","to","standardize",",","please","use","`","preprocessing.StandardScaler","`","before","calling","`","fit","`","on","an","estimator","with","`","normalize=False","`",".","copy_X",":","boolean",",","optional",",","default","True","If","True",",","X","will","be","copied",";","else",",","it","may","be","overwritten",".","precompute",":","True","|","False","|","'auto","'","|","array-like","Whether","to","use","a","precomputed","Gram","matrix","to","speed","up","calculations",".","If","set","to","``","'auto","'","``","let","us","decide",".","The","Gram","matrix","can","also","be","passed","as","argument",".","max_iter",":","integer",",","optional","Maximum","number","of","iterations","to","perform",".","Can","be","used","for","early","stopping",".","eps",":","float",",","optional","The","machine-precision","regularization","in","the","computation","of","the","Cholesky","diagonal","factors",".","Increase","this","for","very","ill-conditioned","systems",".","Unlike","the","``","tol","``","parameter","in","some","iterative","optimization-based","algorithms",",","this","parameter","does","not","control","the","tolerance","of","the","optimization",".","Attributes","--","--","--","--","--","coef_",":","array",",","shape","(","n_features",",",")","parameter","vector","(","w","in","the","formulation","formula",")","intercept_",":","float","independent","term","in","decision","function",".","alpha_",":","float","the","alpha","parameter","chosen","by","the","information","criterion","n_iter_",":","int","number","of","iterations","run","by","lars_path","to","find","the","grid","of","alphas",".","criterion_",":","array",",","shape","(","n_alphas",",",")","The","value","of","the","information","criteria","(","'aic","'",",","'bic","'",")","across","all","alphas",".","The","alpha","which","has","the","smallest","information","criteria","is","chosen",".","Examples","--","--","--","--",">",">",">","from","sklearn","import","linear_model",">",">",">","clf","=","linear_model.LassoLarsIC","(","criterion='bic","'",")",">",">",">","clf.fit","(","[","[","-1",",","1","]",",","[","0",",","0","]",",","[","1",",","1","]","]",",","[","-1.1111",",","0",",","-1.1111","]",")","...","#","doctest",":","+ELLIPSIS",",","+NORMALIZE_WHITESPACE","LassoLarsIC","(","copy_X=True",",","criterion='bic","'",",","eps=","...",",","fit_intercept=True",",","max_iter=500",",","normalize=True",",","positive=False",",","precompute='auto","'",",","verbose=False",")",">",">",">","print","(","clf.coef_",")","#","doctest",":","+ELLIPSIS",",","+NORMALIZE_WHITESPACE","[","0",".","-1.11","...","]","Notes","--","--","-","The","estimation","of","the","number","of","degrees","of","freedom","is","given","by",":","''","On","the","degrees","of","freedom","of","the","lasso","''","Hui","Zou",",","Trevor","Hastie",",","and","Robert","Tibshirani","Ann",".","Statist",".","Volume","35",",","Number","5","(","2007",")",",","2173-2192.","https",":","\/\/en.wikipedia.org\/wiki\/Akaike_information_criterion","https",":","\/\/en.wikipedia.org\/wiki\/Bayesian_information_criterion","See","also","--","--","--","--","lars_path",",","LassoLars",",","LassoLarsCV"]
docstr: Fit the model using X, y as training data.
  
  Parameters
  ----------
  X : array-like, shape (n_samples, n_features)
      training data.
  
  y : array-like, shape (n_samples,)
      target values.
  
  copy_X : boolean, optional, default True
      If ``True``, X will be copied; else, it may be overwritten.
  
  Returns
  -------
  self : object
      returns an instance of self.
docstr_tok: ["Fit","the","model","using","X",",","y","as","training","data",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","(","n_samples",",","n_features",")","training","data",".","y",":","array-like",",","shape","(","n_samples",",",")","target","values",".","copy_X",":","boolean",",","optional",",","default","True","If","``","True","``",",","X","will","be","copied",";","else",",","it","may","be","overwritten",".","Returns","--","--","--","-","self",":","object","returns","an","instance","of","self","."]
code: def fit(self, X, y, copy_X=True):
      """Fit the model using X, y as training data.
  
      Parameters
      ----------
      X : array-like, shape (n_samples, n_features)
          training data.
  
      y : array-like, shape (n_samples,)
          target values.
  
      copy_X : boolean, optional, default True
          If ``True``, X will be copied; else, it may be overwritten.
  
      Returns
      -------
      self : object
          returns an instance of self.
      """
      self.fit_path = True
      X, y = check_X_y(X, y, y_numeric=True)
  
      X, y, Xmean, ymean, Xstd = LinearModel._preprocess_data(
          X, y, self.fit_intercept, self.normalize, self.copy_X
      )
      max_iter = self.max_iter
  
      Gram = self._get_gram()
  
      alphas_, active_, coef_path_, self.n_iter_ = lars_path(
          X,
          y,
          Gram=Gram,
          copy_X=copy_X,
          copy_Gram=True,
          alpha_min=0.0,
          method="lasso",
          verbose=self.verbose,
          max_iter=max_iter,
          eps=self.eps,
          return_n_iter=True,
          positive=self.positive,
      )
  
      n_samples = X.shape[0]
  
      if self.criterion == "aic":
          K = 2  # AIC
      elif self.criterion == "bic":
          K = log(n_samples)  # BIC
      else:
          raise ValueError("criterion should be either bic or aic")
  
      R = y[:, np.newaxis] - np.dot(X, coef_path_)  # residuals
      mean_squared_error = np.mean(R**2, axis=0)
  
      df = np.zeros(
          coef_path_.shape[1], dtype=np.int
      )  # Degrees of freedom
      for k, coef in enumerate(coef_path_.T):
          mask = np.abs(coef) > np.finfo(coef.dtype).eps
          if not np.any(mask):
              continue
          # get the number of degrees of freedom equal to:
          # Xc = X[:, mask]
          # Trace(Xc * inv(Xc.T, Xc) * Xc.T) ie the number of non-zero coefs
          df[k] = np.sum(mask)
  
      self.alphas_ = alphas_
      with np.errstate(divide="ignore"):
          self.criterion_ = (
              n_samples * np.log(mean_squared_error) + K * df
          )
      n_best = np.argmin(self.criterion_)
  
      self.alpha_ = alphas_[n_best]
      self.coef_ = coef_path_[:, n_best]
      self._set_intercept(Xmean, ymean, Xstd)
      return self
  
imports: from __future__ import print_function
  from math import log
  import sys
  import warnings
  from distutils.version import LooseVersion
  import numpy
  from scipy import linalg, interpolate
  from scipy.linalg.lapack import get_lapack_funcs
  from .base import LinearModel
  from ..base import RegressorMixin
  from ..utils import arrayfuncs, as_float_array, check_X_y
  from ..model_selection import check_cv
  from ..exceptions import ConvergenceWarning
  from ..externals.joblib import Parallel, delayed
  from ..externals.six.moves import xrange
  from ..externals.six import string_types
  import scipy
label_desc: Use image node_id 2 for calling the LassoLarsIC obj's underlying member method code with example usage: obj.fit(X, y, copy_X) and returns: self