docstr: ...Numerical consistency check of lik and grad for Hawkes
  Least-Squares with approx=0
docstr_tok: ["...","Numerical","consistency","check","of","lik","and","grad","for","Hawkes","Least-Squares","with","approx=0"]
code: def test_ModelHawkesExpKernLeastSqApprox0(self):
      """...Numerical consistency check of lik and grad for Hawkes
      Least-Squares with approx=0
      """
      timestamps = [
          np.array([0.2, 0.3, 0.65, 0.87, 1, 10, 12, 22]),
          np.array([3.0, 40.0, 60.0]),
      ]
      beta = 2.0
  
      model = ModelHawkesExpKernLeastSq(decays=beta).fit(timestamps)
  
      coeffs = np.array([0.1, 0.4, 0.3, 1.0, 0.4, 0.5])
      grad = np.zeros(6)
  
      loss = model._loss(coeffs)
      self.assertAlmostEqual(loss, 1.05752053, delta=1e-7)
  
      model._grad(coeffs, grad)
      test = np.array(
          [
              0.4363636,
              4.5818182,
              -0.6009268,
              0.4027132,
              1.8310919,
              0.3308908,
          ]
      )
      np.testing.assert_almost_equal(grad, test, decimal=7)
  
      loss = model._loss_and_grad(coeffs, grad)
      np.testing.assert_almost_equal(grad, test, decimal=7)
      self.assertAlmostEqual(loss, 1.05752053, delta=1e-7)
  
file_path: tick/tick/hawkes/model/tests/model_hawkes_expkern_leastsq_test.py
imports: import pickle
  import unittest
  import numpy
  from scipy.optimize import check_grad
  from tick.hawkes.model import ModelHawkesExpKernLeastSq
  from tick.hawkes.model.tests.model_hawkes_test_utils import hawkes_exp_kernel_intensities, hawkes_least_square_error
label_desc: Use image node_id 9 for calling the Test obj's underlying member method code with example usage: obj.test_ModelHawkesExpKernLeastSqApprox0() without return types