raster_tools.general.model_predict_vector#

raster_tools.general.model_predict_vector(features, model, fields, n_outputs=1, out_prefix='pred_')[source]#

Predict new columns using a model.

features’ values are used as predictors for the model to produce new predictions. The resulting predictions are used to create a new vector with the results appended as new columns.

The model argument must provide a predict method. If the desired model does not provide a predict function, ModelPredictAdaptor can be used to wrap it and make it compatible with this function. information.

Parameters
  • features (vector or path str) – Vector with attribute columns.

  • model (object) – The model used to estimate new values. It must have a predict method that takes an array-like object of shape (N, M), where N is the number of samples and M is the number of features/predictor variables. The predict method should return an (N, [n_outputs]) shape result. If only one variable is resurned, then the n_outputs dimension is optional.

  • fields (list of str) – The names of columns used in the model

  • n_outputs (int, optional) – The number of output variables from the model. Each output variable produced by the model is converted to a band in the output raster. The default is 1.

  • out_prefix (str, optional) – The prefix to use when naming the resulting column(s). The prefix will be combined with the 1-based number of the output variable. The Default is “pred_”.

Returns

The resulting vector with estimated values appended as a columns (pred_1, pred_2, pred_3 …).

Return type

Vector