Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions howso/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,10 @@ def react( # noqa: C901
Uses only the context features of the reacted case to determine that area.
Uses full calculations, which uses leave-one-out context features for
computations.
- relevant_values : bool or list of strings, optional
When true outputs a map of each context feature name to a list of relevant values for that
feature given the context. If a list of feature names, will only output relevant values for
each feature specified.
- selected_prediction_stats : list, optional.
List of stats to output. When unspecified, returns all except the confusion matrix. Allowed values:

Expand Down Expand Up @@ -2263,15 +2267,6 @@ def react( # noqa: C901
" following values - ['min', 'max', 'most_similar',]"
)

if details is not None and 'robust_computation' in details:
details = dict(details)
details['robust_influences'] = details['robust_computation']
details['robust_residuals'] = details['robust_computation']
del details['robust_computation']
warnings.warn(
'The detail "robust_computation" is deprecated and will be '
'removed in a future release. Please use "robust_residuals" '
'and/or "robust_influences" instead.', DeprecationWarning)

if details is not None and 'local_case_feature_residual_conviction_robust' in details:
details = dict(details)
Expand Down Expand Up @@ -2752,7 +2747,7 @@ def _preprocess_generate_parameters( # noqa: C901
target_context_values = context_values[i]

if context_features and (
not target_context_values or
target_context_values is None or
not isinstance(target_context_values, Sized) or
len(target_context_values) != len(context_features)
):
Expand Down Expand Up @@ -3906,6 +3901,10 @@ def react_aggregate( # noqa: C901
Compute accuracy contributions by scrambling each feature and
using the robust (power set/permutations) set of remaining
context features for each prediction.
- relevant_values : bool or list of strings, optional
When true outputs a map of each context feature name to a list of relevant values for that
feature given the context. If a list of feature names, will only output relevant values for
each feature specified.
- action_condition : map of str -> any, optional
A condition map to select the action set, which is the collection of cases
reacted to while computing the requested metrics.
Expand Down Expand Up @@ -4917,19 +4916,19 @@ def set_auto_ablation_params(
auto_ablation_enabled: bool = False,
*,
ablated_cases_distribution_batch_size: int = 100,
abs_threshold_map: AblationThresholdMap = None,
abs_threshold_map: t.Optional[AblationThresholdMap] = None,
auto_ablation_influence_weight_entropy_threshold: float = 0.15,
auto_ablation_weight_feature: str = ".case_weight",
batch_size: int = 2_000,
conviction_lower_threshold: t.Optional[float] = None,
conviction_upper_threshold: t.Optional[float] = None,
delta_threshold_map: AblationThresholdMap = None,
delta_threshold_map: t.Optional[AblationThresholdMap] = None,
exact_prediction_features: t.Optional[Collection[str]] = None,
influence_weight_entropy_sample_size: int = 2_000,
min_num_cases: int = 10_000,
max_num_cases: int = 200_000,
reduce_data_influence_weight_entropy_threshold: float = 0.6,
rel_threshold_map: AblationThresholdMap = None,
rel_threshold_map: t.Optional[AblationThresholdMap] = None,
relative_prediction_threshold_map: t.Optional[Mapping[str, float]] = None,
residual_prediction_features: t.Optional[Collection[str]] = None,
tolerance_prediction_threshold_map: t.Optional[Mapping[str, tuple[float, float]]] = None,
Expand Down
2 changes: 1 addition & 1 deletion howso/client/schemas/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Reaction(abc.MutableMapping):
"observational_errors",
"outlying_feature_values",
"prediction_stats",
"robust_influences",
"relevant_values",
"similarity_conviction",
# react_series-only details
"aggregated_categorical_action_probabilities",
Expand Down
14 changes: 11 additions & 3 deletions howso/engine/trainee.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,19 +760,19 @@ def set_auto_ablation_params(
auto_ablation_enabled: bool = False,
*,
ablated_cases_distribution_batch_size: int = 100,
abs_threshold_map: AblationThresholdMap = None,
abs_threshold_map: t.Optional[AblationThresholdMap] = None,
auto_ablation_influence_weight_entropy_threshold: float = 0.15,
auto_ablation_weight_feature: str = ".case_weight",
batch_size: int = 2_000,
conviction_lower_threshold: t.Optional[float] = None,
conviction_upper_threshold: t.Optional[float] = None,
delta_threshold_map: AblationThresholdMap = None,
delta_threshold_map: t.Optional[AblationThresholdMap] = None,
exact_prediction_features: t.Optional[Collection[str]] = None,
influence_weight_entropy_sample_size: int = 2_000,
min_num_cases: int = 10_000,
max_num_cases: int = 200_000,
reduce_data_influence_weight_entropy_threshold: float = 0.6,
rel_threshold_map: AblationThresholdMap = None,
rel_threshold_map: t.Optional[AblationThresholdMap] = None,
relative_prediction_threshold_map: t.Optional[Mapping[str, float]] = None,
residual_prediction_features: t.Optional[Collection[str]] = None,
tolerance_prediction_threshold_map: t.Optional[Mapping[str, tuple[float, float]]] = None,
Expand Down Expand Up @@ -1607,6 +1607,10 @@ def react(
Uses only the context features of the reacted case to determine that area.
Uses full calculations, which uses leave-one-out context features for
computations.
- relevant_values : bool or list of strings, optional
When true outputs a map of each context feature name to a list of relevant values for that
feature given the context. If a list of feature names, will only output relevant values for
each feature specified.
- selected_prediction_stats : list[Prediction_Stats], optional.
List of stats to output. When unspecified, returns all except the confusion matrix. Allowed values:

Expand Down Expand Up @@ -3613,6 +3617,10 @@ def react_aggregate(
"selected_prediction_stats" parameter in the `details` parameter.
Uses full calculations, which uses leave-one-out for features for
computations.
- relevant_values : bool or list of strings, optional
When true outputs a map of each context feature name to a list of relevant values for that
feature given the context. If a list of feature names, will only output relevant values for
each feature specified.
- selected_prediction_stats : list, optional
List of stats to output. When unspecified, returns all except the confusion matrix. Allowed values:

Expand Down
4 changes: 4 additions & 0 deletions howso/scikit/scikit.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ def describe_prediction(self, X: np.ndarray, details: t.Optional[Mapping] = None
Uses only the context features of the reacted case to determine that area.
Uses full calculations, which uses leave-one-out context features for
computations.
- relevant_values : bool or list of strings, optional
When true outputs a map of each context feature name to a list of relevant values for that
feature given the context. If a list of feature names, will only output relevant values for
each feature specified.
- selected_prediction_stats : list, optional
List of stats to output. When unspecified, returns all except the confusion matrix. Allowed values:

Expand Down
22 changes: 11 additions & 11 deletions howso/utilities/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def to_pandas_datetime_format(f: str):

def fix_feature_value_keys(
input_dict: dict[str, t.Any],
feature_attributes: Mapping[t.Hashable, Mapping],
feature_attributes: Mapping[str, Mapping],
feature_name: str
) -> dict[str | float | int, t.Any]:
"""
Expand All @@ -926,7 +926,7 @@ def fix_feature_value_keys(
----------
input_dict : dict[str, Any]
The mapping with feature values as keys that may need fixing.
feature_attributes : Mapping[Hashable, Mapping]
feature_attributes : Mapping[str, Mapping]
The feature attributes of the data.
feature_name : str
The name of the feature whose feature values make the keys of the dict.
Expand All @@ -951,9 +951,9 @@ def fix_feature_value_keys(
return output_dict

def update_caps_maps(
caps_maps: list[dict[dict[str, float]]],
feature_attributes: Mapping[t.Hashable, Mapping]
) -> list[dict[dict[str | int | float, float]]]:
caps_maps: list[dict[str, dict[str, float]]],
feature_attributes: Mapping[str, Mapping]
) -> list[dict[str, dict[str | int | float, float]]]:
"""
Cleans up misformatted keys from non-string nominal feature's CAP maps.

Expand All @@ -962,14 +962,14 @@ def update_caps_maps(

Parameters
----------
caps_maps : list[dict[dict[str, float]]]
caps_maps : list[dict[str, dict[str, float]]]
The list of CAP maps.
feature_attributes : Mapping[str, Mapping]
The feature attributes of the data.

Returns
-------
list[dict[dict[str | int | float, float]]]
list[dict[str, dict[str | int | float, float]]]
The updated list of CAP maps with cleaned up feature values as keys.
"""
updated_caps_maps = []
Expand All @@ -987,8 +987,8 @@ def update_caps_maps(
return updated_caps_maps

def update_confusion_matrix(
confusion_matrix: dict[str, dict | float],
feature_attributes: Mapping[t.Hashable, Mapping]
confusion_matrix: dict[str, dict[str, float | dict[str, t.Any]]],
feature_attributes: Mapping[str, Mapping]
) -> dict[str, t.Any]:
"""
Cleans up misformatted keys from non-string nominal feature's confusion matrices.
Expand All @@ -998,9 +998,9 @@ def update_confusion_matrix(

Parameters
----------
confusion_matrix : dict[str, dict | float]
confusion_matrix : dict[str, dict[str, float | dict[str, t.Any]]]
The mapping that defines the confusion matrix.
feature_attributes : Mapping[Hashable, Mapping]
feature_attributes : Mapping[str, Mapping]
The feature attributes of the data.

Returns
Expand Down
Loading