Package org.tribuo.interop.modelcard
Class ModelCard
java.lang.Object
org.tribuo.interop.modelcard.ModelCard
ModelCard feature to allow more transparent model reporting.
See:
M. Mitchell et al. "Model Cards for Model Reporting" In Conference in Fairness, Accountability, and Transparency, 2019.
At the moment, the ModelCard system only supports models trained within Tribuo and throws an error for all external models.
-
Constructor Summary
ConstructorDescriptionModelCard
(Model<?> model, Evaluation<?> evaluation) Creates an instance of ModelCard that does not include any extracted metrics and has itsUsageDetails
set to null.Creates an instance of ModelCard that has itsUsageDetails
set to null.ModelCard
(Model<?> model, Evaluation<?> evaluation, Map<String, Double> testingMetrics, UsageDetails usage) Creates an instance of ModelCard.ModelCard
(Model<?> model, Evaluation<?> evaluation, UsageDetails usage) Creates an instance of ModelCard that does not include any extracted metrics. -
Method Summary
Modifier and TypeMethodDescriptionstatic ModelCard
deserializeFromJson
(com.fasterxml.jackson.databind.JsonNode modelCard) Reads the Json content corresponding to a ModelCard and instantiates it.static ModelCard
deserializeFromJson
(Path sourceFile) Reads the Json content corresponding to a ModelCard from file and instantiates it.boolean
Gets theModelDetails
of the ModelCard object.Gets theTestingDetails
of the ModelCard object.Gets theTrainingDetails
of the ModelCard object.Gets theUsageDetails
of the ModelCard object, which may be null.int
hashCode()
void
saveToFile
(Path destinationFile) Serializes and saves the ModelCard object to the specified path.com.fasterxml.jackson.databind.node.ObjectNode
toJson()
Creates a Json object corresponding this ModelCard instance.toString()
-
Constructor Details
-
ModelCard
public ModelCard(Model<?> model, Evaluation<?> evaluation, Map<String, Double> testingMetrics, UsageDetails usage) Creates an instance of ModelCard.Throws
IllegalArgumentException
if the model is an external model trained outside Tribuo.- Parameters:
model
- The trained model for which a model card will be built.evaluation
- AnEvaluation
object for the trained model.testingMetrics
- A map of metric descriptions paired with their corresponding metric values for the trained model.usage
- AUsageDetails
object specifying the usage details of the trained model.
-
ModelCard
Creates an instance of ModelCard that does not include any extracted metrics.- Parameters:
model
- The trained model for which a model card will be built.evaluation
- AnEvaluation
object for the trained model.usage
- AUsageDetails
object specifying the usage details of the trained model.
-
ModelCard
Creates an instance of ModelCard that has itsUsageDetails
set to null.- Parameters:
model
- The trained model for which a model card will be built.evaluation
- AnEvaluation
object for the trained model.testingMetrics
- A map of metric descriptions paired with their corresponding metric values for the trained model.
-
ModelCard
Creates an instance of ModelCard that does not include any extracted metrics and has itsUsageDetails
set to null.- Parameters:
model
- The trained model for which a model card will be built.evaluation
- AnEvaluation
object for the trained model.
-
-
Method Details
-
deserializeFromJson
Reads the Json content corresponding to a ModelCard from file and instantiates it.- Parameters:
sourceFile
- The Json file path corresponding to a serialized ModelCard.- Returns:
- A
ModelCard
object corresponding to the provided serialized ModelCard. - Throws:
IOException
- If the model card could not be read from the path, or the Json failed to parse.
-
deserializeFromJson
public static ModelCard deserializeFromJson(com.fasterxml.jackson.databind.JsonNode modelCard) throws com.fasterxml.jackson.core.JsonProcessingException Reads the Json content corresponding to a ModelCard and instantiates it.- Parameters:
modelCard
- The Json content corresponding to a serialized ModelCard that will be used to recreate a new instance of a ModelCard.- Returns:
- A ModelCard object corresponding to the provided serialized ModelCard.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if a problem is encountered when processing Json content.
-
getModelDetails
Gets theModelDetails
of the ModelCard object.- Returns:
- The
ModelDetails
of the ModelCard object.
-
getTrainingDetails
Gets theTrainingDetails
of the ModelCard object.- Returns:
- The
TrainingDetails
of the ModelCard object.
-
getTestingDetails
Gets theTestingDetails
of the ModelCard object.- Returns:
- The
TestingDetails
of the ModelCard object.
-
getUsageDetails
Gets theUsageDetails
of the ModelCard object, which may be null.- Returns:
- The
UsageDetails
of the ModelCard object.
-
toJson
public com.fasterxml.jackson.databind.node.ObjectNode toJson()Creates a Json object corresponding this ModelCard instance.- Returns:
- The
ObjectNode
corresponding to this ModelCard instance.
-
saveToFile
Serializes and saves the ModelCard object to the specified path.- Parameters:
destinationFile
- The file path to which the serialized ModelCard will be saved.- Throws:
IOException
- if a problem is encountered when processing Json content or writing the file.
-
toString
-
equals
-
hashCode
public int hashCode()
-