code: def nlp_logistic_classification_learner(
      df: pd.DataFrame,
      text_feature_cols: List[str],
      target: str,
      vectorizer_params: LogType = None,
      logistic_params: LogType = None,
      prediction_column: str = "prediction",
  ) -> LearnerReturnType:
      """
      Fits a text vectorizer (TfidfVectorizer) followed by
      a logistic regression (LogisticRegression).
  
      Parameters
      ----------
  
      df : pandas.DataFrame
          A Pandas' DataFrame with features and target columns.
          The model will be trained to predict the target column
          from the features.
  
      text_feature_cols : list of str
          A list of column names of the text features used for the model. All these names
          should be in `df`.
  
      target : str
          The name of the column in `df` that should be used as target for the model.
          This column should be discrete, since this is a classification model.
  
      vectorizer_params : dict
          The TfidfVectorizer parameters in the format {"par_name": param}. See:
          http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html
  
      logistic_params : dict
          The LogisticRegression parameters in the format {"par_name": param}. See:
          http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html
  
      prediction_column : str
          The name of the column with the predictions from the model.
      """
  
      # set default params
      default_vect_params = {"strip_accents": "unicode", "min_df": 1}
      merged_vect_params = (
          default_vect_params
          if not vectorizer_params
          else merge(default_vect_params, vectorizer_params)
      )
  
      default_clf_params = {
          "C": 0.1,
          "multi_class": "ovr",
          "solver": "liblinear",
      }
      merged_logistic_params = (
          default_clf_params
          if not logistic_params
          else merge(default_clf_params, logistic_params)
      )
  
      vect = TfidfVectorizer(**merged_vect_params)
      clf = LogisticRegression(**merged_logistic_params)
  
      text_df = (
          df[text_feature_cols]
          .apply(lambda x: x + " ", axis=1)
          .sum(axis=1)
      )
      vect.fit(text_df.values)
      sparse_vect = vect.transform(text_df.values)
      clf.fit(sparse_vect, df[target].values)
  
      def p(new_df: pd.DataFrame) -> pd.DataFrame:
          predict_text_df = (
              new_df[text_feature_cols]
              .apply(lambda x: x + " ", axis=1)
              .sum(axis=1)
          )
          predict_sparse_vect = vect.transform(predict_text_df)
  
          if merged_logistic_params["multi_class"] == "multinomial":
              col_dict = {
                  prediction_column + "_" + str(key): value
                  for (key, value) in enumerate(
                      clf.predict_proba(predict_sparse_vect).T
                  )
              }
          else:
              col_dict = {
                  prediction_column: clf.predict_proba(
                      predict_sparse_vect
                  )[:, 1]
              }
  
          return new_df.assign(**col_dict)
  
      p.__doc__ = learner_pred_fn_docstring(
          "nlp_logistic_classification_learner"
      )
  
      params = {
          "vectorizer_params": merged_vect_params,
          "logistic_params": merged_logistic_params,
      }
  
      log = {
          "nlp_logistic_classification_learner": {
              "features": text_feature_cols,
              "target": target,
              "prediction_column": prediction_column,
              "parameters": assoc(
                  params, "vocab_size", sparse_vect.shape[1]
              ),
              "package": "sklearn",
              "package_version": sk_version,
              "training_samples": len(df),
          },
          "object": clf,
      }
  
      return p, p(df), log
  
file_path: fklearn/src/fklearn/training/classification.py
imports: from typing import List, Any, Optional, Callable, Tuple, Union, TYPE_CHECKING, Literal
  import numpy
  import numpy.typing
  import pandas
  from pathlib import Path
  from toolz import curry, merge, assoc
  from sklearn.feature_extraction.text import TfidfVectorizer
  from sklearn.linear_model import LogisticRegression
  from sklearn import __version__
  from fklearn.types import LearnerReturnType, LearnerLogType, LogType
  from fklearn.common_docstrings import learner_return_docstring, learner_pred_fn_docstring
  from fklearn.training.utils import log_learner_time, expand_features_encoded
label_desc: Use image node_id 5 for calling a global function with example usage: nlp_logistic_classification_learner(df, text_feature_cols, target, vectorizer_params, logistic_params, prediction_column) and returns: p,  p,  log, new_df