class_docstr: Module level tests for all sktime classifiers.
docstr: Test classifier outputs the correct data types and values.
  
  Test predict produces a np.array or pd.Series with only values seen in the train
  data, and that predict_proba probability estimates add up to one.
docstr_tok: ["Test","classifier","outputs","the","correct","data","types","and","values",".","Test","predict","produces","a","np.array","or","pd.Series","with","only","values","seen","in","the","train","data",",","and","that","predict_proba","probability","estimates","add","up","to","one","."]
code: def test_classifier_output(self, estimator_instance, scenario):
      """Test classifier outputs the correct data types and values.
  
      Test predict produces a np.array or pd.Series with only values seen in the train
      data, and that predict_proba probability estimates add up to one.
      """
      n_classes = scenario.get_tag("n_classes")
      X_new = scenario.args["predict"]["X"]
      y_train = scenario.args["fit"]["y"]
      # we use check_is_scitype to get the number instances in X_new
      #   this is more robust against different scitypes in X_new
      _, _, X_new_metadata = check_is_scitype(
          X_new, "Panel", return_metadata=True
      )
      X_new_instances = X_new_metadata["n_instances"]
  
      # run fit and predict
      y_pred = scenario.run(
          estimator_instance, method_sequence=["fit", "predict"]
      )
  
      # check predict
      assert isinstance(y_pred, np.ndarray)
      assert y_pred.shape == (X_new_instances,)
      assert np.all(np.isin(np.unique(y_pred), np.unique(y_train)))
  
      # check predict proba (all classifiers have predict_proba by default)
      y_proba = scenario.run(
          estimator_instance, method_sequence=["predict_proba"]
      )
      assert isinstance(y_proba, np.ndarray)
      assert y_proba.shape == (X_new_instances, n_classes)
      np.testing.assert_almost_equal(y_proba.sum(axis=1), 1, decimal=4)
  
      if estimator_instance.get_tag("capability:train_estimate"):
          if not hasattr(estimator_instance, "_get_train_probs"):
              raise ValueError(
                  "Classifier capability:train_estimate tag is set to "
                  "true, but no _get_train_probs method is present."
              )
  
          X_train = scenario.args["fit"]["X"]
          _, _, X_train_metadata = check_is_scitype(
              X_train, "Panel", return_metadata=True
          )
          X_train_len = X_train_metadata["n_instances"]
  
          train_proba = estimator_instance._get_train_probs(
              X_train, y_train
          )
  
          assert isinstance(train_proba, np.ndarray)
          assert train_proba.shape == (X_train_len, n_classes)
          np.testing.assert_almost_equal(
              train_proba.sum(axis=1), 1, decimal=4
          )
  
imports: import numpy
  import pandas
  import pytest
  from sktime.classification.tests._expected_outputs import basic_motions_proba, unit_test_proba
  from sktime.datasets import load_basic_motions, load_unit_test
  from sktime.datatypes import check_is_scitype
  from sktime.tests.test_all_estimators import BaseFixtureGenerator, QuickTester
  from sktime.utils._testing.estimator_checks import _assert_array_almost_equal
  from sktime.utils._testing.panel import make_classification_problem
  from sktime.utils._testing.scenarios_classification import ClassifierFitPredictMultivariate
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 2 for calling the TestAllClassifiers obj's underlying member method code with example usage: obj.test_classifier_output(estimator_instance, scenario) without return types