code: def test_kernel_sparse_vs_dense_multirow_background():
      """Mix sparse and dense matrix values."""
  
      # train a logistic regression classifier
      (
          X_train,
          X_test,
          Y_train,
          _,
      ) = sklearn.model_selection.train_test_split(
          *shap.datasets.iris(), test_size=0.1, random_state=0
      )
      lr = sklearn.linear_model.LogisticRegression(solver="lbfgs")
      lr.fit(X_train, Y_train)
  
      # use Kernel SHAP to explain test set predictions with dense data
      explainer = shap.KernelExplainer(
          lr.predict_proba,
          X_train,
          nsamples=100,
          link="logit",
          l1_reg="rank(3)",
      )
      shap_values = explainer.shap_values(X_test)
  
      X_sparse_train = scipy.sparse.csr_matrix(X_train)
      X_sparse_test = scipy.sparse.csr_matrix(X_test)
  
      lr_sparse = sklearn.linear_model.LogisticRegression(
          solver="lbfgs"
      )
      lr_sparse.fit(X_sparse_train, Y_train)
  
      # use Kernel SHAP again but with sparse data
      sparse_explainer = shap.KernelExplainer(
          lr.predict_proba,
          X_sparse_train,
          nsamples=100,
          link="logit",
          l1_reg="rank(3)",
      )
      sparse_shap_values = sparse_explainer.shap_values(X_sparse_test)
  
      assert np.allclose(
          shap_values, sparse_shap_values, rtol=1e-05, atol=1e-05
      )
  
      # Use sparse evaluation examples with dense background
      sparse_sv_dense_bg = explainer.shap_values(X_sparse_test)
      assert np.allclose(
          shap_values, sparse_sv_dense_bg, rtol=1e-05, atol=1e-05
      )
  
file_path: shap/tests/explainers/test_kernel.py
imports: import numpy
  import pandas
  import scipy.sparse
  import sklearn
  import shap
label_desc: Use image node_id 11 for calling a global function with example usage: test_kernel_sparse_vs_dense_multirow_background() without return types