Target
Store information about the target model and data.
- class sacroml.attacks.target.Target(model: Any = None, model_path: str = '', model_module_path: str = '', model_name: str = '', model_params: dict | None = None, train_module_path: str = '', train_params: dict | None = None, dataset_name: str = '', dataset_module_path: str = '', features: dict | None = None, X_train: ndarray | None = None, y_train: ndarray | None = None, X_test: ndarray | None = None, y_test: ndarray | None = None, X_orig: ndarray | None = None, y_orig: ndarray | None = None, X_train_orig: ndarray | None = None, y_train_orig: ndarray | None = None, X_test_orig: ndarray | None = None, y_test_orig: ndarray | None = None, proba_train: ndarray | None = None, proba_test: ndarray | None = None)[source]
Store information about the target model and data.
Methods
add_feature
(name, indices, encoding)Add a feature description to the data dictionary.
add_processed_data
(X_train, y_train, X_test, ...)Add a processed and split dataset.
add_raw_data
(X_orig, y_orig, X_train_orig, ...)Add original unprocessed dataset.
add_safemodel_results
(data)Add the results of safemodel disclosure checking.
has_data
()Return whether the target has all processed data.
Return whether the target has a loaded model.
Return whether the target has all probability data.
Return whether the target has all raw data.
load
([path])Load the target class from persistent storage.
load_array
(arr_path, name)Load a data array variable from file.
save
([path, ext])Save the target class to persistent storage.
- __init__(model: Any = None, model_path: str = '', model_module_path: str = '', model_name: str = '', model_params: dict | None = None, train_module_path: str = '', train_params: dict | None = None, dataset_name: str = '', dataset_module_path: str = '', features: dict | None = None, X_train: ndarray | None = None, y_train: ndarray | None = None, X_test: ndarray | None = None, y_test: ndarray | None = None, X_orig: ndarray | None = None, y_orig: ndarray | None = None, X_train_orig: ndarray | None = None, y_train_orig: ndarray | None = None, X_test_orig: ndarray | None = None, y_test_orig: ndarray | None = None, proba_train: ndarray | None = None, proba_test: ndarray | None = None) None [source]
Store information about a target model and associated data.
- Parameters:
- modelAny
Trained target model.
- model_pathstr
Path to a saved model.
- model_module_pathstr
Path to module containing model class.
- model_namestr
Class name of model.
- model_paramsdict | None
Hyperparameters for instantiating the model.
- train_module_pathstr
Path to module containing training function.
- train_paramsdict | None
Hyperparameters for training the model.
- dataset_namestr
The name of the dataset.
- dataset_module_pathstr
Path to module containing dataset loading function.
- featuresdict
Dictionary describing the dataset features.
- X_trainnp.ndarray | None
The (processed) training inputs.
- y_trainnp.ndarray | None
The (processed) training outputs.
- X_testnp.ndarray | None
The (processed) testing inputs.
- y_testnp.ndarray | None
The (processed) testing outputs.
- X_orignp.ndarray | None
The original (unprocessed) dataset inputs.
- y_orignp.ndarray | None
The original (unprocessed) dataset outputs.
- X_train_orignp.ndarray | None
The original (unprocessed) training inputs.
- y_train_orignp.ndarray | None
The original (unprocessed) training outputs.
- X_test_orignp.ndarray | None
The original (unprocessed) testing inputs.
- y_test_orignp.ndarray | None
The original (unprocessed) testing outputs.
- proba_trainnp.ndarray | None
The model predicted training probabilities.
- proba_testnp.ndarray | None
The model predicted testing probabilities.
- add_feature(name: str, indices: list[int], encoding: str) None [source]
Add a feature description to the data dictionary.
- add_processed_data(X_train: ndarray, y_train: ndarray, X_test: ndarray, y_test: ndarray) None [source]
Add a processed and split dataset.
- add_raw_data(X_orig: ndarray, y_orig: ndarray, X_train_orig: ndarray, y_train_orig: ndarray, X_test_orig: ndarray, y_test_orig: ndarray) None [source]
Add original unprocessed dataset.
- add_safemodel_results(data: list) None [source]
Add the results of safemodel disclosure checking.
- Parameters:
- datalist
The results of safemodel disclosure checking.
- load(path: str = 'target') None [source]
Load the target class from persistent storage.
- Parameters:
- pathstr
Name of the output folder containing a target yaml file.