yoklainterview sim

ML Engineer Fe Binning Discretization Interview Questions

75 verified ML Engineer Fe Binning Discretization interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Fe Binning DiscretizationDifficulty 1
A numeric column is discretized with equal-width binning into 4 bins. How are the cut points determined?
  • aThe column is sorted and cut after every quarter of the rows, so each bin ends up holding the same number of observations
  • bCut points are searched so that the variance of the target inside each resulting bin is as small as possible
  • cThe four largest gaps between consecutive sorted values are located and the cuts are placed inside those gaps
  • dThe interval between the column minimum and maximum is divided into four stretches of identical length, and however many rows land in each is whatever the data gives
Explanation:Equal-width binning looks only at the extremes of the column: the span max - min is sliced into k pieces of the same width. Occupancy is never consulted, so bin counts can be wildly unbalanced. Target-driven and gap-driven cut placement are different families of rules that ignore the fixed-width constraint entirely.
Fe Binning DiscretizationDifficulty 1
The same numeric column is discretized with equal-frequency (quantile) binning into 4 bins instead. What characterizes the resulting bins?
  • aAll 4 bins span the same numeric width, and the counts inside them are approximately equal as a side effect
  • bBin widths grow geometrically from left to right, which is what balances the counts
  • cThe bins are placed around the 4 densest regions of the column, leaving sparse regions unassigned
  • dThe cut points are the empirical 25th, 50th and 75th percentiles and the counts come out close to equal
Explanation:Quantile binning inverts the equal-width rule: it fixes the number of rows per bin and lets the width float. The cut points are just sample percentiles of the training column, so a dense region gets narrow bins and a long tail gets one very wide bin.
Fe Binning DiscretizationDifficulty 2
With scikit-learn 1.6, a single column holding [0, 1, 2, 3, 10] is passed to KBinsDiscretizer(n_bins=2, encode='ordinal', strategy='uniform', subsample=None). What does fit_transform return?
  • a[0, 0, 0, 1, 1] — the two values furthest from the mean are grouped together in the upper bin
  • b[0, 0, 1, 1, 1] — the cut point sits at the median 2.0, so three values reach the upper bin
  • c[0, 0, 0, 0, 1] — the single cut point is 5.0, so only the value 10 reaches the upper bin
  • d[0, 1, 1, 1, 1] — the smallest value anchors the lower bin and everything above it moves up
Explanation:The uniform strategy places edges at min, midpoint, max, giving [0.0, 5.0, 10.0]. Values 0 through 3 fall below 5.0 and receive code 0; only 10 lands in the upper interval. Nothing in the rule looks at how many rows end up on either side.
Fe Binning DiscretizationDifficulty 2
The same column [0, 1, 2, 3, 10] is now passed to KBinsDiscretizer(n_bins=2, encode='ordinal', strategy='quantile', subsample=None) in scikit-learn 1.6. What does the fitted bin_edges_ array for that feature contain?
  • a[0.0, 2.0, 10.0], because the interior edge is the median of the column
  • b[0.0, 3.2, 10.0], because the interior edge is the arithmetic mean of the five observed values
  • c[0.0, 5.0, 10.0], because the single interior edge is the arithmetic midpoint of the observed range
  • d[1.0, 2.0, 3.0], because only the interior values of the column are used to build the edge array
Explanation:With two quantile bins the single interior cut point is the 50th percentile, which is 2.0 here. The arithmetic mean of the observed values and the midpoint of the observed range are the two rules that would move that cut somewhere else, and neither is what the percentile strategy applies.
Fe Binning DiscretizationDifficulty 2
An income-like column is drawn as np.random.default_rng(0).lognormal(0, 1, 1000) and discretized into 5 equal-width bins with scikit-learn 1.6. Measured on that seed, what does the occupancy of the five bins look like?
  • aRoughly 200 rows in every bin, because a thousand rows is enough for the width rule to even out
  • bAbout 945 rows in the first bin and 43, 10, 1, 1 in the remaining four, since the tail sets the maximum
  • cRoughly 340 rows in each of the first three bins and none in the last two
  • dRoughly 500 rows in the middle bin, about 125 in each of the others, mirroring the bell shape of the data
Explanation:Under a lognormal shape the maximum sits far above the bulk, so the equal-width edges are stretched across a range almost nobody occupies. On this seed the measured counts are 945, 43, 10, 1, 1. Equalized counts are what a percentile-based rule would deliver on the same column.
Fe Binning DiscretizationDifficulty 2
The same lognormal column from the previous setup is re-binned into 5 bins with strategy='quantile' instead. Counts become 200 per bin. What happens to the bin widths?
  • aThey stay identical to the equal-width case, since only the assignment rule changed and not the 6 stored edges
  • bThey become equal to each other but narrower overall, because the extreme values are excluded from the edge computation
  • cThey become extremely unequal: the first bin covers roughly 0.02 to 0.43 while the last one stretches from about 2.17 up to 21.46
  • dThey shrink uniformly by a constant factor such as 0.5, keeping their ratios to one another unchanged
Explanation:Equalizing occupancy forces the widths to absorb the density: where the data is dense the bins are narrow, and the sparse tail is swallowed by a single very wide bin. The measured edges on this seed are approximately 0.02, 0.43, 0.74, 1.19, 2.17, 21.46.

Test yourself against the 1950-question ML Engineer bank.

Start interview