Aiml - 4351601
Aiml - 4351601
Aiml - 4351601
Laboratory Manual
(Foundation of AI and ML)
(4351601)
DTE’s Vision:
● To provide globally competitive technical education;
● Remove geographical imbalances and inconsistencies;
● Develop student friendly resources with a special focus on girls’ education
and support to weaker sections;
● Develop programs relevant to industry and create a vibrant pool of technical
professionals.
DTE’s Mission:
Institute’s Vision:
Institute’s Mission:
Department’s Vision:
Department’s Mission:
Foundation of AI and ML(4351601)
Certificate
Place:…………..
Date: …………………..
Preface
The primary aim of any laboratory/Practical/field work is enhancement of required skills as
well as creative ability amongst students to solve real time problems by developing relevant
competencies in psychomotor domain. Keeping in view, GTU has designed competency focused
outcome-based curriculum -2021 (COGC-2021) for Diploma engineering programmes. In this more
time is allotted to practical work than theory. It shows importance of enhancement of skills amongst
students and it pays attention to utilize every second of time allotted for practical amongst Students,
Instructors and Lecturers to achieve relevant outcomes by performing rather than writing practice in
study type. It is essential for effective implementation of competency focused outcome- based Green
curriculum-2021. Every practical has been keenly designed to serve as a tool to develop & enhance
relevant industry needed competency in each and every student. These psychomotor skills are very
difficult to develop through traditional chalk and board content delivery method in the classroom.
Accordingly, this lab manual has been designed to focus on the industry defined relevant outcomes,
rather than old practice of conducting practical to prove concept and theory.
By using this lab manual, students can read procedure one day in advance to actual
performance day of practical experiment which generates interest and also, they can have idea of
judgement of magnitude prior to performance. This in turn enhances predetermined outcomes amongst
students. Each and every Experiment /Practical in this manual begins by competency, industry relevant
skills, course outcomes as well as practical outcomes which serve as a key role for doing the practical.
The students will also have a clear idea of safety and necessary precautions to be taken while
performing experiment.
This manual also provides guidelines to lecturers to facilitate student-centred lab activities for
each practical/experiment by arranging and managing necessary resources in order that the students
follow the procedures with required safety and necessary precautions to achieve outcomes. It also
gives an idea that how students will be assessed by providing Rubrics.
Fundamentals of machine learning course will help students to build up core competencies in
understanding machine learning approaches and students will be able to design and train machine
learning modes for various use cases. The lab work of the course is designed to develop crisp
understanding of the underpinning theory.
Although we try our level best to design this lab manual, but always there are chances of
improvement. We welcome any suggestions for improvement.
3 | Page
Foundation of AI and ML (4351601)
1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, science
and engineering fundamentals and engineering specialization to solve the engineering
problems.
2. Problem analysis: Identify and analyse well-defined engineering problems using codified
standard methods.
4. Engineering Tools, Experimentation and Testing: Apply modern engineering tools and
appropriate technique to conduct standard tests and measurements.
7. Life-long learning: Ability to analyze individual needs and engage in updating in the context
of technological changes in field of engineering.
4 | Page
Foundation of AI and ML (4351601)
5 | Page
Foundation of AI and ML (4351601)
The following industry relevant skills are expected to be developed in the students by
performance of experiments of this course.
a) Student will learn to automate variety of task making system more efficient and cost
effective.
b) Student will learn efficient handling of data that will cater to better data analytics
c) Student will lean to implement AI and ML approaches to varied field of applications from
healthcare to e-commerce.
6 | Page
Foundation of AI and ML (4351601)
Date: ……………
Practical No.1: Use Cancer Dataset for detecting whether the cancer cells in data are
benign or malignant. The data contains 2 types of cancers: 1. benign
cancer (B) and 2. Malignant cancer (M). Use relevant ML techniques for
the same.
A. Objective: To develop a machine learning model to accurately classify cancer cells
as benign or malignant.
B. Expected Program Outcomes (POs):-PO1, PO2, PO3, PO4, PO5, PO6, PO7
L. References / Suggestions
1. https://www.kaggle.com/datasets/erdemtaha/cancer-data
2. https://towardsdatascience.com/building-a-simple-machine-learning-
model-on-breast-cancer-data-eca4b3b99fa3
M. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performe Performed students
ntivelyparticipate
d practical with performing
dinperformance
Engagement /5 practical others help practical but not
him/hers tried him/herself
elf
Work is submitted
Work done after
later than 1week nd
2 week but
Time /5 Completed Work submitted
but by the end of before the end
the work nd after 3 week time
2 week rd
of 3 week
within
1week
Date: ……………
Practical No.2: Implement following activation functions using python to build simple
neural network. a. ReLU b. Sigmoid c. Tanh
A. Objective: To understand and develop python code to implement activation
functions
B. Expected Program Outcomes (POs):- PO1, PO2, PO3, PO4, PO5, PO6, PO7
H. Resources/Equipment Required
Sr.No. Instrument/Equipment
Specification Quantity
/Components/Trainer kit
1 System supporting Jupyter Python 3.x 1
Notebook
2. What is the range of output values produced by the sigmoid activation function?
L. References / Suggestions
1. https://towardsdatascience.com/activation-functions-neural-networks-
1cbd9f8d91d6
2. https://www.baeldung.com/cs/sigmoid-vs-tanh-functions
M. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performed Performed students
ntivelyparticipate
practical practical with performing
dinperformance
Engagement /5 him/herself others help practical but not
tried him/herself
Work is
Work done after
submitted later nd
2 week but
Time /5 Completed Work submitted
than 1week but before the end
the work nd after 3 week time
by the end of 2 rd
of 3 week
within 1week
week
Date: ……………
Practical No.3: Implement following feed forward neural network using python
programming: a. Single layer feed forward neural network. b. Multi-layer
feed forward neural network.
A. Objective: To understand and develop python code to implement neural network
B. Expected Program Outcomes (POs):-PO1, PO2, PO3, PO4, PO5, PO6, PO7
H. Resources/Equipment Required
Sr.No. Instrument/Equipment
Specification Quantity
/Components/Trainer kit
1 System supporting Jupyter Python 3.x 1
Notebook
L. References / Suggestions
1. https://www.cs.cmu.edu/afs/cs/academic/class/15381-
s07/www/slides/042407neuralNetworks.pdf
M. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performed Performed students
ntivelyparticipate
practical practical with performing
dinperformance
Engagement /5 him/herself others help practical but not
tried him/herself
Work is
Work done after
submitted later nd
2 week but
Time /5 Completed Work submitted
than 1week but before the end
the work nd after 3 week time
by the end of 2 rd
of 3 week
within 1week
week
Date: ……………
Practical No.4: Perform following data preprocessing on text/paragraph using NLTK
library:
a. Write a Python program to tokenize words, sentence wise.
b. Write a python program that accepts the list of tokenized word and
stems it into root word.
c. Write a program in python to identify the part of speech for each word
in the text.
d. Write a Python NLTK program to remove stop words from a given text.
e. Write a python program for identifying and correcting misspelled
words in a given text, such as an essay or a letter.
A. Objective: Learn data pre-processing using NLTK library to write the python
program.
B. Expected Program Outcomes (POs): PO1, PO2, PO3, PO4, PO5, PO6, PO7
C. Expected Skills to be developed based on competency:
Here is program logic for a Python program that utilizes NLTK for various NLP tasks:
1. Import the necessary modules and libraries:
nltk for NLP functionalities
Specific modules like PorterStemmer or WordNetLemmatizer for word
stemming or lemmatization
2. Define functions for each task:
Tokenization:
Use word_tokenize() to tokenize words
Use sent_tokenize() to tokenize sentences
Word Stemming:
Initialize a stemmer object (e.g., PorterStemmer())
Use the stemmer's stem() function to stem each word
Part-of-Speech (POS) Tagging:
Use pos_tag() to get POS tags for each word
Stop Words Removal:
Use stopwords.words() to get a list of stopwords for a specific
language
Filter out the stopwords from the tokenized words
Misspelled Words Correction:
Initialize a spell checker object (e.g., SpellChecker())
Use the spell checker's correction() function to correct
misspelled words
3. Get user input or load text from a file.
Foundation of AI and ML (4351601)
import nltk
from nltk.stem import PorterStemmer
from nltk.corpus import stopwords
from nltk import pos_tag, word_tokenize
from spellchecker import SpellChecker
# Tokenization
deftokenize_words(text):
return word_tokenize(text)
deftokenize_sentences(text):
return sent_tokenize(text)
# Word Stemming
defstem_words(words):
stemmer = PorterStemmer()
return [stemmer.stem(word) for word in words]
Foundation of AI and ML (4351601)
# POS Tagging
defidentify_pos(words):
return pos_tag(words)
# Example usage
text = "This is an example sentence. And here's another one!"
# Tokenization
words = tokenize_words(text)
sentences = tokenize_sentences(text)
# Word Stemming
stemmed_words = stem_words(words)
# POS Tagging
pos_tags = identify_pos(words)
Foundation of AI and ML (4351601)
I. Resources/Equipment Required
Sr.No. Instrument/Equipment
Specification
/Components/Trainer kit
1 Computer system with Windows 7 or higher Ver., macOS, and
operating system Linux, with 4GB or higher RAM, Python
versions: 2.7.X, 3.6.X
2 Python IDEs and Code Editors jupyter, spyder, google colab, Open
Source : Anaconda Navigator
Ensure that all the necessary equipment and software are in good working
condition.
Never eat or drink in the lab, as it can cause contamination and create safety
hazards.
If any accidents or injuries occur, immediately notify the instructor and seek
medical attention if necessary.
M. References / Suggestions
1. https://www.geeksforgeeks.org/machine-learning/
2. https://www.geeksforgeeks.org/natural-language-processing-nlp-tutorial/
3. https://www.tutorialspoint.com/machine_learning_with_python/index.htm
N. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performe Performed students
ntivelyparticipate
d practical with performing
dinperformance
Engagement /5 practical others help practical but not
him/hers tried him/herself
elf
Work is submitted
Work done after
later than 1week nd
2 week but
Time /5 Completed Work submitted
but by the end of before the end
the work nd after 3 week time
2 week rd
of 3 week
within
1week
Date: ……………
Practical No.5: Implement following Word embedding techniques in NLP.
a. TFIDF- Term Frequency Inverse document Frequency
b. BOW (Bag of Words)
c. Word2Vec
B. Expected Program Outcomes (POs): PO1, PO2, PO3, PO4, PO5, PO6, PO7
as a baseline approach for various NLP tasks like text classification and sentiment
analysis.
c. Word2Vec: Word2Vec is a popular word embedding technique that represents
words as dense vectors in a continuous vector space. It captures the semantic and
syntactic relationships between words by learning from large text corpora using
neural network architectures. Word2Vec offers two approaches: Continuous Bag
of Words (CBOW) and Skip-gram. CBOW predicts a target word from its
surrounding context words, while Skip-gram predicts the context words given a
target word. Word2Vec embeddings are known to capture meaningful
relationships between words and can be used for various NLP tasks like word
similarity, analogy completion, and language generation.
These word embedding techniques provide ways to represent words or
documents in a numerical form that can be easily processed by machine learning
algorithms. They facilitate capturing semantic relationships, similarity, and
contextual information from text data, enabling better understanding and analysis
of natural language. Each technique has its strengths and limitations, and the
choice depends on the specific task and requirements of the NLP application.
Also explore the following links
1. https://scikit-learn.org/stable/user_guide.html
2. https://www.geeksforgeeks.org/word-embeddings-in-nlp/
import math
defcalculate_idf(corpus):
total_documents = len(corpus)
word_document_count = {}
Foundation of AI and ML (4351601)
TF-IDF Calculation:
Multiply the TF score (step 2) with the IDF score (step 3) for each word in a document
to get the final TF-IDF score.
defcalculate_tfidf(tf, idf):
tfidf = {word: tf[word] * idf[word] for word in tf}
return tfidf
1. https://www.geeksforgeeks.org/machine-learning/
2. https://www.geeksforgeeks.org/natural-language-processing-nlp-tutorial/
3. https://www.tutorialspoint.com/machine_learning_with_python/index.ht
N. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performe Performed students
ntivelyparticipate
d practical with performing
dinperformance
Engagement /5 practical others help practical but not
him/hers tried him/herself
elf
Work is submitted
Work done after
later than 1week nd
2 week but
Time /5 Completed Work submitted
but by the end of before the end
the work nd after 3 week time
2 week rd
of 3 week
within
1week
Date: ……………
Practical No.6: Implement Pre Trained word Embedding: GloVe Technique in NLP.
B. Expected Program Outcomes (POs): PO1, PO2, PO3, PO4, PO5, PO6, PO7
2. https://analyticsindiamag.com/hands-on-guide-to-word-embeddings-using-
glove/
H. Resources/Equipment Required
Sr.No. Instrument/Equipment
Specification
/Components/Trainer kit
1 Computer system with Windows 7 or higher Ver., macOS, and
operating system Linux, with 4GB or higher RAM, Python
versions: 2.7.X, 3.6.X
2 Python IDEs and Code Editors jupyter, spyder, google colab, Open
Source : Anaconda Navigator
c) Elmo d) Nltk
M. Assessment-Rubrics
Presentinpractical
Watched other
sessionbutnotatte
Performe Performed students
ntivelyparticipate
d practical with performing
dinperformance
Engagement /5 practical others help practical but not
him/hers tried him/herself
elf
Work is submitted
Work done after
later than 1week nd
2 week but
Time /5 Completed Work submitted
but by the end of before the end
the work nd after 3 week time
2 week rd
of 3 week
within
1week
Foundation of AI and ML
4351601
Lab manuals are prepared by
Ms. Rikita D. Parekh
Lecturer
Government Polytechnic for Girls, Ahmedabad
Branch Coordinator
Shri. Nandu A. Fatak
Head of Department
Information Technology
Government Polytechnic for Girls, Ahmedabad
Committee Chairman
Shri. R. D. Raghani
Head of Department- EC
Principal (I/C)
Government Polytechnic, Gandhinagar