JSONStorageHandler#

class JSONStorageHandler(path)[source]#

Storage handler for JSON files, with ending .json.

Loads and saves results in JSON format, as follows.

Each result is stored as a JSON record with the following keys:

  • model_id: The ID of the model.

  • validation_id: The ID of the validation run.

  • folds: A dictionary of fold results,

    where each key is a fold ID and the value is a dictionary of scores and dataframes.

The folds dictionary has the following structure, where ground_truth, predictions, and train_data are returned only if they were requested during benchmarking.

Keys are strings representing fold IDs.

```json {

“0”: {
“scores”: {

“accuracy”: 0.9, “f1_score”: 0.8

}, “ground_truth”: {

“column1”: [1, 0, 1], “column2”: [0.5, 0.3, 0.8]

}, “predictions”: {

“column1”: [1, 0, 0], “column2”: [0.6, 0.4, 0.7]

}, “train_data”: {

“column1”: [0, 1, 1], “column2”: [0.2, 0.9, 0.4]

}

}, “1”: {

}

}

Parameters:
pathstr, or Path coercible

The path to the file to save to or load

Methods

is_applicable(path)

Check if the storage handler is applicable for the given path.

load()

Load the results from a file.

save(results)

Save the results to a JSON file.

save(results: list[ResultObject])[source]#

Save the results to a JSON file.

Parameters:
resultsResultObject

The results to save.

static is_applicable(path)[source]#

Check if the storage handler is applicable for the given path.

Parameters:
pathstr

The path to the file to save to or load

Returns:
bool

True if the storage handler is applicable for the given path.

load() list[ResultObject][source]#

Load the results from a file.

Returns:
list[ResultObject]

The loaded results. Returns empty list if file doesn’t exist.