Dimas Mukhlas Widiantoro

Welcome To dimasmukhlas.com

I am Dimas Mukhlas Widiantoro, a seasoned growth expert with 12 years of experience growing Brainly. I share my expertise in growth strategies, user acquisition, and product development. View my complete portfolio at codify.my.id

How the process of data pipeline in machine learning

 Based on book of Geron 

Here is some example of preparation when we want to run some process on machine learning before we choose the model.

#lets create the data pipeline


from sklearn.pipeline import Pipeline 

from sklearn.preprocessing import StandardScaler 


num_pipeline = Pipeline([

    ('imputer', SimpleImputer(strategy="median")),

    ('attribs_adder', CombinedAttributesAdder()),

    ('std_scaler', StandardScaler()),

]


)


housing_num_tr = num_pipeline.fit_transform(housing_num)


and the idea why this process exist is 



This code builds a data-cleaning machine (a pipeline) that automatically prepares your data before training a machine-learning model.


Instead of cleaning data step by step manually,

➡️ The pipeline does all steps in the correct order, every time.


🧱 What the pipeline contains (in plain English)


1. Imputer

('imputer', SimpleImputer(strategy="median"))

  • Fills empty or missing values in your dataset

  • Uses the median of the column

  • Make sure the model won’t crash because of missing data


👉 Like filling empty boxes so everything is complete.


2. Attribute Adder

('attribs_adder', CombinedAttributesAdder())

  • Adds new useful features (like rooms per household, etc.)

  • Helps the model learn better patterns

  • You wrote this transformer earlier


👉 Like adding extra helpful information the model didn’t have before.


3. Standard Scaler

('std_scaler', StandardScaler())

  • Makes all numbers on a similar scale (mean 0, std 1)

  • Prevents big numbers from dominating small numbers

  • Important for many ML algorithms


👉 Like making all features “fair” before the model uses them.


📦 

Putting it all together: Pipeline

num_pipeline = Pipeline([ ... ])

The pipeline arranges all steps in the correct order:

  1. Fix missing values

  2. Add new attributes

  3. Scale the features


👉 Think of it like a factory assembly line for data.


🚀 

Finally, run the pipeline on the data

housing_num_tr = num_pipeline.fit_transform(housing_num)

This:

  • Fits the pipeline

  • Transforms the data

  • Returns the cleaned, improved numeric dataset


👉 Now your data is ready for the model.


🧠 

In one simple sentence:


And how it runs in model 




Post a Comment

0 Comments