trustyai.model.counterfactual_prediction
- trustyai.model.counterfactual_prediction(input_features: int | float | integer | inexact | ndarray | DataFrame | Series | List[Feature] | PredictionInput, outputs: int | float | integer | inexact | ndarray | DataFrame | Series | List[Output] | PredictionOutput | None = None, feature_names: List[str] | None = None, output_names: List[str] | None = None, data_distribution: DataDistribution | None = None, uuid: UUID | None = None, timeout: float | None = None, criteria: GoalCriteria | None = None) CounterfactualPrediction
Wrap features and outputs into a CounterfactualPrediction. Given a list of features and outputs, this function will bundle them into Prediction objects for use with the
CounterfactualExplainer.- Parameters:
- input_featuresint, float,
numpy.number, List[Union[int, float,numpy.number]],numpy.ndarray,pandas.DataFrame,pandas.Series, List[Feature], orPredictionInput List of input features, as a:
If there’s only a single input feature, an
int,float, or any of the Numpy equivalents can be used.A list of
int,float, or any of the Numpy equivalents.Numpy array of shape
[1, n_features]or[n_features]Pandas DataFrame with 1 row and
n_featurescolumnsPandas Series with n_features rows
A List of TrustyAI
Feature, as created by thefeature()functionA TrustyAI
PredictionInput
- outputsint, float,
numpy.number, List[Union[int, float,numpy.number]],numpy.ndarray,pandas.DataFrame,pandas.Series, List[Output], orPredictionOutput The desired model outputs to be searched for in the counterfactual explanation. These can take the form of a:
If there’s only a single output, an
int,float, or any of the Numpy equivalents can be used.A list of
int,float, or any of the Numpy equivalents.Numpy array of shape
[1, n_outputs]or[n_outputs]Pandas DataFrame with 1 row and
n_outputscolumnsPandas Series with n_outputs rows
A List of TrustyAI
Output, as created by theoutput()functionA TrustyAI
PredictionOutput
- feature_names: Optional[List[str]]
The names of the features, in the case where the feature object does not contain them
- output_names: Optional[List[str]]
The names of the outputs, in the case where the outputobject does not contain them
- data_distributionOptional[
DataDistribution] The
DataDistributionto use when sampling the inputs.- uuidOptional[
_uuid.UUID] The UUID to use during search.
- timeoutOptional[float]
The timeout time in seconds of the counterfactual explanation.
- criteriaOptional[
GoalCriteria] An optional custom scoring function, wrapped as a
GoalCriteria.
- input_featuresint, float,