Supervised LEARNING File
Supervised LEARNING File
PRACTICAL FILE
Code :
Practical - 2
AIM : Logistic regression: Implement logistic regression on a binary classification dataset and
evaluate the model's performance.
Code :
Practical - 3
AIM : k-Nearest Neighbors (k-NN): Implement k-NN algorithm on a dataset and evaluate the
model's performance.
Code :
Practical - 4
AIM : Decision Trees: Implement decision trees on a dataset and evaluate the model's
performance.
Code :
Practical - 5
Aim : Random Forest: Implement random forest algorithm on a dataset and evaluate the
model's performance.
Code :
Practical - 6
AIM: Support Vector Machines (SVM): Implement SVM on a dataset and evaluate the
model's performance.
Code :
Practical - 7
Aim : Naive Bayes: Implement Naive Bayes algorithm on a dataset and evaluate the model's
performance .
Code :
Practical - 8
Aim : Gradient Boosting: Implement gradient boosting algorithm on a dataset and evaluate
the model's performance.
Code :
Practical - 9
Aim : Convolutional Neural Networks (CNN): Implement CNN on an image classification
dataset and evaluate the model's performance.
Code :
Practical - 10
Aim : Recurrent Neural Networks (RNN): Implement RNN on a text classification dataset and
evaluate the model's performance.
Code :
Practical - 11
Aim : Long Short-Term Memory Networks (LSTM): Implement LSTM on a time-series dataset
and evaluate the model's performance.
Code :
Practical - 12
Aim : Autoencoders: Implement autoencoders on an image dataset and evaluate the
model's performance.
Code :
Practical - 13
Aim : Generative Adversarial Networks (GANs): Implement GANs on an image dataset and
evaluate the model's performance.
Code :
Practical - 14
Aim: Transfer Learning: Implement transfer learning on an image dataset and evaluate the
model's performance.
Dataset Used:
Code:
import tensorflow as tf
from tensorflow.keras.applications import ResNet50
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import EarlyStopping
import matplotlib.pyplot as plt
import os
validation_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(224, 224),
batch_size=32,
class_mode='binary'
)
validation_generator = validation_datagen.flow_from_directory(
validation_dir,
target_size=(224, 224),
batch_size=32,
class_mode='binary'
)
for _ in range(10):
env.render()
action = env.action_space.sample()
step_result = env.step(action)
if len(step_result) == 4:
next_state, reward, done, info = step_result
terminated = False
else:
next_state, reward, done, truncated, info = step_result
terminated = done or truncated
if terminated:
state = env.reset()
env.close()
Output