From 6046fdae6f55619eb785d9e17827c40c1d4633c3 Mon Sep 17 00:00:00 2001 From: Omar Santos Date: Thu, 28 Dec 2023 19:10:03 -0500 Subject: [PATCH] Create risk_matrix_example.py --- .../risk_matrix_example.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ai_research/AI Security Best Practices/risk_matrix_example.py diff --git a/ai_research/AI Security Best Practices/risk_matrix_example.py b/ai_research/AI Security Best Practices/risk_matrix_example.py new file mode 100644 index 0000000..85c2818 --- /dev/null +++ b/ai_research/AI Security Best Practices/risk_matrix_example.py @@ -0,0 +1,36 @@ +# A Simple script to illustrate an example of a basic AI Risk Matrix + +import matplotlib.pyplot as plt +import numpy as np + +# Define the risks and their impact and likelihood +risks = { + "Data Privacy Risk": {"Impact": "Medium", "Likelihood": "Medium"}, + "Diagnostic Accuracy Risk": {"Impact": "Very High", "Likelihood": "Low"}, + "Bias Risk": {"Impact": "High", "Likelihood": "Medium"} +} + +# Mapping of impact and likelihood to numerical values +impact_mapping = {"Low": 1, "Medium": 2, "High": 3, "Very High": 4} +likelihood_mapping = {"Low": 1, "Medium": 2, "High": 3, "Very High": 4} + +# Prepare data for plotting +x = [likelihood_mapping[risks[risk]['Likelihood']] for risk in risks] +y = [impact_mapping[risks[risk]['Impact']] for risk in risks] +labels = list(risks.keys()) + +# Create the plot +plt.figure(figsize=(8, 6)) +plt.scatter(x, y, color='blue') +plt.title('AI System Risk Matrix') +plt.xlabel('Likelihood') +plt.ylabel('Impact') +plt.xticks([1, 2, 3, 4], ['Low', 'Medium', 'High', 'Very High']) +plt.yticks([1, 2, 3, 4], ['Low', 'Medium', 'High', 'Very High']) +plt.grid(True) + +# Annotate the points +for i, label in enumerate(labels): + plt.annotate(label, (x[i], y[i])) + +plt.show()