You are on page 1of 7

HOME ASSIGNMENTS

AI/PYTHON_WARMUP_SESSION_2
HOME ASSIGNMENT 1
WHAT IS AN API?
API is the acronym for application programming interface. It is a software intermediary that allows two applications to
communicate with each other.

WHAT IS EXPLORATORY DATA ANALYSIS EXPLAIN WITH EXAMPLE


It is an approach that is used to analyze the data and discover trends, patterns, or check assumptions in data with the
help of statistical summaries and graphical representations.

WHAT IS FEATURE ENGINEERING . EXPLAIN WITH EXAMPLE.


It refers to enhancement of the data set to improve the machine learning model, making the model more accurate.
For example :
If the training model of my project ( Emotion Identifier ) would have classified the images more accurately then the
program would have identified the mood or the emotion of the person more effectively.
WHAT ARE THE STEPS WE HAVE TO FOLLOW WHILE TRAINING A MACHINE
LEARNING MODEL?
1 Collecting the data for the data set
2 Analyzing and classifying the data into the data set
3 Choosing the perfect model for the data set
4 Training the model
5 Fine tuning the model
6 Making predictions using the model

WHAT DO YOU UNDERSTAND BY NLP?


NLP is an acronym for Natural Language Processing. It is an ability of the computer to manipulate, interpret and use the
human language.

WHAT DO YOU UNDERSTAND BY LEXICON BASED SENTIMENT ANALYSIS?


It is an approach in which the machine learning model determines the emotion of the text in positive, neutral and negative.
HOME ASSIGNMENT 2
SOURCE CODE :
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
a = pd.read_csv('PlayTennis.csv')
d = {'sunny': 1, 'overcast': 0, 'rainy': 2}
a['outlook'] = a['outlook'].map(d)
a['windy'] = a['windy'].astype(int)
ct = ColumnTransformer([
('encoder', OneHotEncoder(), ['outlook', 'temp', 'humidity'])
], remainder='passthrough')
a = ct.fit_transform(a)
features = ['outlook_sunny', 'outlook_overcast', 'outlook_rainy', 'temp_cool', 'temp_hot', 'temp_mild', 'humidity_high', 'humidity_normal', 'windy']
x = a[:, :-1]
y = a[:, -1]
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=0)
print(x_train.shape)
print(x_test.shape)
print(y_train.shape)
print(y_test.shape)
dtree = DecisionTreeClassifier(max_depth=3)
dtree = dtree.fit(x_train, y_train)
tree.plot_tree(dtree)
OUTPUT:
HOME ASSIGNMENT 3
SOURCE CODE :
from textblob import TextBlob

tweets = [
"I am very happy today.",
"I feel sad.",
"I do not like this product.",
"The product is good but the delivery system is very poor.",
"I like to eat pizza."
]

for tweet in tweets:


analysis = TextBlob(tweet)
polarity = analysis.sentiment.polarity
subjectivity = analysis.sentiment.subjectivity

if polarity > 0:
sentiment = "Positive"
elif polarity < 0:
sentiment = "Negative"
else:
sentiment = "Neutral"

print(f"Tweet: {tweet}")
print(f"Sentiment: {sentiment} (Polarity: {polarity}, Subjectivity: {subjectivity})")
print()
OUTPUT:

You might also like