class_docstr: Wrapper around Spark MLlib PipelineModel providing interface for scoring pandas DataFrame.
class_docstr_tok: ["Wrapper","around","Spark","MLlib","PipelineModel","providing","interface","for","scoring","pandas","DataFrame","."]
docstr: Generate predictions given input data in a pandas DataFrame.
  
  :param pandas_df: pandas DataFrame containing input data.
  :param params: Additional parameters to pass to the model for inference.
  
                 .. Note:: Experimental: This parameter may change or be removed in a future
                                         release without warning.
  
  :return: List with model predictions.
docstr_tok: ["Generate","predictions","given","input","data","in","a","pandas","DataFrame",".",":","param","pandas_df",":","pandas","DataFrame","containing","input","data",".",":","param","params",":","Additional","parameters","to","pass","to","the","model","for","inference",".","..","Note",":",":","Experimental",":","This","parameter","may","change","or","be","removed","in","a","future","release","without","warning",".",":","return",":","List","with","model","predictions","."]
code: def predict(
      self,
      pandas_df,
      params: Optional[
          Dict[str, Any]
      ] = None,  # pylint: disable=unused-argument
  ):
      """
      Generate predictions given input data in a pandas DataFrame.
  
      :param pandas_df: pandas DataFrame containing input data.
      :param params: Additional parameters to pass to the model for inference.
  
                     .. Note:: Experimental: This parameter may change or be removed in a future
                                             release without warning.
  
      :return: List with model predictions.
      """
      from pyspark.ml import PipelineModel
  
      if _is_spark_connect_model(self.spark_model):
          # Spark connect ML model directly appends prediction result column to input pandas
          # dataframe. To make input dataframe intact, make a copy first.
          # TODO: apache/spark master has made a change to do shallow copy before
          #  calling `spark_model.transform`, so once spark 4.0 releases, we can
          #  remove this line.
          pandas_df = pandas_df.copy(deep=False)
          # Assuming the model output column name is "prediction".
          # Spark model uses "prediction" as default model inference output column name.
          return self.spark_model.transform(pandas_df)["prediction"]
  
      spark_df = _find_and_set_features_col_as_vector_if_needed(
          self.spark.createDataFrame(pandas_df), self.spark_model
      )
      prediction_column = "prediction"
      if isinstance(
          self.spark_model, PipelineModel
      ) and self.spark_model.stages[-1].hasParam("outputCol"):
          from pyspark.sql import SparkSession
  
          spark = SparkSession.builder.getOrCreate()
          # do a transform with an empty input DataFrame
          # to get the schema of the transformed DataFrame
          transformed_df = self.spark_model.transform(
              spark.createDataFrame([], spark_df.schema)
          )
          # Ensure prediction column doesn't already exist
          if prediction_column not in transformed_df.columns:
              # make sure predict work by default for Transformers
              self.spark_model.stages[-1].setOutputCol(
                  prediction_column
              )
      return [
          x.prediction
          for x in self.spark_model.transform(spark_df)
          .select(prediction_column)
          .collect()
      ]
  
imports: import logging
  import os
  import posixpath
  import re
  import shutil
  from typing import Any, Dict, Optional
  import pandas
  import yaml
  from packaging.version import Version
  import mlflow
  from mlflow import environment_variables, mleap, pyfunc
  from mlflow.environment_variables import MLFLOW_DFS_TMP
  from mlflow.exceptions import MlflowException
  from mlflow.models import Model, ModelInputExample, ModelSignature, infer_signature
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.signature import _LOG_MODEL_INFER_SIGNATURE_WARNING_TEMPLATE
  from mlflow.models.utils import _Example, _save_example
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.store.artifact.databricks_artifact_repo import DatabricksArtifactRepository
  from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri, _get_root_uri_and_artifact_path
  from mlflow.utils import _get_fully_qualified_class_name, databricks_utils
  from mlflow.utils.autologging_utils import autologging_integration, safe_patch
  from mlflow.utils.class_utils import _get_class_from_string
  from mlflow.utils.docstring_utils import LOG_MODEL_PARAM_DOCS, format_docstring
  from mlflow.utils.environment import _CONDA_ENV_FILE_NAME, _CONSTRAINTS_FILE_NAME, _PYTHON_ENV_FILE_NAME, _REQUIREMENTS_FILE_NAME, _mlflow_conda_env, _process_conda_env, _process_pip_requirements, _PythonEnv, _validate_env_arguments
  from mlflow.utils.file_utils import TempDir, get_total_file_size, shutil_copytree_without_file_permissions, write_to
  from mlflow.utils.model_utils import _add_code_from_conf_to_system_path, _get_flavor_configuration_from_uri, _validate_and_copy_code_paths
  from mlflow.utils.requirements_utils import _get_pinned_requirement
  from mlflow.utils.uri import append_to_uri_path, dbfs_hdfs_uri_to_fuse_path, generate_tmp_dfs_path, get_databricks_profile_uri_from_artifact_uri, is_databricks_acled_artifacts_uri, is_local_uri, is_valid_dbfs_uri
label_desc: Use image node_id 2 for calling the _PyFuncModelWrapper obj's underlying member method code with example usage: obj.predict(pandas_df, params) and returns: unknown, self