0% found this document useful (0 votes)
15 views

ML Lab

Machine learning lab work

Uploaded by

sanjanabhosle27
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

ML Lab

Machine learning lab work

Uploaded by

sanjanabhosle27
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Institute’s Vision

To be an organisation with potential for excellence in engineering and management


for the advancement of society and human kind.

Institute’s Mission

• To excel in academics, practical engineering, management and to commence


research endeavours.

• To prepare students for future opportunities.

• To nurture students with social and ethical responsibilities.


Department’s Vision

To create proficient graduates with technical knowledge and social values

Department’s Mission

• To improvise teaching and learning process through modern tool usage

• To encourage participation from department and industry through internship and


interaction

• To cater ethical and value based education addressing social needs


COURSE DETAILS

Lab Code Lab Name Credits

CSL701 Machine Learning Lab 1

Lab Objectives and Outcome

Lab Objectives:

1 To introduce the basic concepts and techniques of Machine Learning.


2 To acquire in depth understanding of various supervised and unsupervised algorithms

3 To be able to apply various ensemble techniques for combining ML models.

4 To demonstrate dimensionality reduction techniques.

Lab Outcomes: On successful completion of lab, learner will be able to


1 To implement an appropriate machine learning model for the given application.
2 To implement ensemble techniques to combine predictions from different models.

3 To implement the dimensionality reduction techniques.

Term work:
The distribution of marks for term work shall be as follows:
Lab/ Experimental Work: 10 Marks
Mini Project: 05 Marks
Attendance (Theory & Practical): 05 Marks
Assignments: 05-marks

Oral Exam:
Examination is to be conducted based on the entire Syllabus of CSC701:
Machine Learning.
Suggested List of Experiments
Sr. Title of Experiment Date of Date of Pg Grade Sign
No. Performance Submission No.

1 To implement Linear
Regression.
2 To implement Logistic
Regression.
3 To implement Ensemble
learning
(bagging/boosting)
4 To implement SVM

5 To implement PCA

6 To implement LDA

7 To implement DB Scan

8 To implement CART

9 Innovative experiment

10 Assignment no.1

11 Assignment no. 2

12 Mini Project

13 Course certificate
Program Outcomes
Engineering Graduates will be able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,


and an engineering specialization to the solution of complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences,
and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and research


methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modelling to complex engineering activities with
an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive clear
instructions.

11. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Machine Learning Mini Project
Object Detection for Visually Impaired People
By Sanjana Bhosle, Krutika Bhide, Gaurav Sharma

Data set used:

More than 50 images are used for each Class to train the model. Airpods

Keys

Purse
Spectacle Case

Stapler

Code used for training Data:

import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras
import layers, models import os

# Set paths to dataset train_dir = '

C:\Users\Sanjana\OneDrive\Desktop\MiniProject\Project_code\Image_Collection val_dir = '


C:\Users\Sanjana\OneDrive\Desktop\MiniProject\Project_code\Label'

# Image data generator for augmentation and rescaling train_datagen


= ImageDataGenerator( rescale=1./255, rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2, shear_range=0.2, zoom_range=0.2,
horizontal_flip=True, fill_mode='nearest'

val_datagen = ImageDataGenerator(rescale=1./255)

# Create generators train_generator =

train_datagen.flow_from_directory(

train_dir, target_size=(224, 224),


batch_size=32, class_mode='categorical'

val_generator = val_datagen.flow_from_directory( val_dir,


target_size=(224, 224), batch_size=32, class_mode='categorical'

model = models.Sequential([

layers.Conv2D(32, (3, 3), activation='relu', input_shape=(224, 224, 3)),


layers.MaxPooling2D(pool_size=(2, 2)),

layers.Conv2D(64, (3, 3), activation='relu'), layers.MaxPooling2D(pool_size=(2, 2)),

layers.Conv2D(128, (3, 3), activation='relu'),

layers.MaxPooling2D(pool_size=(2, 2)), layers.Flatten(), layers.Dense(128,

activation='relu'), layers.Dense(64, activation='relu'),

# Output layer for 5 classes

layers.Dense(5, activation='softmax')
])

model.compile( optimizer='adam',
loss='categorical_crossentropy', metrics=['accuracy']

history = model.fit( train_generator, steps_per_epoch=train_generator.samples //


train_generator.batch_size, validation_data=val_generator,
validation_steps=val_generator.samples // val_generator.batch_size, epochs=10

model.save('keras_model.h5')

print("Model training completed and saved.")

Code used for prediction:

import tensorflow.keras import numpy as


np import cv2

import pyttsx3

# Initialize the text-to-speech engine engine = pyttsx3.init()

# Disable scientific notation for clarity

np.set_printoptions(suppress=True)

# Load the model model =


tensorflow.keras.models.load_model('keras_model.h5') # Create the array of the
right shape to feed into the keras model data = np.ndarray(shape=(1, 224, 224,
3), dtype=np.float32)

# Replace this with the path to your image

#cam = cv2.VideoCapture('200_sam1.jpeg') #cam =


cv2.VideoCapture('InputVideo3.mp4') cam = cv2.VideoCapture(0)

while True:

_, img = cam.read() img = cv2.resize(img, (224, 224)) image_array = np.asarray(img)


normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1 data[0] = normalized_image_array

prediction = model.predict(data)
for i in prediction: if i[0] > 0.7:

text = "Airpods" if i[1] > 0.7:

text = "Keys" if i[2] > 0.7:

text = "Purse" if i[3] > 0.7:

text = "Spectacle Case" if i[4] > 0.7:

text = "Stapler"

# Display the text on the image img = cv2.resize(img, (500, 500)) cv2.putText(img, text, (10, 30),
cv2.FONT_HERSHEY_COMPLEX_SMALL, 2, (0, 255,

0), 1)

cv2.imshow('img', img)

# Speak out the detected object #engine.say(f"Detected object:


{text}")

engine.say(text)

engine.runAndWait()

if cv2.waitKey(1) & 0xFF == ord('q'):

break

# Release the webcam and close all windows cam.release() cv2.destroyAllWindows()

Result:

You might also like