Utils#

gordo.machine.model.utils.make_base_dataframe(tags: List[SensorTag] | List[str], model_input: ndarray, model_output: ndarray, target_tag_list: List[SensorTag] | List[str] | None = None, index: ndarray | Index | None = None, frequency: timedelta | None = None) DataFrame[source]#

Construct a dataframe which has a MultiIndex column consisting of top level keys ‘model-input’ and ‘model-output’. Takes care of aligning model output if different than model input lengths, as setting column names based on passed tags and target_tag_list.

Parameters:
  • tags – Tags which will be assigned to model-input and/or model-output if the shapes match.

  • model_input – Original input given to the model

  • model_output – Raw model output

  • target_tag_list – Tags to be assigned to model-output if not assigned but model output matches model input, tags will be used.

  • index – The index which should be assigned to the resulting dataframe, will be clipped to the length of model_output, should the model output less than its input.

  • frequency – The spacing of the time between points.

gordo.machine.model.utils.metric_wrapper(metric, scaler: TransformerMixin | None = None)[source]#

Ensures that a given metric works properly when the model itself returns a y which is shorter than the target y, and allows scaling the data before applying the metrics.

Parameters:
  • metric – Metric which must accept y_true and y_pred of the same length

  • scaler – Transformer which will be applied on y and y_pred before the metrics is calculated. Must have method transform, so for most scalers it must already be fitted on y.