Lab Report 4
Lab Report 4
Theory:
Supervised Learning: It is a machine learning technique that uses
labeled data to train models to predict outcomes.
Classification: Classification is a subset of supervised learning in the
process of predicting which category a new data points belongs to.
Source Code 1: from io import IncrementalNewlineDecoder
import numpy as np
import os
import sklearn
import sys
try:
%tensorflow_version 1.x
!apt update && apt install -y libpq-dev libsdl2-dev swig xorg-dev xvfb
IS_COLAB = True
except Exception:
IS_COLAB = False
def reset_graph(seed=42):
tf.reset_default_graph()
tf.set_random_seed(seed)
np.random.seed(seed)
mpl.rc('axes', labelsize=14)
mpl.rc('xtick', labelsize=12)
mpl.rc('ytick', labelsize=12)
mpl.rc('animation', html='jshtml')
PROJECT_ROOT_DIR = "."
CHAPTER_ID = "rl"
os.makedirs(IMAGES_PATH, exist_ok=True)
if tight_layout:
plt.tight_layout()
def create_my_plot():
y = np.sin(x)
plt.plot(x, y)
plt.title("Sine Wave")
plt.xlabel("x")
plt.ylabel("sin(x)")
plt.show()
create_my_plot()
save_fig("my_plot")
patch.set_data(frames[num])
return patch,
fig = plt.figure()
patch = plt.imshow(frames[0])
plt.axis('off')
anim = mpl.animation.FuncAnimation(
return anim
frames = []
n_max_steps = 1000
n_change_steps = 10
img = env.render(mode="rgb_array")
frames.append(img)
if step % n_change_steps == 0:
if done:
break
plot_animation(frames)
patch.set_data(frames[num])
return patch,
fig = plt.figure()
patch = plt.imshow(frames[0])
plt.axis('off')
anim = mpl.animation.FuncAnimation(
plt.close()
return anim
frames = []
env.seed(42)
obs = env.reset()
img = env.render(mode="rgb_array")
frames.append(img)
if step % n_change_steps == 0:
if done:
break
plot_animation(frames)
mpl.rc('axes', labelsize=14)
mpl.rc('xtick', labelsize=12)
mpl.rc('ytick', labelsize=12)
patch.set_data(frames[num])
return patch,
fig = plt.figure()
patch = plt.imshow(frames[0])
plt.axis('off')
anim = animation.FuncAnimation(
plt.close()
return anim
for i in range(100):
# Iterate through each point in the sine wave and update the frame
for j in range(len(x)):
frames.append(frame)
anim = plot_animation(frames)
anim
import os
def plot_digit(data):
plt.axis("off")
# EXTRA
size = 28
n_rows = (len(instances)
● 1) // images_per_row + 1
row_images = []
n_empty = n_rows * images_per_row len(instances)
images.append(np.zeros((size, size * n_empty)))
for row in range(n_rows):
rimages = images[row * images_per_row: (row + 1) * images_per_row]
row_images.append(np.concatenate(rimages, axis=1))
image = np.concatenate(row_images, axis=0)
plt.imshow(image, cmap=mpl.cm.binary, **options)
plt.axis("off")
plt.figure(figsize=(9, 9))
PROJECT_ROOT_DIR = "."
CHAPTER_ID = "classification"
os.makedirs(IMAGES_PATH, exist_ok=True)
plt.show() number 2