Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

23069: Adds "goal_features_map" parameter to react_aggregate, MINOR #376

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 25 additions & 0 deletions howso/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3540,6 +3540,7 @@ def react_aggregate( # noqa: C901
details: t.Optional[dict] = None,
features_to_derive: t.Optional(Collection[str]) = None,
feature_influences_action_feature: t.Optional[str] = None,
goal_features_map: t.Optional[Mapping] = None,
hyperparameter_param_path: t.Optional[Collection[str]] = None,
num_robust_influence_samples: t.Optional[int] = None,
num_robust_residual_samples: t.Optional[int] = None,
Expand Down Expand Up @@ -3727,6 +3728,29 @@ def react_aggregate( # noqa: C901
the action feature. If not provided, will default to the ``action_feature`` if provided.
If ``action_feature`` is not provided and feature influences ``details`` are
selected, this feature must be provided.
goal_features_map : dict of dict, optional
A mapping of feature name to the goals for the feature, which will
cause each internal prediction to achieve the goals as appropriate
for the given context. This functions similarly to the same parameter
in ``AbstractHowsoClient.react``, but is used in every prediction made
while computing the desired metrics.
Valid keys in the map are:

- "goal": "min" or "max", will make a prediction while minimizing or
maximizing the value for the feature.
- "value" : somevalue, will make a prediction while approaching the
specified value.

.. NOTE::
Nominal features only support "value", "goal" is ignored.
For non-nominals, if both are provided, only "goal" is considered.

Example::

{
"feature_a" : { "goal": "max" },
"feature_b" : { "value": 99 }
}
hyperparameter_param_path : iterable of str, optional.
Full path for hyperparameters to use for computation. If specified
for any residual computations, takes precedence over action_feature
Expand Down Expand Up @@ -3838,6 +3862,7 @@ def react_aggregate( # noqa: C901
"details": details,
"features_to_derive": features_to_derive,
"feature_influences_action_feature": feature_influences_action_feature,
"goal_features_map": goal_features_map,
"hyperparameter_param_path": hyperparameter_param_path,
"num_robust_influence_samples": num_robust_influence_samples,
"num_robust_residual_samples": num_robust_residual_samples,
Expand Down
25 changes: 25 additions & 0 deletions howso/engine/trainee.py
Original file line number Diff line number Diff line change
Expand Up @@ -3145,6 +3145,7 @@ def react_aggregate(
details: t.Optional[dict] = None,
features_to_derive: t.Optional[Collection[[str]]] = None,
feature_influences_action_feature: t.Optional[str] = None,
goal_features_map: t.Optional[Mapping] = None,
hyperparameter_param_path: t.Optional[Collection[str]] = None,
num_robust_influence_samples: t.Optional[int] = None,
num_robust_residual_samples: t.Optional[int] = None,
Expand Down Expand Up @@ -3328,6 +3329,29 @@ def react_aggregate(
the action feature. If not provided, will default to the ``action_feature`` if provided.
If ``action_feature`` is not provided and feature influences ``details`` are
selected, this feature must be provided.
goal_features_map : dict of dict, optional
A mapping of feature name to the goals for the feature, which will
cause each internal prediction to achieve the goals as appropriate
for the given context. This functions similarly to the same parameter
in ``Trainee.react``, but is used in every prediction made while computing
the desired metrics.
Valid keys in the map are:

- "goal": "min" or "max", will make a prediction while minimizing or
maximizing the value for the feature.
- "value" : somevalue, will make a prediction while approaching the
specified value.

.. NOTE::
Nominal features only support "value", "goal" is ignored.
For non-nominals, if both are provided, only "goal" is considered.

Example::

{
"feature_a" : { "goal": "max" },
"feature_b" : { "value": 99 }
}
hyperparameter_param_path : Collection of str, optional.
Full path for hyperparameters to use for computation. If specified
for any residual computations, takes precedence over action_feature
Expand Down Expand Up @@ -3398,6 +3422,7 @@ def react_aggregate(
details=details,
features_to_derive=features_to_derive,
feature_influences_action_feature=feature_influences_action_feature,
goal_features_map=goal_features_map,
hyperparameter_param_path=hyperparameter_param_path,
num_robust_influence_samples=num_robust_influence_samples,
num_robust_residual_samples=num_robust_residual_samples,
Expand Down
Loading