Handle Variable Discretisation

Feature-engine, a Python library for feature engineering

1 min read

Published Oct 3 2025


10
0
0
0

Feature EngineeringFeature-engineMachine LearningPandasPythonscikit-learnTransformers

This technique consists of transforming continuous numerical variables into discrete variables. Often referred to as binning as it creates bins to group values together.


Equal Frequency

It divides continuous numerical variables into contiguous equal frequency intervals, intervals containing approximately the same proportion of observations.


Parameters:

  • q : quantities - the number of equal frequency intervals.
eqf = EqualFrequencyDiscretiser(q=5, variables=['target']

This will create 5 bins of values. You can look at the calculated bins by looking at eqf.binner_dict_ which will show something like {'target': [-inf, 1.072, 1.573, 2.094, 2.9, inf]}






Equal Width

This technique divides continuous numerical variables into intervals of the same width. Each bin will probably have different counts.


Parameters:

  • bins : The number of equal width bins required.
ewd = EqualWidthDiscretiser(bins=6, variables=['target'])

This will create 6, equal width bins. The bin ranges can be viewed by looking at ewd.binner_dict_ which will show something like {'target': [-inf, 0.9583266666666665, 1.7666633333333333, 2.5749999999999997, 3.383336666666666, 4.191673333333333, inf]}






Arbitrary Discretiser

It divides continuous range intervals, which limits are determined by the user.


Parameters:

  • binning_dict - A dictionary object with the column and the user defined bin intervals.
ad = ArbitraryDiscretiser(binning_dict={'target':[0, 2, 4, 6, np.inf]})

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact