Everything needed to run the experiments in the optimal setting.

class trickster.optim.BenchCost(problem_ctx)

Alternative cost function used for analyses and stats.

__call__(x, another)

Call self as a function.

class trickster.optim.CategoricalLpProblemContext(clf: Any, target_class: float, target_confidence: float = 0.5, epsilon: float = 1.0, lp_space=1, expansion_specs: List[trickster.domain.categorical.FeatureExpansionSpec] = NOTHING)

Context for an optimal search instance in Lp space with categorical transformations.

  • clf – Target classifier.
  • target_class – Target class.
  • target_confidence – Target class confidence.
  • lp_space (LpSpace) – $$L_p$$ space.
  • epsilon – Runtime-optimality trade-off parameter. 1 means optimal. More is sub-optimal but faster.
  • expansion_specs – List of categorical expansion specs (trickster.domain.categorical.FeatureExpansionSpec)
>>> problem_ctx = CategoricalLpProblemContext(
...     clf="stub", target_class=1, target_confidence=0.5,
...     lp_space="inf", epsilon=10)

Generate an instance of graph search problem.

class trickster.optim.GoalFunc(problem_ctx)

Tells whether an example flips the decision of the classifier.


Call self as a function.

class trickster.optim.SpecExpandFunc(problem_ctx, weight_vec=None)

Expand candidates using given specs with each transformation having $L_p$ cost.


Call self as a function.

trickster.optim.run_experiment(problem_ctx, data, confidence_margin=1.0, reduce_classifier=True, transformable_feature_idxs=None, make_graph_search_problem=None, get_cost_weights_fn=None, graph_search_kwargs=None, logger=None)

Experiment runner for optimal setting in categorical feature space.

An experiment finds adversarial examples for a given model and a given dataset.

  • problem_ctx (trickster.base.ProblemContext) – Search problem context.
  • data – Data tuple (X, y)
  • confidence_margin (float) – Pick initial examples that are at most this far away from the target confidence. Use this to get to relax the problem.
  • reduce_classifier (bool) – Whether to use trickster.linear.create_reduced_linear_classifier() if possible.
  • transformable_feature_idxs (list) –
  • graph_search_kwargs (dict) – Parameters passed to the search function call.
  • logger – Logger instance.