# Import necessary libraries/modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import squarify
# Plot hobbies treemap
categories = ['Piano', 'Hiking in the Mountains', 'Snowboarding', 'Tennis','CrossFit',
'AI Generated Art','Learning New Skills','Going on Adventures!']
sizes = [20, 20, 10, 10, 20, 5, 15, 15]
colors = ['#dfe318', '#2db27d', '#38598c', '#0b101b']
# Create a figure and a set of subplots
fig, ax = plt.subplots(figsize=(12, 8))
# Set the background color of the axes and the figure
ax.set_facecolor('#1e2327') # for the axes
fig.patch.set_facecolor('#1e2327') # for the figure background
squarify.plot(sizes=sizes, label=categories, color=colors, alpha=0.7, pad=0.01, ax=ax)
plt.title('Some of my Hobbies',fontweight='bold',fontsize=20, color='#F0EAD6')
plt.axis('off') # Disable the axis
# Adjust label formatting
for i, label in enumerate(plt.gca().texts):
label.set_fontsize(13.5)
label.set_weight('bold')
if categories[i] == 'Going on Adventures!':
label.set_rotation(90)
label.set_color('#2db27d')
if categories[i] == 'Tennis':
label.set_color('#2db27d')
plt.show()
# Create list of predictions and transform into 2x2 numpy array
predictions_list = [0,0,0,1]
predictions_matrix = np.array(predictions_list).reshape(2,2)
# Change background color
fig, ax = plt.subplots(figsize=(5,4))
fig.patch.set_facecolor('#1e2327')
ax.set_facecolor('#1e2327')
# Plot confusion matrix using seaborn heatmap
plt.figure(figsize=(5,4))
ax = sns.heatmap(predictions_matrix, vmin=0, vmax=1, annot=True,
cmap = sns.color_palette("mako", as_cmap=True), fmt='g')
plt.title('Confusion Matrix', fontsize=16, fontweight='bold', color='#F0EAD6')
plt.xlabel('Predicted Label', color='#F0EAD6')
plt.ylabel('True Label', color='#F0EAD6')
ax.tick_params(axis='both', colors='#F0EAD6')
# Access the color bar
cbar = ax.collections[0].colorbar
# Change the color of the color bar's tick labels
cbar.ax.yaxis.set_tick_params(color='#F0EAD6') # Change tick label colors
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='#F0EAD6') # Change tick text colors