Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

mport seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Create the DataFrame from the table data data = { 'Risk Description':

mport seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Create the DataFrame from the table data
data ={
'Risk Description': [
'Unwanted Outputs, Bias', 'Lack of Quality, Factuality', 'Lack of Timeliness',
'Lack of Explainability', 'Insecure Generated Code', 'Incorrect Response to Inputs',
'Automation Bias', 'Misinterpreting Text as Instruction', 'Lack of Confidentiality',
'Self-reinforcing Impacts', 'Developer Dependence', 'Misinformation',
'Social Engineering', 'Re-identification', 'Surveillance Concerns',
'Malware Creation', 'Malware Placement', 'RCE Attacks', 'Training Data Reconstruction',
'Model Subversion', 'Member Reasoning Attacks', 'Homograph Attacks', 'Prompt Injection Attacks',
'Data Poisoning', 'Model Poisoning', 'Learning Transfer Attacks', 'Environmental Impact',
'Economic Disruption', 'Overreliance/Dependency', 'Dual Use Concerns', 'Unforeseen Consequences'
],
'Planning': [1,0,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,1,0],
'Data': [1,1,1,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0],
'Development': [1,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,0,1,0,0,0,0,0],
'Operation': [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,0,1,0],
'Risk Level': ['High', 'Medium', 'Medium', 'High', 'High', 'Medium', 'Medium', 'Medium', 'High', 'Medium', 'Medium', 'High', 'Medium', 'High', 'High', 'High', 'Medium', 'High', 'Medium', 'Medium', 'Medium', 'Low', 'Medium', 'Medium', 'Medium', 'Low', 'Low', 'Low', 'Medium', 'High', 'High']
}
df = pd.DataFrame(data)
df = df.set_index('Risk Description')
df_heatmap = df.transpose()
# Create heatmap
plt.figure(figsize=(15,10))
sns.set(font_scale=0.9)
# Create a custom color palette (white to red gradient)
cmap = sns.color_palette("Reds", as_cmap=True)
ax = sns.heatmap(df_heatmap, cmap=cmap, annot=df['Risk Level'], fmt='', linewidths=0.5, cbar_kws={'label': 'Risk Level'})
# Add tooltips
for i in range(len(df_heatmap)):
for j in range(len(df_heatmap.columns)):
text = ax.text(j +0.5, i +0.5, df_heatmap.values[i, j], ha="center", va="center", color="black")
text.set_gid(f"tooltip_{i}_{j}")
tooltip_text = df.index[j]+": "+ df.columns[i]
ax.add_artist(AnchoredText(tooltip_text, loc="center", frameon=True, prop=dict(fontsize=0)))
# Set up the hover functionality
from matplotlib.offsetbox import AnchoredText
def on_hover(event):
for text in ax.texts:
cont, ind = text.contains(event)
if cont:
text.set_weight('bold')
text.set_bbox(dict(facecolor='white', alpha=0.8, edgecolor='black'))
annotation = text.get_gid().split('_')[1:]
tooltip_text = df.index[int(annotation[0])]+": "+ df.columns[int(annotation[1])]
ax.add_artist(AnchoredText(tooltip_text, loc="center", frameon=True, prop=dict(fontsize=8)))
else:
text.set_weight('normal')
text.set_bbox(dict(facecolor='white', alpha=0, edgecolor='black'))
plt.gcf().canvas.mpl_connect("motion_notify_event", on_hover)
# Add a title
plt.title('AI System Lifecycle & Impact Risk Assessment Heatmap', fontsize=14)
# Show the plot
plt.show()
\Chi \rho \eta \sigma \iota \mu \omicron \pi \omicron \iota \sigma \tau \epsi \tau \omicron
u \kappa \delta \iota \kappa \alpha \mu \epsi \pi \rho \omicron \sigma \omicron \chi .
play_circleeditcontent_copy
Key Changes:
Gradient Color Map: Uses "Reds" colormap to represent risk intensity from low (white) to high (red).
Risk Level Annotations: Directly annotates cells with "High," "Medium," or "Low" instead of numerical values.
Gridlines: Adds gridlines for easier visual separation of cells.
Enhanced Tooltips: Provides full risk descriptions in tooltips when hovering over cells.
Sorting: Groups risks by lifecycle phase and impact for better visual organization. OPTIMAZE THE HEATMAP WITH THE CODE ITS IMPORTANT TO DO OPTIMAZATION SCHEME

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Conduct an effective performance feedback session. page 376

Answered: 1 week ago