code: def test_mpca_trainer(classifier, params, gait):
      x = gait["fea3D"].transpose((3, 0, 1, 2))
      x = x[:20, :]
      y = gait["gnd"][:20].reshape(-1)
      trainer = MPCATrainer(classifier=classifier, **params)
      trainer.fit(x, y)
      y_pred = trainer.predict(x)
      testing.assert_equal(np.unique(y), np.unique(y_pred))
      assert accuracy_score(y, y_pred) >= 0.8
  
      if classifier == "linear_svc":
          with pytest.raises(Exception):
              y_proba = trainer.predict_proba(x)
      else:
          y_proba = trainer.predict_proba(x)
          assert np.max(y_proba) <= 1.0
          assert np.min(y_proba) >= 0.0
          y_ = np.zeros(y.shape)
          y_[np.where(y == 1)] = 1
          assert roc_auc_score(y_, y_proba[:, 0]) >= 0.8
  
      y_dec_score = trainer.decision_function(x)
      assert roc_auc_score(y, y_dec_score) >= 0.8
  
      if classifier == "svc" and trainer.clf.kernel == "rbf":
          with pytest.raises(Exception):
              trainer.mpca.inverse_transform(trainer.clf.coef_)
      else:
          weights = (
              trainer.mpca.inverse_transform(trainer.clf.coef_)
              - trainer.mpca.mean_
          )
          top_weights = model_weights.select_top_weight(
              weights, select_ratio=0.1
          )
          fig = visualize.plot_weights(
              top_weights[0][0], background_img=x[0][0]
          )
          assert isinstance(fig, matplotlib.figure.Figure)
  
file_path: pykale/tests/pipeline/test_mpca_trainer.py
imports: import matplotlib.figure
  import numpy
  import pytest
  from numpy import testing
  from sklearn.metrics import accuracy_score, roc_auc_score
  from kale.interpret import model_weights, visualize
  from kale.pipeline.mpca_trainer import MPCATrainer
label_desc: Use image node_id 1 for calling a global function with example usage: test_mpca_trainer(classifier, params, gait) without return types