All problems

Sizing Random Forest's Feature Subsampling

mediumPythonEnsembles & Regularization

A random forest at Ardwick Mutual stops its trees turning into copies of each other by hiding most of the features from each of them. Every time a tree reaches a point where it has to decide what to split its claims on, it is shown only a random handful of the available features and has to pick from those — so one dominant feature cannot head every tree in the forest. How large that handful is comes from a fraction of the feature total, set once for the whole forest. However small the fraction, a tree can never be left with nothing to choose between.

Task: Print how many features a tree gets to choose from at each split.

Input

One line holding two values separated by a single space: the total number of features as a whole number, then the fraction, a number between 0 and 1.

Output

One line holding the number of features considered at a split. The fraction of the total is cut down to a whole number of features by discarding everything after the decimal point, not by rounding to the nearest and not by rounding up — a handful working out at 2.8 features is 2 features. If that leaves none at all, one feature is considered instead.

Example:

Input:
100 0.25

Output:
25

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…