code: def test_aft_survival_demo_data():
      import pandas as pd
  
      df = pd.read_csv(os.path.join(dpath, "veterans_lung_cancer.csv"))
  
      y_lower_bound = df["Survival_label_lower_bound"]
      y_upper_bound = df["Survival_label_upper_bound"]
      X = df.drop(
          ["Survival_label_lower_bound", "Survival_label_upper_bound"],
          axis=1,
      )
  
      dtrain = xgb.DMatrix(X)
      dtrain.set_float_info("label_lower_bound", y_lower_bound)
      dtrain.set_float_info("label_upper_bound", y_upper_bound)
  
      base_params = {
          "verbosity": 0,
          "objective": "survival:aft",
          "eval_metric": "aft-nloglik",
          "tree_method": "hist",
          "learning_rate": 0.05,
          "aft_loss_distribution_scale": 1.20,
          "max_depth": 6,
          "lambda": 0.01,
          "alpha": 0.02,
      }
      nloglik_rec = {}
      dists = ["normal", "logistic", "extreme"]
      for dist in dists:
          params = base_params
          params.update({"aft_loss_distribution": dist})
          evals_result = {}
          bst = xgb.train(
              params,
              dtrain,
              num_boost_round=500,
              evals=[(dtrain, "train")],
              evals_result=evals_result,
          )
          nloglik_rec[dist] = evals_result["train"]["aft-nloglik"]
          # AFT metric (negative log likelihood) improve monotonically
          assert all(
              p >= q
              for p, q in zip(nloglik_rec[dist], nloglik_rec[dist][:1])
          )
      # For this data, normal distribution works the best
      assert nloglik_rec["normal"][-1] < 4.9
      assert nloglik_rec["logistic"][-1] > 4.9
      assert nloglik_rec["extreme"][-1] > 4.9
  
file_path: xgboost/tests/python/test_survival.py
imports: import json
  import os
  from typing import List, Optional, Tuple, cast
  import numpy
  import pytest
  import xgboost
  from xgboost import testing
label_desc: Use image node_id 5 for calling a global function with example usage: test_aft_survival_demo_data() without return types