nebula.addons.trustworthiness.utils#
Attributes#
Functions#
|
Counts the number of samples by class. |
|
Get the entropy of each client in the scenario. |
|
Read a CSV file. |
|
Check if the field in the factsheet file is filled or not. |
|
Gets the input value from input document and apply the metric operation on the value. |
|
Gets the input value from input document by path. |
|
Writes the result to JSON. |
|
Module Contents#
- nebula.addons.trustworthiness.utils.hashids#
- nebula.addons.trustworthiness.utils.logger#
- nebula.addons.trustworthiness.utils.dirname#
- nebula.addons.trustworthiness.utils.count_class_samples(scenario_name, dataloaders_files)#
Counts the number of samples by class.
- Parameters:
scenario_name (string) – Name of the scenario.
dataloaders_files (list) – Files that contain the dataloaders.
- nebula.addons.trustworthiness.utils.get_entropy(client_id, scenario_name, dataloader)#
Get the entropy of each client in the scenario.
- Parameters:
client_id (int) – The client id.
scenario_name (string) – Name of the scenario.
dataloaders_files (list) – Files that contain the dataloaders.
- nebula.addons.trustworthiness.utils.read_csv(filename)#
Read a CSV file.
- Parameters:
filename (string) – Name of the file.
- Returns:
The CSV readed.
- Return type:
object
- nebula.addons.trustworthiness.utils.check_field_filled(factsheet_dict, factsheet_path, value, empty='')#
Check if the field in the factsheet file is filled or not.
- Parameters:
factsheet_dict (dict) – The factshett dict.
factsheet_path (list) – The factsheet field to check.
value (float) – The value to add in the field.
empty (string) – If the value could not be appended, the empty string is returned.
- Returns:
The value added in the factsheet or empty if the value could not be appened
- Return type:
float
- nebula.addons.trustworthiness.utils.get_input_value(input_docs, inputs, operation)#
Gets the input value from input document and apply the metric operation on the value.
- Parameters:
inputs_docs (map) – The input document map.
inputs (list) – All the inputs.
operation (string) – The metric operation.
- Returns:
The metric value
- Return type:
float
- nebula.addons.trustworthiness.utils.get_value_from_path(input_doc, path)#
Gets the input value from input document by path.
- Parameters:
inputs_doc (map) – The input document map.
path (string) – The field name of the input value of interest.
- Returns:
The input value from the input document
- Return type:
float
- nebula.addons.trustworthiness.utils.write_results_json(out_file, dict)#
Writes the result to JSON.
- Parameters:
out_file (string) – The output file.
dict (dict) – The object to be witten into JSON.
- Returns:
The input value from the input document
- Return type:
float
- nebula.addons.trustworthiness.utils.save_results_csv(scenario_name, id, bytes_sent, bytes_recv, accuracy, loss, finish)#
- Parameters:
scenario_name (str)
id (int)
bytes_sent (int)
bytes_recv (int)
accuracy (float)
loss (float)
finish (bool)