Coding Challenge - Extremely Randomized Trees
For this exercise, you'll be debugging the provided implementation of an algorithm introduced by Geurts et al. (2006) called Extremely Randomized Trees.
The algorithm is mostly functional, but currently has some bugs that cause it to sometimes crash and sometimes get poor accuracy.
You won't need to read the paper; the algorithm is described in the source code of:
trees.pyYour objective is to ensure the correctness of the implementation in:
trees.pyUnit tests are provided in:
test_trees.pyYou are encouraged to read the tests and write additional tests, but do not modify the existing tests or docstrings — treat them as correct.
If you want to modify a test case, copy it into a new script and make your changes there.
Your code does not need to be optimized for execution speed, but avoid making the code dramatically slower. For example, don't replace vectorized NumPy operations with nested for loops.
I recommend running the unit tests to start with:
python tests/test_trees.pyand working backwards from the failing tests.
The CodeSignal platform can hang if your code has an infinite loop. Watch out for this and refresh the window and/or kill the terminal if this happens.
You should make the tests pass by fixing the underlying issue in the code. You should not “hack” the tests, for example by hardcoding checks for certain input data, or overriding assertion methods to always pass.
Hint: all test cases are of equal point value, but I found:
test_small_featuresand
test_ensemblethe most difficult, so you may want to leave them until the end.
Permitted Resources
You may search and consult documentation.
In particular, the NumPy documentation may be useful.
You may not use or refer to:
- any other third-party libraries such as scikit-learn
- existing decision tree implementations
- AI assistance, except that AI overview search results in Google are permitted
Debugging Methods
You may use any debugging methods, including print statements, the REPL, and terminal-based debuggers.
I recommend not using the CodeSignal graphical debugger, as it has multiple severe issues.
To use breakpoints with pdb, add the following statement into your source code:
breakpoint()Then execute:
pytest -k test_name --pdbin the terminal to run a specific test.
Or run:
pytest --pdbto run all tests.
The Run button will hang if it hits a breakpoint.
To use the REPL, run:
ipythonat the terminal.
You can use the following snippet so that changes to:
trees.pyautomatically take effect in your REPL:
%load_ext autoreload
%autoreload 2
from trees import *Limits
execution time limit: 30 seconds
memory limit: 4g
我们长期稳定承接各大科技公司如Capital One、TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

