Call WhatsApp Enquiry

Everything About Data Preprocessing

Data Preprocessing:

Introduction to Data Preprocessing:- Before modeling the data we need to clean the information to get a training sample for the modeling. Data preprocessing is a data mining technique that involves transforming the raw data into an understandable format. It provides the technique for cleaning the data from the real world which is often incomplete, inconsistent, lacking accuracy and more likely to contain many errors. Preprocessing provides clean information before it gets to the modeling phase.

Preprocessing of data in a stepwise fashion in scikit learn.

1.Introduction to Preprocessing:

  • Learning algorithms have an affinity towards a certain pattern of data.
  • Unscaled or unstandardized data have might have an unacceptable prediction.
  • Learning algorithms understand the only number, converting text image to number is required.
  • Preprocessing refers to transformation before feeding to machine learning.

2. StandardScaler

  • The StandardScaler assumes your data is normally distributed within each feature and will scale them such that the distribution is now centered around 0, with a standard deviation of 1.
  • Calculate – Subtract mean of column & div by the standard deviation
  • If data is not normally distributed, this is not the best scaler to use.

StandardScaler Formula

3. MinMaxScaler

  • Calculate – Subtract min of column & div by the difference between max & min
  • Data shifts between 0 & 1
  • If distribution not suitable for StandardScaler, this scaler works out.
  • Sensitive to outliers.

MinMaxScaler Formula

4. Robust Scaler

  • Suited for data with outliers
  • Calculate by subtracting 1st-quartile & div by difference between 3rd-quartile & 1st-quartile.

Robust Scaler Formula

5. Normalizer

  • Each parameter value is obtained by dividing by magnitude.
  • Enabling you to more easily compare data from different places.

Normalizer Formula

6. Binarization

  • Thresholding numerical values to binary values ( 0 or 1 )
  • A few learning algorithms assume data to be in Bernoulli distribution – Bernoulli’s Naive Bayes

7. Encoding Categorical Value

  • Ordinal Values – Low, Medium & High. Relationship between values
  • LabelEncoding with the right mapping

8. Imputation

  • Missing values cannot be processed by learning algorithms
  • Imputers can be used to infer the value of missing details from existing data

9. Polynomial Features

  • Deriving non-linear feature by converting information into a higher degree
  • Used with linear regression to learn a model of higher degree

10. Custom Transformer

  • Often, you will want to convert an existing Python function into a transformer to assist in data cleaning or processing.
  • FunctionTransformer is used to create one Transformer
  • validate = False, is required for the string column.

11. Text Processing

  • Perhaps one of the most common information
  • Learning algorithms don’t understand the text but only numbers
  • Below methods convert text to numbers

12. CountVectorizer

  • Each column represents one word, count refers to the frequency of the word
  • A sequence of words is not maintained


  • n_grams – Number of words considered for each column
  • stop_words – words not considered
  • vocabulary – only words considered

13. TfIdfVectorizer

  • Words occurring more frequently in a doc versus entire corpus is considered more important
  • The importance is on the scale of 0 & 1

14. HashingVectorizer

  • All the above techniques convert information into a table where each word is converted to column
  • Learning on data with lakhs of columns is difficult to process
  • HashingVectorizer is a useful technique for out-of-core learning
  • Multiple words are hashed to limited column
  • Limitation – Hashed value to word mapping is not possible

15. Image Processing using skimage

  • skimage doesn’t come with anaconda. install with ‘pip install skimage’
  • Images should be converted from 0-255 scale to 0-1 scale.
  • skimage takes image path & returns numpy array
  • images consist of 3 dimensions.

#iguru_button_61f231c70a4c5 .wgl_button_link { color: rgba(255,255,255,1); }#iguru_button_61f231c70a4c5 .wgl_button_link:hover { color: rgba(255,255,255,1); }#iguru_button_61f231c70a4c5 .wgl_button_link { border-color: transparent; background-color: rgba(255,149,98,1); }#iguru_button_61f231c70a4c5 .wgl_button_link:hover { border-color: rgba(230,95,42,1); background-color: rgba(253,185,0,1); }#iguru_button_61f231c70ba6b .wgl_button_link { color: rgba(255,255,255,1); }#iguru_button_61f231c70ba6b .wgl_button_link:hover { color: rgba(255,255,255,1); }#iguru_button_61f231c70ba6b .wgl_button_link { border-color: rgba(218,0,0,1); background-color: rgba(218,0,0,1); }#iguru_button_61f231c70ba6b .wgl_button_link:hover { border-color: rgba(218,0,0,1); background-color: rgba(218,0,0,1); }#iguru_button_61f231c7103c3 .wgl_button_link { color: rgba(241,241,241,1); }#iguru_button_61f231c7103c3 .wgl_button_link:hover { color: rgba(250,249,249,1); }#iguru_button_61f231c7103c3 .wgl_button_link { border-color: rgba(102,75,196,1); background-color: rgba(48,90,169,1); }#iguru_button_61f231c7103c3 .wgl_button_link:hover { border-color: rgba(102,75,196,1); background-color: rgba(57,83,146,1); }#iguru_soc_icon_wrap_61f231c71802c a{ background: transparent; }#iguru_soc_icon_wrap_61f231c71802c a:hover{ background: transparent; border-color: #3aa0e8; }#iguru_soc_icon_wrap_61f231c71802c a{ color: #acacae; }#iguru_soc_icon_wrap_61f231c71802c a:hover{ color: #ffffff; }#iguru_soc_icon_wrap_61f231c71802c { display: inline-block; }.iguru_module_social #soc_icon_61f231c7180681{ color: #ffffff; }.iguru_module_social #soc_icon_61f231c7180681:hover{ color: #ffffff; }.iguru_module_social #soc_icon_61f231c7180681{ background: #44b1e4; }.iguru_module_social #soc_icon_61f231c7180681:hover{ background: #44b1e4; }
Get The Learnbay Advantage For Your Career
Overlay Image
Everything About Data Preprocessing" data-page-url="">