docstr: ...Extra tests for linear regression with sample intercepts and not
  global intercept, check gradient wrt homemade gradient
docstr_tok: ["...","Extra","tests","for","linear","regression","with","sample","intercepts","and","not","global","intercept",",","check","gradient","wrt","homemade","gradient"]
code: def test_ModelLinRegWithInterceptsWithoutGlobalInterceptExtras(self):
      """...Extra tests for linear regression with sample intercepts and not
      global intercept, check gradient wrt homemade gradient
      """
      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
      model = ModelLinRegWithIntercepts(fit_intercept=False).fit(X, y)
      coeffs = np.random.randn(model.n_coeffs)
      grad1 = model.grad(coeffs)
      X2 = np.hstack((X, np.identity(n_samples)))
      grad2 = X2.T.dot(X2.dot(coeffs) - y) / n_samples
      np.testing.assert_almost_equal(grad1, grad2, decimal=10)
  
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 3 for calling the Test obj's underlying member method code with example usage: obj.test_ModelLinRegWithInterceptsWithoutGlobalInterceptExtras() without return types