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
ConstructorsConstructorDescriptionModelCard(Model<?> model, Evaluation<?> evaluation) Creates an instance of ModelCard that does not include any extracted metrics and has itsUsageDetailsset to null.Creates an instance of ModelCard that has itsUsageDetailsset 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 ModelCarddeserializeFromJson(com.fasterxml.jackson.databind.JsonNode modelCard) Reads the Json content corresponding to a ModelCard and instantiates it.static ModelCarddeserializeFromJson(Path sourceFile) Reads the Json content corresponding to a ModelCard from file and instantiates it.booleanGets theModelDetailsof the ModelCard object.Gets theTestingDetailsof the ModelCard object.Gets theTrainingDetailsof the ModelCard object.Gets theUsageDetailsof the ModelCard object, which may be null.inthashCode()voidsaveToFile(Path destinationFile) Serializes and saves the ModelCard object to the specified path.com.fasterxml.jackson.databind.node.ObjectNodetoJson()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
IllegalArgumentExceptionif the model is an external model trained outside Tribuo.- Parameters:
model- The trained model for which a model card will be built.evaluation- AnEvaluationobject for the trained model.testingMetrics- A map of metric descriptions paired with their corresponding metric values for the trained model.usage- AUsageDetailsobject 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- AnEvaluationobject for the trained model.usage- AUsageDetailsobject specifying the usage details of the trained model.
-
ModelCard
Creates an instance of ModelCard that has itsUsageDetailsset to null.- Parameters:
model- The trained model for which a model card will be built.evaluation- AnEvaluationobject 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 itsUsageDetailsset to null.- Parameters:
model- The trained model for which a model card will be built.evaluation- AnEvaluationobject 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
ModelCardobject 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 theModelDetailsof the ModelCard object.- Returns:
- The
ModelDetailsof the ModelCard object.
-
getTrainingDetails
Gets theTrainingDetailsof the ModelCard object.- Returns:
- The
TrainingDetailsof the ModelCard object.
-
getTestingDetails
Gets theTestingDetailsof the ModelCard object.- Returns:
- The
TestingDetailsof the ModelCard object.
-
getUsageDetails
Gets theUsageDetailsof the ModelCard object, which may be null.- Returns:
- The
UsageDetailsof the ModelCard object.
-
toJson
public com.fasterxml.jackson.databind.node.ObjectNode toJson()Creates a Json object corresponding this ModelCard instance.- Returns:
- The
ObjectNodecorresponding 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
-