docstr: Test that gradient is consistent with loss and that minimum is
  achievable with a small gradient
docstr_tok: ["Test","that","gradient","is","consistent","with","loss","and","that","minimum","is","achievable","with","a","small","gradient"]
code: def _test_grad(
      self, model, coeffs, delta_check_grad=1e-5, delta_model_grad=1e-4
  ):
      """Test that gradient is consistent with loss and that minimum is
      achievable with a small gradient
      """
      self.assertAlmostEqual(
          check_grad(model.loss, model.grad, coeffs),
          0.0,
          delta=delta_check_grad,
      )
      # Check that minimum iss achievable with a small gradient
      coeffs_min = fmin_bfgs(
          model.loss, coeffs, fprime=model.grad, disp=False
      )
      self.assertAlmostEqual(
          norm(model.grad(coeffs_min)), 0.0, delta=delta_model_grad
      )
  
file_path: tick/tick/survival/tests/model_sccs_test.py
imports: import unittest, pickle
  import numpy
  from scipy.optimize import check_grad, fmin_bfgs
  from scipy.linalg import norm
  from scipy.sparse import csr_matrix
  from tick.survival import SimuSCCS, ModelSCCS
  from tick.preprocessing import LongitudinalFeaturesLagger
  from tick.solver import SVRG
  from tick.prox import ProxZero
label_desc: Use image node_id 8 for calling the ModelSCCSTest obj's underlying member method code with example usage: obj._test_grad(model, coeffs, delta_check_grad, delta_model_grad) without return types