pyreal.explanation_types.example_based.SimilarExampleExplanation#

class pyreal.explanation_types.example_based.SimilarExampleExplanation(explanation, values=None)[source]#

A type wrapper for explanations that include most similar rows from the training set.

Contains a dict of dataframes

__init__(explanation, values=None)#

Set the wrapped explanation to explanation and values to values and validate :param explanation: wrapped explanation :type explanation: object :param values: Values corresponding with the object being explained :type values: DataFrame of shape (n_instances, n_features) or None

Methods

__init__(explanation[, values])

Set the wrapped explanation to explanation and values to values and validate :param explanation: wrapped explanation :type explanation: object :param values: Values corresponding with the object being explained :type values: DataFrame of shape (n_instances, n_features) or None

apply_feature_descriptions(feature_descriptions)

No-op because feature descriptions are applied at produce time for similar examples explanation, to improve performance

get()

Get the explanation wrapped by this type.

get_all()

Get the explanation and wrapped values as a tuple.

get_examples([row_id, rank])

Get the example in rank-th position for the given row_id. :param row_id: ID of row to get explanation of. :type row_id: int :param rank: Which example to return (ie, rank=0 returns the first example generated). If none, return all examples :type rank: int.

get_explanation()

Get the explanation wrapped by this type

get_row_ids()

Return all row_ids held by this explanation

get_targets([row_id, rank])

Get the targets in rank-th position for the given row_id. :param row_id: ID of row to get explanation of. :type row_id: int :param rank: Which example to return (ie, rank=0 returns the first example generated). If none, return all examples :type rank: int.

get_values()

Return the values associated with the explanation

update_examples(func[, inplace])

Update every example using the provided function :param func: Function to apply to every example :type func: function :param inplace: If True, change the explanation on this object. Otherwise, create a new object identical to this one but with a new explanation :type inplace: Boolean.

update_explanation(new_explanation[, ...])

Sets this object's explanation to the new value.

update_values(values[, inplace])

Updates this objects values, and validates

validate()

Validate that self.explanation is a valid dict of DataFrames :returns: None

validate_values()

Validate that self.values are valid values for this Explanation.