Dump the model as JSON string For an example, see the file: "serialized_model.json". Returns ------- str A JSON string representing the model information. Examples -------- >>> model = pyfair.FairModel(name="Insider Threat")
(self)
| 530 | return self._model_table |
| 531 | |
| 532 | def to_json(self): |
| 533 | """Dump the model as JSON string |
| 534 | |
| 535 | For an example, see the file: "serialized_model.json". |
| 536 | |
| 537 | Returns |
| 538 | ------- |
| 539 | str |
| 540 | A JSON string representing the model information. |
| 541 | |
| 542 | Examples |
| 543 | -------- |
| 544 | >>> model = pyfair.FairModel(name="Insider Threat") |
| 545 | >>> model.bulk_import_data({ |
| 546 | ... 'Loss Event Frequency': {'mean': 90, 'stdev': 100}, |
| 547 | ... 'Loss Magnitude': {'constant': 4000}, |
| 548 | ... }) |
| 549 | ... model.calculate_all)() |
| 550 | ... json_data = model.to_json() |
| 551 | |
| 552 | """ |
| 553 | # Copy only. |
| 554 | data = {**self._data_input.get_supplied_values()} |
| 555 | # Add non-parameter metadata information |
| 556 | data['name'] = str(self._name) |
| 557 | data['n_simulations'] = self._n_simulations |
| 558 | data['random_seed'] = self._random_seed |
| 559 | data['model_uuid'] = self._model_uuid |
| 560 | data['type'] = str(self.__class__.__name__) |
| 561 | data['creation_date'] = self._creation_date |
| 562 | # Dump as string |
| 563 | json_data = json.dumps( |
| 564 | data, |
| 565 | indent=4, |
| 566 | ) |
| 567 | return json_data |
| 568 | |
| 569 | def export_params(self): |
| 570 | """Export params as a dictionary. |