elliptic_toolkit.plots module

elliptic_toolkit.plots.plot_marginals(cv_results, max_ticks=10)[source]

For each hyperparameter in cv_results, plot the marginal mean and standard deviation (error bar) of test scores.

The marginal mean/std for each hyperparameter value is computed by averaging across all other hyperparameters the mean/std across the cv folds (i.e., by computing the average of the mean_test_score and std_test_score columns).

Parameters:
  • cv_results (dict) – The cv_results_ attribute from a scikit-learn search object.

  • max_ticks (int, default=10) – Maximum number of x-ticks to show on the x-axis for readability.

Returns:

figs – Dictionary mapping parameter names to matplotlib.figure.Figure objects.

Return type:

dict

elliptic_toolkit.plots.plot_evals(est, X_test, y_test, y_train, *, time_steps_test=None)[source]

Generate two evaluation plots for a classifier: 1. Precision-Recall curve on the test set. 2. Rolling/cumulative AP and illicit rate by time step.

Parameters:
  • est (classifier) – Trained classifier with predict_proba method.

  • X_test (pd.DataFrame, array-like) – Test features. Must contain a ‘time’ column unless time_steps_test is provided.

  • y_test (numpy.ndarray) – Test labels (binary).

  • y_train (numpy.ndarray) – Training labels (binary), used for reference illicit rate.

  • time_steps_test (numpy.ndarray, optional) – Time step values for test set. If None, will use X_test[‘time’].

Returns:

  • pr_fig (matplotlib.figure.Figure) – Figure for the precision-recall curve.

  • temporal_fig (matplotlib.figure.Figure) – Figure for the rolling/cumulative AP and illicit rate by time step.

Notes

This function assumes arrays to be numpy ndarrays. X_test is allowed to be a torch.Tensor but est.predict_proba must return numpy arrays.