Class XGBoostRegressionConverter

java.lang.Object
org.tribuo.regression.xgboost.XGBoostRegressionConverter
All Implemented Interfaces:
Serializable, XGBoostOutputConverter<Regressor>, ProtoSerializable<org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto>

public final class XGBoostRegressionConverter extends Object implements XGBoostOutputConverter<Regressor>
Converts XGBoost outputs into Regressor Predictions.

Instances of this class are stateless and thread-safe.

See Also:
  • Field Details

    • CURRENT_VERSION

      public static final int CURRENT_VERSION
      Protobuf serialization version.
      See Also:
  • Constructor Details

    • XGBoostRegressionConverter

      public XGBoostRegressionConverter()
      Construct an XGBoostRegressionConverter.
  • Method Details

    • deserializeFromProto

      public static XGBoostRegressionConverter deserializeFromProto(int version, String className, com.google.protobuf.Any message)
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
    • generatesProbabilities

      public boolean generatesProbabilities()
      Description copied from interface: XGBoostOutputConverter
      Does this converter produce probabilities?
      Specified by:
      generatesProbabilities in interface XGBoostOutputConverter<Regressor>
      Returns:
      True if it produces probabilities.
    • convertOutput

      public Prediction<Regressor> convertOutput(ImmutableOutputInfo<Regressor> info, List<float[]> probabilities, int numValidFeatures, Example<Regressor> example)
      Description copied from interface: XGBoostOutputConverter
      Converts a list of float arrays from XGBoost Boosters into a Tribuo Prediction.
      Specified by:
      convertOutput in interface XGBoostOutputConverter<Regressor>
      Parameters:
      info - The output info.
      probabilities - The XGBoost output.
      numValidFeatures - The number of valid features used in the prediction.
      example - The example this prediction was generated from.
      Returns:
      The prediction object.
    • convertBatchOutput

      public List<Prediction<Regressor>> convertBatchOutput(ImmutableOutputInfo<Regressor> info, List<float[][]> probabilities, int[] numValidFeatures, Example<Regressor>[] examples)
      Description copied from interface: XGBoostOutputConverter
      Converts a list of float arrays from XGBoost Boosters into a Tribuo Prediction.
      Specified by:
      convertBatchOutput in interface XGBoostOutputConverter<Regressor>
      Parameters:
      info - The output info.
      probabilities - The XGBoost output, list dimension is across models, first array dimension is across examples, second array dimension is across outputs.
      numValidFeatures - The number of valid features used in each prediction.
      examples - The examples these predictions were generated from.
      Returns:
      The prediction object.
    • serialize

      public org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto serialize()
      Description copied from interface: ProtoSerializable
      Serializes this object to a protobuf.
      Specified by:
      serialize in interface ProtoSerializable<org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto>
      Returns:
      The protobuf.
    • getTypeWitness

      public Class<Regressor> getTypeWitness()
      Description copied from interface: XGBoostOutputConverter
      Gets the type witness for the output this converter uses.

      The default implementation throws UnsupportedOperationException for compatibility with subclasses which don't support protobuf serialization.

      Specified by:
      getTypeWitness in interface XGBoostOutputConverter<Regressor>
      Returns:
      The class of the output.