Pipelines

Pipelines: Pipelines: Every Step, Every Time, Different Steps for Different Columns.

Updated

  1. Pipelines: Every Step, Every Time (Journeyman): A pipeline chains the preparation steps and the model into one object, so make_pipeline(SimpleImputer(), StandardScaler(), LogisticRegression()) fits every step on the data it's given with one fit, repeats the same steps with one predict, names each step for named_steps, and refits every step inside each fold when it's handed to cross_val_score.
  2. Different Steps for Different Columns (Freelancer): A ColumnTransformer sends each list of columns through its own steps, so the number columns are filled with the median and standardized while the category columns are filled with the most frequent value and one-hot encoded, columns it isn't given are dropped by default, and as the first step of a pipeline it lets one fit and one predict handle a whole table, with get_feature_names_out listing the columns the model gets.