Python and NumPy
Reuse the training reference on another report
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Calculate the mean of the training readings, subtract it from the new report, and collect the reference and transformed report together in that order.
A reusable transformation should return both the training reference and the new report expressed relative to it. Botie needs a clear output contract.
Compute the training mean, subtract it from the new report, and collect the mean before the transformed report.
Examples and results
- Training readings
- 010
- 114
- New report
- 012
- 118
- Required result
[ 12, [ 0, 6 ] ]
- Training readings
- 08
- 112
- 216
- New report
- 011
- 117
- Required result
[ 12, [ -1, 5 ] ]
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
Workshop cases satisfy the finite, nonempty vector contract. Python is where we define functions and handle invalid inputs. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Repeated training values and a centred report
This check uses the pieces from “Return a reference with the values it explains”.
BOTIE
- Training readings
- 04
- 14
- 210
- New report
- 06
- 16
- 20
Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
What inputs and output order would you state before translating this construction into a Python function?
Specify a reusable calculation's fitted state, transformed output and invalid-input behaviour separately.
Workshop cases satisfy the finite, nonempty vector contract. Python is where we define functions and handle invalid inputs.
Work through the Python challenges →