Me Internship Certificate(s)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

Internship Report

on

MACHINE LEARNING

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPUR,


ANANTHAPURAMU

In Partial Fulfillment of the Requirements for the Award of the degree of

BACHELOR OF TECHNOLOGY

In
COMPUTER SCIENCE & ENGINEERING
Submitted By
V Sathish - 21695A0533

MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE


(UGC – AUTONOMOUS)
(Affiliated to JNTUA, Ananthapuramu)
(Accredited by NBA, Approved by AICTE, new delhi)
AN ISO 9001:2008 Certified Institution

P. B. No: 14, Angallu, Madanapalle -517325

2022 - 23
2009-2013

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

BONAFIDE CERTIFICATE

This is to certify that the internship work entitled “Stress Detection” is a bonafide work
Carried out by

V Sathish _ 21695A0533

Submitted in partial fulfillment of the requirements for the award of degree Bachelor of

Technology in the stream of Computer Science & Engineering in Madanapalle

Institute of Technology & Science, Madanapalle, affiliated to Jawaharlal Nehru

Technological University Anantapur, Ananthapuramu during the academic year 2022-

2023.

Internship Coordinator Head of the Department


Dr. K. Lakshmi, Dr. R. Kalpana,
Professor, Professor and Head,
Department of CSE Department of CSE

Submitted for the University Examination held on:

Examiner - I Examiner - II
ACKNOWLEDGEMENT
We sincerely thank the MANAGEMENT of Madanapalle Institute of

Technology & Science for providing excellent infrastructure and lab facilities that helped

me complete this Project.

We sincerely thank Dr. C. Yuvaraj, M.E., Ph.D., Principal, for guiding and

providing facilities for completing our Project at Madanapalle Institute of Technology

& Science, Madanapalle.

We express our gratitude to Dr. R. Kalpana, Ph.D., Professor and Head of the

Department of CSE for her continuous support in making necessary arrangements for the

successful completion of the Project.

We express our sincere thanks to the Internship Coordinator, Dr. K. Lakshmi,

Ph.D., Professor, Department of CSE for her tremendous support for the successful

completion of Project.

We express our deep gratitude to our Internship In-Charge Mr.A.GOWTHAM,

M.E., Assistant Professor, Department of CSE, for his guidance and encouragement

that helped us to complete this Project.

We also wish to place on record my gratefulness to other Faculty of CSE

Department and our friends and our parents for their help and cooperation during our

project work.
DECLARATION
We hereby declare that the results embodied in this internship

"MACHINE LEARNING" by us under the guidance of

Mr .A .GOWTHAM , in partial fulfillment of the award of Bachelor of

Technology in Computer Science & Engineering from

Jawaharlal Nehru Technological University Anantapur,

Ananthapuramu.

Date :

Place :

Internship Associate:

Student name - V Sathish


( 21695A0533)

ABSTRACT

Machine Learning is one of the emerging fields of Artificial Intelligence and it has many
applications. It is a tool that uses data and Artificial Intelligence in its areas of application. The
main idea behind the development of machine learning algorithms is to create a model that
understands and analyzes the given data and helps in prediction. Machine learning methods can be
applied to various domains.

With the increase in growth of technology, stress and anxiety in an individual are also increasing.
Stress is invisible and it’s like a slow poison. Stress, tension, and anxiety are the features that could
compromise the psychological wellness of individuals. These factors could lead an individual to
take their own lives. Therefore, it is important for any person to manage stress, to live a healthy and
a balanced life. Many organizations including our government are trying to find the people under
stress and get them treated. This can be achieved if there is a machine that can detect stress by
understanding texts from posts. The main objective of this project is to create a stress detection
machine. The rise of social media is changing people’s life. Now-a-days, with the growing
popularity of social media, people are sharing their activities, moods and interactions through the
social media posts. If we know whether the person is under stress or not, then we can treat them
accordingly. Because, there might be some words that can trigger some sort of anxiety in the people
under stress. The main objective of this project is to identify such people through their posts or
blogs. The machine reads the posts and detects whether the person is under stress or not.

In the internship I have done on Machine Learning, I did a project on Stress detection. The goal of
the project was to create a model to input text from the user and return whether the person is under
stress or not. In order to analyze the human language, recognition is not enough so we use natural
language processing. For example, if we write “I’m happy” in the input box, since the state you are
expressing indicates that you are not under stress then the model should return ‘No stress’. And if
the input given is “I need some help”, then the output should be ‘Stress’.

Keywords: Artificial intelligence, Natural Language Processing

CONTENTS

PAGE
S.NO. TOPIC
NO.
1 INTRODUCTION 1-6
1.1 About Machine Learning 2,3
1.2 Importance and Applications of
4
Machine Learning
1.3 Language used 5
1.4 Need for the Model 6

2 TOOLS AND TECHNIQUES 7,8


2.1 Platform Used 8
2.2 Hardware used 8
2.3 Software used 8

3 PROJECT WORK 9-15


3.1 Project overview 10
3.2 Algorithm 11,12
3.3 Source code 13 - 15

4 CODE AND OUTPUT SCREENSHOTS 16-21

5 CONCLUSION 22

6 BIBLIOGRAPHY 22

7 REFERENCES 23
CHAPTER 1 INTRODUCTION

1
1.1 ABOUT MACHINE LEARNING
Machine learning is a sub-domain of computer science. It uses data and
artificial intelligence in its area of applications. It is considered as the
topnotch pass to the most interesting and growing careers in the current
world. It is used to make predictions and gain insights. This can be
achieved by providing the data to train the model. The learning can be
mainly classified into two types, they are I) Supervised Learning
II) Unsupervised Learning

Supervised Learning: The supervised learning can be achieved by a model


if the data provided is labelled.
Classification and regression problems can be solved by using supervised
learning.

• Classification: In this, we need to categorize the given set of data


into classes.
Examples: Logistic Regression, Classification trees, Support Vector
Machines, Random Forests, Artificial Neural Networks etc.

• Regression: In this, we analyse the effect of the independent


variable on dependent variables.
Examples: Linear Regression, Decision Trees, Bayesian Networks,
Fuzzy Classification etc.

Unsupervised Learning: The unsupervised learning can be achieved by a


model if the data provided is unlabelled. 2
Clustering and Dimension reduction problems can be solved by using
unsupervised learning.

• Clustering: In this, we take the unlabelled data and understand it’s


features and group them accordingly.
Examples: K-means Clustering, Hierarchal Clustering, Gaussian
Mixture models, Genetic Algorithms etc.
• Dimension Reduction: This is the process of reducing the number
of random variables under consideration to make the classification
simple.
Examples: Principal Component Analysis, Tensor Decomposition,
Multi-dimension Statistics, Random Projections etc.
Fig. 1.1 Machine Learning 3

1.2 IMPORTANCE AND APPLICATIONS OF MACHINE LEARNING

With the growing economy, the world is changing and the internet has
become the data generation machine. Machine learning helps the data
analysts to organize and handle this data. It helps in analysing the data and
provides valuable insights. Machine learning allows the software’s to
become more accurate.
It is known to everyone that large companies are describing the Machine
Learning as “The future”. It has many applications in various domains.
Few of them are listed below.
1) Image Recognition
2) Automatic language Translation
3) Medical Diagnosis
4) Stock market Trading
5) Online Fraud Detection
6) Virtual Personal Assistant
7) Email Spam and Malware Filtering
8) Self-driving cars
9) Recommendation Systems (Movie recommendation, Music
Recommendation)
10) Image recognition

4
1.3 LANGUAGE USED:
Python programming language that includes:
1) Basic Syntax including variables.
2) Conditionals, Control Flow(if-else-elif) and Iterations
3) Classes, Objects, Functions, Parameters, and Arguments. (Don’t try
to forgot learn about usage of self-parameter, init and super
functions)
4) Built-In Data Structures like List, Tuples, Dictionaries, Sets
5) List Comprehensions and Generators
6) Basic Algorithms like Searching, Sorting, Dynamic Programming 7)
Basic Data Structures like Arrays, Linked List.
8) File Handling.
9) Basic modules like math, os, sys, urllib, csv.
10) Handling SQL operations with Python using SQLAlchemy or
SQLite3.
11) Numerical Operations with NumPy
12) Data Handling with Pandas
13) Data Visualization with Matplotlib.
14) Basic knowledge of Tkinter (gives you an idea about how graphs are
displayed in Matplotlib and will further help in creating
environments for training RL Agents)

5
1.4 NEED FOR THE MODEL:
Why Stress detection is needed?

Stress, anxiety, and depression are threatening the mental


health of people. Every person has a reason for having a
stressful life. People often share their feelings on social
media platforms like on Instagram in the form of posts and
stories, and on Reddit in the form of asking for suggestions
about their life on subreddits.

In the past few years, many content creators have come


forward to create content to help people with their mental
health. Many organizations can use stress detection to find
which social media users are stressed to help them quickly.
So if you want to learn how to use machine learning to
detect stress on social media posts, this article is for you. In
this article, I will take you through the task of stress
detection with machine learning using Python.
6

CHAPTER 2 TOOLS AND


TECHNIQUES

7
2.1 PLATFORM USED:
Windows 11 Home Single Language
Version: 21H2
2.2 HARDWARE USED:
Processor: AMD Ryzen 7 5700U with Radeon Graphics 1.80 GHz
System type: 64-bit operating system, x64-based processor

2.3 SOFTWARE USED:


o Languages used: Python o
Anaconda prompt o Jupyter
notebook

CHAPTER 3 PROJECT WORK


9

3.1 OVERVIEW
Stress detection is a challenging task, as there are so many
words that can be used by people on their posts that can
show whether a person is having psychological stress or
not. While looking for datasets that I can use to train a
machine learning model for stress detection, I found a
dataset on Kaggle with 116 columns. We only need to use
the text and label column for this task.

The dataset I am using for this task contains data posted on


subreddits related to mental health. This dataset contains
various mental health problems shared by people about
their life. Fortunately, this dataset is labelled as 0 and 1,
where 0 indicates no stress and 1 indicates stress. So in the
section below, I will take you through the task of stress
detection in social media posts using Python.
10
3.2 ALGORITHM

CountVectorizer is a great tool provided by the scikit-learn


library in Python. It is used to transform a given text into a
vector on the basis of the frequency (count) of each word
that occurs in the entire text. This is helpful when we have
multiple such texts, and we wish to convert each word in
each text into vectors (for using in further text analysis). Let
us consider a few sample texts from a document

CountVectorizer creates a matrix in which each unique word


is represented by a column of the matrix, and each text
sample from the document is a row in the matrix. The value
of each cell is nothing but the count of the word in that
particular text sample.

11
PROCEDURE :
Import the necessary Python libraries and the dataset that
we need for this task.
The text column of this dataset to clean the text column with
stopwords, links, special symbols and language errors. Most
used words by the people sharing about their life problems
on social media by visualizing a word cloud of the text
column.
Label column in this dataset contains labels as 0 and 1. 0
means no stress, and 1 means stress.
Use Stress and No stress labels instead of 1 and 0. Prepare
the column accordingly and select the text and label
columns for the process of training a machine learning
model.
Split the dataset into training and test sets.
The problem of binary classification, I will be using the
Bernoulli Naive Bayes algorithm, which is one of the best
algorithms for binary classification problems.
The performance of our model on some random sentences
based on mental health.

12
3.3 SOURCE CODE
import pandas as pd import
numpy as np data =
pd.read_csv("stress.csv")
print(data.head())
print(data.isnull().sum())
import nltk import re
nltk.download('stopwords')
stemmer = nltk.SnowballStemmer("english") from
nltk.corpus import stopwords
import string
stopword=set(stopwords.words('english'))

def clean(text): text =


str(text).lower() text =
re.sub('\[.*?\]', '', text)
text = re.sub('https?://\S+|www\.\S+', '', text)
text = re.sub('<.*?>+', '', text)
text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
text = re.sub('\n', '', text) text = re.sub('\w*\d\w*', '', text)
text = [word for word in text.split(' ') if word not in stopword]
text=" ".join(text)
text = [stemmer.stem(word) for word in text.split(' ')]
text=" ".join(text) return text
data["text"] = data["text"].apply(clean)
13
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS,
ImageColorGenerator
text = " ".join(i for i in data.text) stopwords =
set(STOPWORDS) wordcloud =
WordCloud(stopwords=stopwords,
background_color="white").generate(text) plt.figure(
figsize=(15,10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off") plt.show()
data["label"] = data["label"].map({0: "No Stress", 1: "Stress"})
data = data[["text", "label"]] print(data.head())
from sklearn.feature_extraction.text import CountVectorizer from
sklearn.model_selection import train_test_split

x = np.array(data["text"])
y = np.array(data["label"])

cv = CountVectorizer() X
= cv.fit_transform(x)
xtrain, xtest, ytrain, ytest = train_test_split(X,
y,test_size=0.33,random_state=42) from sklearn.naive_bayes
import BernoulliNB model = BernoulliNB() model.fit(xtrain,
ytrain) user = input("Enter a Text: ")
14
data = cv.transform([user]).toarray() output = model.predict(data)
print(output)
15

CHAPTER 4 CODE AND OUTPUT


SCREENSHOTS

16
17
18
19
20
2
1
5 : CONCLUSION :
So this is how you can train a machine learning model to detect
stress from social media posts. People often share their feelings
on social media platforms. Many organizations can use stress
detection to find which social media users are stressed to help
them quickly. I hope you liked this article on stress detection with
machine learning using Python. Feel free to ask your valuable
questions in the comments section below.

6 : BIBLIOGRAPHY :

o GEEKS FOR GEEKS

o DATA.GOV

o kaggle.com/code/mohaiminul101/ Stress Detection

o geeksforgeeks.org/python-decision-tree-regression-
usingsklearn/#:~:text=Decision%20tree%20regression
%20observes%20features,set%20of%20numbers%20o r
%20values.
o Kaggle.com

22
7.REFERENCES:
o Thecleverprogrammer.com/2021/08/04/ Stress
Detection -with-machine-learning/
o raw.githubusercontent.com/amankharwal/
Websitedata/master/ Stress Detection.csv

23

You might also like