Question: import seaborn as sns import matplotlib.pyplot as plt # Data for the heatmap ( using your probability scale 1 - 4 ) data = {

import seaborn as sns
import matplotlib.pyplot as plt
# Data for the heatmap (using your probability scale 1-4)
data ={
'Explore': [1,2,3],
'Establish': [2,3,4],
'Exploit': [3,4,4]
}
index =['General Prompts', 'Adversarial Prompts', 'Targeted Prompts']
df = pd.DataFrame(data, index=index)
# Create a custom colormap to better reflect the probability levels
colors =[(255/255,255/255,204/255), # Light Yellow (Low)
(255/255,237/255,160/255), # Light Orange (Medium)
(254/255,178/255,76/255), # Orange (High)
(227/255,26/255,28/255)] # Red (Very High)
cmap = sns.color_palette(colors)
# Create the heatmap with seaborn
plt.figure(figsize=(10,6)) # Adjust figure size for better readability
sns.heatmap(df, annot=True, cmap=cmap, fmt=".0f", cbar_kws={'label': 'Probability'})
# Add labels and title
plt.title('Probability of Identifying Harmful LLM Outputs', fontsize=14) # Increase title font size
plt.ylabel('Prompt Type', fontsize=12) # Increase y-axis label font size
plt.xlabel('Phase', fontsize=12) # Increase x-axis label font size
plt.xticks(fontsize=10) # Increase x-axis tick labels font size
plt.yticks(fontsize=10) # Increase y-axis tick labels font size
# Show the plot
plt.show() do the heatmap visualize this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!