docstr: ...Numerical consistency check of loss and gradient for linear
  regression with sample intercepts and a global intercept
docstr_tok: ["...","Numerical","consistency","check","of","loss","and","gradient","for","linear","regression","with","sample","intercepts","and","a","global","intercept"]
code: def test_ModelLinRegWithInterceptsWithGlobalIntercept(self):
      """...Numerical consistency check of loss and gradient for linear
      regression with sample intercepts and a global intercept
      """
      np.random.seed(12)
      n_samples, n_features = 200, 5
      w0 = np.random.randn(n_features)
      intercept0 = 50 * weights_sparse_gauss(
          n_weights=n_samples, nnz=30
      )
      c0 = None
      X, y = SimuLinReg(
          w0, c0, n_samples=n_samples, verbose=False, seed=2038
      ).simulate()
      # Add gross outliers to the labels
      y += intercept0
      X_spars = csr_matrix(X)
      model = ModelLinRegWithIntercepts(fit_intercept=False).fit(X, y)
      model_spars = ModelLinRegWithIntercepts(fit_intercept=False).fit(
          X_spars, y
      )
      self.run_test_for_glm(model, model_spars)
      self._test_glm_intercept_vs_hardcoded_intercept(model)
  
      self.assertAlmostEqual(model.get_lip_mean(), 6.324960325598532)
      self.assertAlmostEqual(model.get_lip_max(), 30.277118951892113)
      self.assertAlmostEqual(
          model.get_lip_mean(), model_spars.get_lip_mean()
      )
      self.assertAlmostEqual(
          model.get_lip_max(), model_spars.get_lip_max()
      )
      self.assertAlmostEqual(model.get_lip_best(), 2.7217793249045439)
  
file_path: tick/tick/robust/tests/model_linreg_with_intercepts_test.py
imports: import unittest
  import numpy
  from scipy.sparse import csr_matrix
  from tick.linear_model import SimuLinReg
  from tick.base_model.tests.generalized_linear_model import TestGLM
  from tick.robust import ModelLinRegWithIntercepts
  from tick.simulation import weights_sparse_gauss
label_desc: Use image node_id 1 for calling the Test obj's underlying member method code with example usage: obj.test_ModelLinRegWithInterceptsWithGlobalIntercept() without return types