docstr: ...Test HawkesExpKern fit with different solvers
  and penalties
docstr_tok: ["...","Test","HawkesExpKern","fit","with","different","solvers","and","penalties"]
code: def test_HawkesExpKern_fit(self):
      """...Test HawkesExpKern fit with different solvers
      and penalties
      """
      sto_seed = 179312
      n_nodes = 2
      events, baseline, adjacency = Test.get_train_data(
          n_nodes=n_nodes, betas=self.decays
      )
      start = 0.3
      initial_adjacency_error = Test.estimation_error(
          start * np.ones((n_nodes, n_nodes)), adjacency
      )
  
      for gofit in gofits:
          for penalty in penalties:
              for solver in solvers:
                  solver_kwargs = {
                      "penalty": penalty,
                      "tol": 1e-10,
                      "solver": solver,
                      "verbose": False,
                      "max_iter": 10,
                      "gofit": gofit,
                  }
  
                  if penalty != "none":
                      solver_kwargs["C"] = 50
  
                  if solver in ["sgd", "svrg"]:
                      solver_kwargs["random_state"] = sto_seed
  
                  # manually set step
                  if solver == "sgd" and gofit == "likelihood":
                      solver_kwargs["step"] = 3e-1
                  elif solver == "sgd" and gofit == "least-squares":
                      solver_kwargs["step"] = 1e-5
                  elif solver == "svrg" and gofit == "likelihood":
                      solver_kwargs["step"] = 1e-3
                  elif solver == "svrg" and gofit == "least-squares":
                      continue
  
                  if solver == "bfgs":
                      # BFGS only accepts ProxZero and ProxL2sq for now
                      if penalty != "l2":
                          continue
  
                  if penalty == "nuclear":
                      # Nuclear penalty only compatible with batch solvers
                      if solver in HawkesExpKern._solvers_stochastic:
                          continue
  
                  learner = HawkesExpKern(self.decays, **solver_kwargs)
                  learner.fit(events, start=start)
                  adjacency_error = Test.estimation_error(
                      learner.adjacency, adjacency
                  )
                  self.assertLess(
                      adjacency_error,
                      initial_adjacency_error * 0.8,
                      "solver %s with penalty %s and "
                      "gofit %s reached too high "
                      "baseline error" % (solver, penalty, gofit),
                  )
  
imports: import unittest
  import numpy
  from tick.base.inference import InferenceTest
  from tick.hawkes import SimuHawkesExpKernels
  from tick.hawkes.inference import HawkesExpKern
  from tick.hawkes.model.model_hawkes_expkern_leastsq import ModelHawkesExpKernLeastSq
  from tick.hawkes.model.model_hawkes_expkern_loglik import ModelHawkesExpKernLogLik
  from tick.prox import ProxNuclear
  from tick.prox import ProxPositive, ProxL1, ProxL2Sq, ProxElasticNet
  from tick.solver import AGD, GD, BFGS, SGD, SVRG
label_desc: Use image node_id 4 for calling the Test obj's underlying member method code with example usage: obj.test_HawkesExpKern_fit() without return types