SteveOv / ebop_maven

EBOP Model Automatic input Value Estimation Neural network
GNU General Public License v3.0
1 stars 0 forks source link

review re-scaling code in estimator.predict() #65

Closed SteveOv closed 2 months ago

SteveOv commented 2 months ago

The code which rescales the predictions in the estimator predict() function looks like;

        # Undo any scaling applied to the labels (e.g. the model predicts inc/100)
        if unscale:
            raw_preds /= [*self._labels_and_scales.values()]

Given that the raw_preds is a 3-d array of size (iters, insts, predictions) I'm concerned that this is not exlicitly told how to apply the scaling (effectively over the last axis). I think what's happening is that the axis is chosen because it matches the size of _labels_and_scales. My worry is that this may run into problems if the number of instances or the number of iterations matches the number of _labels_and_scales.

SteveOv commented 2 months ago

I've tested this and it's not a problem.

Looking at this more closely, I can see that the numpy broadcasting algorithm will work from the last to first dimension, to match the two arrays.

What is happening is exactly what needs to happen.

For more info, see https://numpy.org/doc/stable/user/basics.broadcasting.html