code: def logistic_classification_learner(
      df: pd.DataFrame,
      features: List[str],
      target: str,
      params: LogType = None,
      prediction_column: str = "prediction",
      weight_column: str = None,
      encode_extra_cols: bool = True,
  ) -> LearnerReturnType:
      """
      Fits an logistic regression classifier to the dataset. Return the predict function
      for the model and the predictions for the input dataset.
  
      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.
  
      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.
          This column should be discrete, since this is a classification model.
  
      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.
          If a multiclass problem, additional prediction_column_i columns will be added for i in range(0,n_classes).
  
      weight_column : str, optional
          The name of the column with scores to weight the data.
  
      encode_extra_cols : bool (default: True)
          If True, treats all columns in `df` with name pattern fklearn_feat__col==val` as feature columns.
      """
  
      def_params = {
          "C": 0.1,
          "multi_class": "ovr",
          "solver": "liblinear",
      }
      merged_params = (
          def_params if not params else merge(def_params, params)
      )
  
      weights = df[weight_column].values if weight_column else None
  
      features = (
          features
          if not encode_extra_cols
          else expand_features_encoded(df, features)
      )
  
      clf = LogisticRegression(**merged_params)
      clf.fit(
          df[features].values, df[target].values, sample_weight=weights
      )
  
      def p(new_df: pd.DataFrame) -> pd.DataFrame:
          pred = clf.predict_proba(new_df[features].values)
          if merged_params["multi_class"] == "multinomial":
              col_dict = {
                  prediction_column + "_" + str(key): value
                  for (key, value) in enumerate(pred.T)
              }
              col_dict.update({prediction_column: pred.argmax(axis=1)})
          else:
              col_dict = {prediction_column: pred[:, 1]}
  
          return new_df.assign(**col_dict)
  
      p.__doc__ = learner_pred_fn_docstring(
          "logistic_classification_learner"
      )
  
      log = {
          "logistic_classification_learner": {
              "features": features,
              "target": target,
              "parameters": merged_params,
              "prediction_column": prediction_column,
              "package": "sklearn",
              "package_version": sk_version,
              "feature_importance": dict(
                  zip(features, clf.coef_.flatten())
              ),
              "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 1 for calling a global function with example usage: logistic_classification_learner(df, features, target, params, prediction_column, weight_column, encode_extra_cols) and returns: p,  p,  log, new_df