Class XGBoostClassificationConverter
java.lang.Object
org.tribuo.classification.xgboost.XGBoostClassificationConverter
- All Implemented Interfaces:
Serializable
,XGBoostOutputConverter<Label>
,ProtoSerializable<org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto>
public final class XGBoostClassificationConverter
extends Object
implements XGBoostOutputConverter<Label>
Converts XGBoost outputs into
Label
Prediction
s.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionConstructs an XGBoostClassificationConverter. -
Method Summary
Modifier and TypeMethodDescriptionconvertBatchOutput
(ImmutableOutputInfo<Label> info, List<float[][]> probabilitiesList, int[] numValidFeatures, Example<Label>[] examples) Converts a list of float arrays from XGBoost Boosters into a TribuoPrediction
.convertOutput
(ImmutableOutputInfo<Label> info, List<float[]> probabilitiesList, int numValidFeatures, Example<Label> example) Converts a list of float arrays from XGBoost Boosters into a TribuoPrediction
.deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
Does this converter produce probabilities?Gets the type witness for the output this converter uses.org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto
Serializes this object to a protobuf.
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
XGBoostClassificationConverter
public XGBoostClassificationConverter()Constructs an XGBoostClassificationConverter.
-
-
Method Details
-
deserializeFromProto
public static XGBoostClassificationConverter 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 interfaceXGBoostOutputConverter<Label>
- Returns:
- True if it produces probabilities.
-
convertOutput
public Prediction<Label> convertOutput(ImmutableOutputInfo<Label> info, List<float[]> probabilitiesList, int numValidFeatures, Example<Label> example) Description copied from interface:XGBoostOutputConverter
Converts a list of float arrays from XGBoost Boosters into a TribuoPrediction
.- Specified by:
convertOutput
in interfaceXGBoostOutputConverter<Label>
- Parameters:
info
- The output info.probabilitiesList
- 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<Label>> convertBatchOutput(ImmutableOutputInfo<Label> info, List<float[][]> probabilitiesList, int[] numValidFeatures, Example<Label>[] examples) Description copied from interface:XGBoostOutputConverter
Converts a list of float arrays from XGBoost Boosters into a TribuoPrediction
.- Specified by:
convertBatchOutput
in interfaceXGBoostOutputConverter<Label>
- Parameters:
info
- The output info.probabilitiesList
- 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 interfaceProtoSerializable<org.tribuo.common.xgboost.protos.XGBoostOutputConverterProto>
- Returns:
- The protobuf.
-
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 interfaceXGBoostOutputConverter<Label>
- Returns:
- The class of the output.
-