code: def custom_supervised_model_learner(
      df: pd.DataFrame,
      features: List[str],
      target: str,
      model: Any,
      supervised_type: str,
      log: Dict[str, Dict],
      prediction_column: str = "prediction",
  ) -> LearnerReturnType:
      """
      Fits a custom model to the dataset.
      Return the predict function, the predictions for the input dataset and a log describing the model.
  
      Parameters
      ----------
  
      df : pandas.DataFrame
          A Pandas' DataFrame with features and target columns.
          The model will be trained to predict the target column
          from features.
  
      features : list of str
          A list os column names that are used as features for the model. All this names
          should be in `df`.
  
      target : str
          The name of the column in `df` that should be used as target for the model.
  
      model: Object
          Machine learning model to be used for regression or clasisfication.
          model object must have ".fit" attribute to train the data.
          For classification problems, it also needs ".predict_proba" attribute.
          For regression problemsm it needs ".predict" attribute.
  
      supervised_type: str
          Type of supervised learning to be used
          The options are: 'classification' or 'regression'
  
      log : Dict[str, Dict]
          Log with additional information of the custom model used.
          It must start with just one element with the model name.
  
      prediction_column : str
          The name of the column with the predictions from the model.
          For classification problems, all probabilities wiill be added: for i in range(0,n_classes).
          For regression just prediction_column will be added.
      """
  
      if len(log) != 1:
          raise ValueError(
              "'log' dictionary must start with model name"
          )
      if supervised_type not in ("classification", "regression"):
          raise TypeError(
              "supervised_type options are: 'classification' or 'regression'"
          )
      if not hasattr(model, "fit"):
          raise AttributeError(
              "'model' object must have 'fit' attribute"
          )
      if supervised_type == "classification" and not hasattr(
          model, "predict_proba"
      ):
          raise AttributeError(
              "'model' object for classification must have 'predict_proba' attribute"
          )
      if supervised_type == "regression" and not hasattr(
          model, "predict"
      ):
          raise AttributeError(
              "'model' object for regression must have 'predict' attribute"
          )
  
      model.fit(df[features].values, df[target].values)
  
      def p(new_df: pd.DataFrame) -> pd.DataFrame:
          if supervised_type == "classification":
              pred = model.predict_proba(new_df[features].values)
              col_dict = {}
              for key, value in enumerate(pred.T):
                  col_dict.update(
                      {prediction_column + "_" + str(key): value}
                  )
          elif supervised_type == "regression":
              col_dict = {
                  prediction_column: model.predict(
                      new_df[features].values
                  )
              }
  
          return new_df.assign(**col_dict)
  
      p.__doc__ = learner_pred_fn_docstring(
          "custom_supervised_model_learner"
      )
  
      log["object"] = model
  
      return p, p(df), log
  
file_path: fklearn/src/fklearn/training/regression.py
imports: from typing import Any, Dict, List, Union
  import numpy
  import pandas
  from toolz import merge, curry, assoc
  from sklearn.linear_model import LinearRegression, ElasticNet
  from sklearn.gaussian_process import GaussianProcessRegressor, kernels
  from sklearn import __version__
  from fklearn.common_docstrings import learner_pred_fn_docstring, learner_return_docstring
  from fklearn.types import LearnerReturnType
  from fklearn.training.utils import log_learner_time, expand_features_encoded
label_desc: Use image node_id 6 for calling a global function with example usage: custom_supervised_model_learner(df, features, target, model, supervised_type, log, prediction_column) and returns: p,  p,  log, new_df