Practical File OF Machine Learning
Practical File OF Machine Learning
OF
MACHINE LEARNING
SESSION 2022-2026
Department of Computer Science
Global Institute of Technology & Management,
(Gurugram University)
Farrukh Nagar, Haryana, India
SUBMITTED BY SUBMITTED TO
Name: Shubham Kumar Chaubey Name: Mr. Muzamil Aslam
Roll No.: 221116 Designation: Professor
Semester: 6th- B
S.
EXPERIMENT DATE SIGNATURE
NO.
1. Automatic Word Analysis in NLP 11-02-2025
Classification Algorithms and ROC
2. 28-02-2025
Interpretation
Customer Segmentation using K-Means
3. 21-03-2025
Clustering
Neural Networks: Feedforward, CNN, and
4. 28-03-2025
RNN
5. Feature Selection Techniques 04-04-2025
INDEX
sis
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer, WordNetLemmatizer
from collections import Counter
from textblob import TextBlob
# 2. Removing stopwords
stop_words = set(stopwords.words("english"))
filtered_words = [word for word in tokens if word.isalnum()
and word not in stop_words]
# 6. Sentiment Analysis
blob = TextBlob(text)
sentiment = blob.sentiment.polarity # Range from -1
(negative) to 1 (positive)
# Output Results
print("Original Text:", text)
print("\nTokenized Words:", tokens)
print("\nFiltered Words (Without Stopwords):", filtered_words)
print("\nStemmed Words:", stemmed_words)
print("\nLemmatized Words:", lemmatized_words)
print("\nWord Frequency:", word_freq)
print("\nSentiment Analysis Score:", sentiment)
if sentiment > 0:
print("Overall Sentiment: Positive ")
elif sentiment < 0:
print("Overall Sentiment: Negative ")
else:
print("Overall Sentiment: Neutral ")
Explanation:
Expected Output:
Original Text: Machine learning is a branch of artificial
intelligence that enables computers to learn from data...
Conclusion:
This experiment successfully demonstrates automatic word analysis using
machine learning and NLP techniques, covering:
✅ Tokenization
✅ Stopword Removal
✅ Stemming & Lemmatization
✅ Word Frequency Analysis
✅ Sentiment Analysis
Dvlnxfbnlfbncnnvnlx
bfbnvlnClustering: The dataset contained raw, ungrouped customer data
without clear segmentation.
After Clustering: The K-Means algorithm successfully identified distinct customer
segments based on their annual income and spending patterns.
Customer Segmentation: The segmented customers represent different shopper
profiles, allowing targeted marketing strategies to be devised.
# -----------------------------
# Assignment 1: Feedforward NN for MNIST
# -----------------------------
print("Training Feedforward NN on MNIST...")
vnnnnnnnnnnnnnnnnnnnnnnnnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxjjjjjjjjjjjjjjjjjjjjjjjjjjjjjlxxxxxxxx
xxxxxxxxxxxxxxxxxxxxllllllllllllllllllllllllllllllllllmean
texture 0.323782 1.000000 ... 0.415185
fvbnum
Experiment 7: One Assignment to be done in
Grouping
Grouping Data using K-Means Clustering
Objective:
Software/Tools Required:
Python
Libraries: pandas, sklearn, matplotlib, seaborn
Dataset:
Tasks to Perform:
# Load dataset
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
# Apply KMeans
kmeans = KMeans(n_clusters=3, random_state=42)
df['cluster'] = kmeans.fit_predict(X)
Sample Output:
Silhouette Score: 0.66
A scatter plot will display 3 groups of data points with distinct colors
and black centroids.
Expected Learning Outcomes: