THE ADHYYAN SCHOOL
SHATABDI NAGAR, MEERUT
ARTIFICIAL INTELLIGENCE
(SUBJECT CODE: 843)
PRACTICAL FILE
Name: _________________________
Roll No: _________________________
Adm. No. _________________________
Class & Section: _________________________
INDEX
[Link]. Name of the Program T. Sign
1 Creating Numpy Arrays
2 Creating Series
3 Creating Dataframe
4 Manipulating Dataframe
5 Creating and Displaying dataframe from CSV file
6 Linear Regression Model
7 Create a website containing ML model
8 Classification of Iris dataset using ODM
9 Clustering of Images using ODM
10 Creating Word Cloud using ODM
11 Big data Analytics with ODM
12 Data Story Telling – 1
13 Data Story Telling – 2
14 Data Story Telling- 3
PROGRAM-1
1. Create a numpy array of 2 dimension and display it
To write a program to create NumPy array using the following methods:
a) Rank-1 array using list
b) Rank-2 array using list of tuples
CODE:
import numpy as np
e=eval(input("Enter a list"))
#a)
arr1= [Link](e)
print(arr1)
#b)
arr2= [Link]([(1,2,3,4), (4,5,6,7)])
print(arr2)
OUTPUT:
PROGRAM-2
2. Create a Series using dictionary to store the fruit name as index and cost as
values and display it
CODE :
import pandas as pd
# Dictionary of fruit names and costs
fruit_data = {'strawberry': 1.80, 'pineapple': 0.95, 'kiwi': 0.90, 'muskmelon': 2.50}
# Create a Pandas Series from the dictionary
fruit_series = pd. Series (fruit_data)
# Display the Series
print(fruit_series)
OUTPUT
PROGRAM -3
3. To write a program to create the following dataframe using dictionary of list.
a) Display the DataFrame.
b) Display first 5 records.
c) Display last 10 records.
d) Display the number of missing values in the dataset
PROGRAM:
import pandas as pd
import numpy as np
a= [Link](['Arnav', 85, 'Cricket'])
b= [Link](['Neha', 92, 'Volleyball'])
c= [Link](['Priya', 78, 'Hockey'])
d= [Link](['Rahul', 83, 'Badminton'])
sports= [Link]([a,b,c,d], columns=['Students', 'Marks','Sports'],
index=[1,2,3,4])
print(sports)
print([Link]())
print([Link](10))
print([Link]())
OUTPUT
PROGRAM-4
4. Create a data frame to store 5 students name and their English, Maths and
Science marks using Dictionary
a. Add a new row In the data frame
b. Add a new column in the data frame Hindi with values
[89,90,95,68,100]
c. Delete a row from the table
d. Delete the column Hindi marks from the table
e. Display the Data frame attributes like index, columns, head (), tail (),
shape ()
PROGRAM
PROGRAM-5
5. To write a program for importing the given CSV file(‘[Link]’) to a
DataFrame and display it.
a. Read the CSV file and convert it Into Python DataFrame
CODE
import pandas as pd
df=pd.read_csv("[Link]")
print(df)
OUTPUT
EmployeeID Name Department Salary
0 101 John HR 55000
1 102 Jane IT 72000
2 103 Emily Finance 64000
3 104 Michael Marketing 58000
4 105 James Manager 75000
b. To write a program for exporting the given DataFrame to a CSV file.
PROGRAM
import pandas as pd
df=[Link]({'ProductID':[201,202,203,204],'ProductName':
['Laptop','Smartphone', 'Headphones', 'Monitor'],'Price':
[75000,25000,1500,12000],'Stock':[50,100,200,75]})
print(df)
df.to_csv("[Link]", index=False)
print(df)
OUTPUT
PROGRAM-6
6. A company wants to estimate the expected salary for a new employee who has
4.5 years of experience. Using the linear regression model trained on the
Salary_Data.csv file, predict the salary for this employee. Also, explain how
accurate our prediction is based on the model evaluation metrics. Base
Reference: [Link]
PROGRAM:
import pandas as pd
import numpy as np
df=pd.read_csv("Salary_Data.csv")
df
[Link]()
[Link]
X=[Link](df['YearsExperience']).reshape(-1,1)
Y=[Link](df['Salary']).reshape(-1,1)
print([Link], [Link])
X_train, x_test, Y_train, y_test=train_test_split(X,Y,test_size=0.2,
shuffle=True, random_state=10)
model=LinearRegression()
[Link](X_train,Y_train)
[Link](X_train,Y_train)
[Link](x_test, y_test)
experience=4.5
predicted_salary=[Link]([[experience]])
print(predicted_salary)
OUTPUT
Years Experience Salary
0 1.1 39343
1 1.3 46205
2 1.5 37731
3 2.0 43525
4 2.2 39891
... ... ...
29 10.5 121872
Years Experience Salary
0 1.1 39343
1 1.3 46205
2 1.5 37731
3 2.0 43525
4 2.2 39891
(30, 2)
(30, 1) (30, 1)
Linear Regression()
0.95
0.93
[[68000.]]
PROGRAM -7
7. CREATING A WEBSITE CONTAINING AN ML MODEL 1. Go to the website
[Link]
(ATTACH THE SCREENSHOTS)
OUTPUT
PROGRAM-8
Classification and Model Evaluation
Perform Classification on Iris Dataset sing Orange Data Mining tool. You can
download the dataset from link Image classification model using Orange data mining
too.
Aim
To perform classification on the Iris dataset and evaluate the classification model using the
Orange Data Mining tool.
Software Required
Orange Data Mining Tool
Iris Dataset (CSV / built-in dataset)
Dataset Description
The Iris dataset contains 150 instances of iris flowers. Each instance has four numerical
attributes:
1. Sepal Length
2. Sepal Width
3. Petal Length
4. Petal Width
The class attribute represents the species of the iris flower, namely:
Iris Setosa
Iris Versicolor
Iris Virginica
Algorithm Used
Logistic Regression (Classification Algorithm)
Procedure / Steps
1. Open the Orange Data Mining tool.
2. Drag and drop the File widget onto the workflow canvas.
3. Load the Iris dataset using the File widget.
4. Drag the Data Table widget and connect it to the File widget to view the dataset.
5. Drag the Logistic Regression widget and connect it to the File widget.
6. Drag the Test & Score widget and connect:
o File → Test & Score
o Logistic Regression → Test & Score
7. Select 10-fold cross validation for model evaluation.
8. Drag the Confusion Matrix widget and connect it to the Test & Score widget.
9. Observe the classification results and performance metrics.
Output / Observation
The Iris dataset was successfully loaded into Orange Data Mining. The classification model
was built using the Logistic Regression algorithm and evaluated using 10-fold cross
validation.
Model Evaluation Results
Accuracy: Approximately 95%
Precision: High for all three classes
Recall: High for all three classes
F1-Score: Above 0.90
The Confusion Matrix indicates that:
Iris Setosa is classified with 100% accuracy
Minor misclassification occurs between Iris Versicolor and Iris Virginica
Overall model performance is excellent
Result
The classification of the Iris dataset was successfully performed using the Orange Data
Mining tool. The model achieved high accuracy and demonstrated effective classification
performance.
Conclusion
Orange Data Mining provides an efficient and user-friendly platform for performing
classification and model evaluation without programming. The Iris dataset was accurately
classified, and the evaluation metrics confirm the reliability of the classification model.
PROGRAM -9
Computer Vision - Clustering
Cluster images of different flowers like roses, sunflowers, Lillies into distinct groups
based on their visual characteristics using ODM
Computer Vision – Image Clustering using Orange Data Mining (ODM)
Aim
To perform image clustering on different flower images such as roses, sunflowers, and lilies
based on their visual characteristics using Orange Data Mining (ODM).
Software Required
Orange Data Mining Tool (ODM)
Image Dataset (flower images: roses, sunflowers, lilies)
Dataset Description
The dataset consists of digital images of different flowers, including:
Roses
Sunflowers
Lilies
The images differ in color, shape, texture, and size, which are used as visual features for
clustering.
Technique Used
Image Embedding
Clustering (k-Means Clustering)
Procedure / Steps
1. Open the Orange Data Mining tool.
2. Drag and drop the Import Images widget onto the canvas.
3. Select the folder containing flower images (roses, sunflowers, and lilies).
4. Drag the Image Embedding widget and connect it to the Import Images widget.
5. Drag the k-Means clustering widget and connect it to the Image Embedding widget.
6. Set the number of clusters (k = 3) corresponding to three flower types.
7. Drag the Image Viewer widget and connect it to the k-Means widget.
8. Observe the clustered images based on visual similarity.
Output / Observation
The flower images were successfully imported into Orange Data Mining using the Import
Images widget. Image features were extracted using the Image Embedding technique. The
extracted features were clustered using the k-Means clustering algorithm.
The results show that:
Images of roses, sunflowers, and lilies are grouped into distinct clusters
Images with similar color and shape appear in the same cluster
The clustering is based on visual characteristics such as texture and color patterns
PROGRAM -10
Natural Language Processing – Word Cloud
Perform Text pre-processing on any newspaper article or story using Orange
datamining tool.
1. Aim
To perform text preprocessing on the newspaper blog titled "Impact of AI and Automation
on India’s Employment Landscape" and generate a Word Cloud to visualize the core themes.
2. Selected Article Details
Headline: Impact of AI and Automation on India’s Employment Landscape.
Date: 23 Oct 2024.
Core Theme: The dual nature of AI integration—how it creates high-skilled jobs in
sectors like Finance and Healthcare while displacing routine manual labor in
Manufacturing and IT.
3. The Orange Data Mining Workflow
To process this specific article, the following workflow is used in Orange:
1. Corpus Widget: The blog text is loaded here.
2. Preprocess Text Widget: This is the most critical step. We apply the following:
o Transformation: All text is changed to lowercase.
o Tokenization: The text is split into words.
o Stopwords Removal: Common words (like "the," "is," "and") and blog-
specific noise (like "share," "twitter," "facebook") are filtered out.
o Lemmatization: Words like "automating" and "automation" are grouped into
their root form.
3. Word Cloud Widget: This widget visualizes the results.
4. NLP Analysis & Word Cloud Visualization
After preprocessing the provided article, the following terms emerge as the most frequent
and significant:
Primary Keywords: AI, Automation, India, Employment, Jobs, Skills.
Sectoral Keywords: Healthcare, Manufacturing, IT, Finance, Agriculture.
Policy Keywords: Upskilling, Reskilling, NITI Aayog, Mission.
5. Conclusion & Inference
The Word Cloud demonstrates that the discussion around AI in India is centered on the
"Skill Gap." The prominence of the word "Upskilling" and "Reskilling" in the cloud shows
that the solution to job displacement is education. By using NLP techniques, we have
successfully reduced a 1,500-word technical blog into a single visual that communicates the
"Future of Work" in India.
PROGRAM -11
Big data Analytics
To build a classification model on the Heart Disease dataset in order to predict the
presence or absence of heart disease.
1. Aim
To build and analyze a Big Data Classification Model that can accurately predict the
presence or absence of heart disease in a patient based on their medical history and clinical
parameters.
2. The Concept of Classification
In Big Data Analytics, Classification is a supervised learning technique where the computer
learns to categorize data into specific groups. In this project, the model acts as a binary
classifier that sorts patients into two distinct labels:
Presence (1): The patient is diagnosed with heart disease.
Absence (0): The patient is healthy.
3. Data Indicators (Features)
The model analyzes several critical medical "features" to make its decision. These include:
Demographics: Age and Gender.
Chest Pain Type (CP): Categorized by severity.
Cholesterol Levels: High levels often indicate higher risk.
Maximum Heart Rate (Thalach): Heart performance during physical activity.
Resting Blood Pressure (Trestbps): Baseline cardiovascular health.
4. How the Model Works (The Process)
1. Data Collection: A large dataset (like the UCI Heart Disease dataset) is fed into the
system containing records of thousands of previous patients.
2. Pattern Recognition: The model identifies correlations—for example, it might find
that patients over age 50 with a specific type of chest pain have an 80% higher
chance of heart disease.
3. Training & Testing: The data is split. The model "studies" the training data to build
its logic and then "tests" itself on the remaining data to check if its predictions are
correct.
4. Prediction: Once ready, the model can take a new patient's report and instantly
classify them as high-risk or low-risk.
5. Conclusion
This classification model demonstrates how Big Data can be used in healthcare to save lives.
By automating the screening process, medical professionals can identify high-risk patients
faster and with higher precision. The success of the model is measured by its Accuracy,
ensuring that it minimizes "False Negatives" (missing a sick patient) and "False Positives"
(wrongly diagnosing a healthy patient).
PROGRAM -12 Data Story telling
Dataset: Climate Change Indicators
Visualise the Data and analyse the trends:
Use tools like Excel to create visuals:
A line graph for temperature changes over the years
1. Data Visualization (Line Graph)
An effective visualization for this dataset is a dual-axis line graph. This allows you to see
how $CO_{2}$ levels and temperature anomalies move together over time.
2. Trend Analysis
Based on the data provided in your narrative, here is the technical breakdown of the trends:
Positive Correlation: There is a direct, positive correlation between $CO_{2}$
emissions and temperature. For every 5 billion tonne increase in $CO_{2}$, we
observe a significant upward crawl in the temperature baseline.
The 2010–2015 Surge: This period is identified as the "Climax" of the dataset,
showing the sharpest acceleration in emissions. This suggests a period of rapid
industrial activity or energy consumption during those years.
Temperature Velocity: A warming rate of 0.12°C per year is extremely rapid in
geological terms. If this trend continues linearly, the planet would warm by 1.2°C
every decade, which exceeds many international climate safety targets.
4. Summary for Your Presentation
Indicator Trend Direction Magnitude
Global Temperature Increasing 📈 +0.12°C Every Year
$CO_{2}$ Emissions Increasing 📈 +5 Billion Tonnes every 5 years
Deforestation Decreasing 📉 -0.5 Million Hectares per year
A bar chart for CO₂ emissions over the years.
A combined bar chart for deforestation and emissions over the years
Craft a Narrative Using Freytag’s Pyramid:
1. Introduction: Every year, there is an alarming gradual increase in the average global
temperature. The carbon dioxide emissions are also increasing by the year, and that is
not good at all. On the brighter side, the deforestation rates have been reducing.
2. Rising Action: From the year 2000, a gradual increase in the temperature and CO2
emissions can be seen. Every 5 years approximately, there is an increase of around 5
billion tonnes of CO2. There is also an increase of 0.12 Celsius every year in the global
average temperature. On the contrary, there is a steady decrease in the deforestation
rate through the years. There is a decrease of 0.5 million hectares of deforestation every
year.
3. Climax: There was a significant increase in the carbon dioxide emission rate between
2010 and 2015. Afterwards, it steadily increased. Under deforestation rates, there was a
noticeable drop in 2005.
4. Falling Action: Looking at the data collected over the years, we should focus on
keeping the global average temperature in check, making sure we don’t have to worry
about global warming anytime soon. We can do this by keeping our ozone layer intact,
so that no harmful sun rays reach us. We must also keep the CO2 emissions in check,
and we can bring it down by planting more trees, which brings us to our late indicator.
We are doing a good job with the deforestation rates, seeing that it is decreasing. We
must keep this up and also do reforestation actions of reforestation to restore what
we've destroyed.
5. Conclusion:After looking at all of the collected data, it is clear that we need to have a
sense of urgency for the state of our environment today. The CO2 emissions are rising,
the global temperature’s getting higher, etc. So we need to take urgent action to reverse
these effects so that our beloved Earth lasts past our generation!
Present Your Data Story: Combine your visuals and narrative into a cohesive
presentation to inform your audience about the issue and inspire action.
(ATTACH THE POSTER YOU MADE WITH THE CHARTS AND SUMMARY)
Visual Data:
The Data Story: "A Race Against the Thermometer"
I. Introduction: The Warming Warning
Today, our planet is sending us a clear signal. Every year, we witness an alarming increase in
global average temperatures. As $CO_{2}$ emissions continue to climb, the greenhouse
effect intensifies. However, there is a silver lining: global deforestation rates are finally
beginning to slow down, offering us a vital tool to fight back.
II. Rising Action: The Numbers Behind the Heat
Since the year 2000, the data shows a relentless climb. Approximately every five years,
$CO_{2}$ emissions have surged by 5 billion tonnes. Parallel to this, the global temperature
has been creeping up by 0.12°C annually. On the positive side, our conservation efforts have
started to show results—deforestation has been dropping steadily by 0.5 million hectares per
year.
III. Climax: The Turning Point
The period between 2010 and 2015 marked a critical acceleration in $CO_{2}$ output,
setting a dangerous new baseline for global emissions. Simultaneously, 2005 stood out as a
pivotal year for our forests, where a noticeable drop in deforestation rates proved that
international policy and environmental action could actually change the trend.
IV. Falling Action: The Path to Restoration
The data makes our mission clear: we must stabilize the global temperature to prevent the
worst effects of global warming. Our strategy must be twofold:
1. Protect the Shield: Keep our ozone layer intact to block harmful UV radiation.
2. The Green Lung: Use our success in reducing deforestation as a springboard for
reforestation. Planting trees is our best defense for absorbing the excess $CO_{2}$
we’ve already emitted.
V. Conclusion: The Urgency of Now
The evidence is undeniable. With $CO_{2}$ and temperatures reaching record highs, we
cannot afford to wait. We must take urgent, collective action to reverse these trends. Let’s
build on our success in protecting forests to ensure that Earth remains a habitable, vibrant
home for generations to come.
3. Poster Summary (Quick View)
The Problem The Trend The Solution
+5 Billion Tonnes of $CO_{2}$ every 5
Rising Emissions Transition to clean energy.
years.
Protect the Ozone & reduce
Global Warming +0.12°C Temperature rise every year.
pollution.
Reforestation: Plant more to
Deforestation Decreasing by 0.5M hectares/year.
restore!
PROGRAM -13 Data Story telling
Consider the following information: In 2016, a survey found that India has about
2.6 million STEM graduates. The percentage of women at the various IITs are as
follows: IIT Kanpur - 6.5%
IIT Guwahati - 6.3%
IIT Delhi - 10%
IIT Bombay - 10%
IIT Mandi - 14%
Few reasons for this abnormal number are:
• Women face gender bias in performance evaluation/jobs
• Young marriage age
• Pressure of handling household chores as well as excelling at the job
Create an effective data story with an effective visual and compelling narrative
about the plight of women in STEM in India.
(ATTACH THE POSTER YOU MADE WITH THE CHARTS AND SUMMARY)
Visual Data:
Data Story: The Leaky Pipeline of Indian STEM
Introduction
India is a global powerhouse for talent, producing approximately 2.6 million STEM
graduates as of 2016. However, a closer look at our premier institutions—the IITs—reveals a
startling disparity. While the halls of these institutes are filled with the brightest minds, the
voices of women remain a whisper in the crowd.
The Rising Action
As we analyze the data across various campuses, the numbers paint a grim picture. At IIT
Guwahati and IIT Kanpur, women make up only 6.3% and 6.5% of the student body,
respectively. Even at the "top" of this specific list, IIT Mandi, the figure struggles to reach
14%. This means that despite millions of women graduating in STEM, only a tiny fraction
enters the nation’s most elite engineering corridors.
The Climax -The "plight" of women in STEM isn't a result of a lack of merit; it is a result of a
Socio-Systemic Barrier. The climax of this struggle happens at the intersection of career and
tradition. Many brilliant women are forced to drop out or settle for less due to:
The "Double Burden": Being expected to excel at high-pressure tech jobs while
simultaneously managing 100% of household chores.
Societal Timelines: The pressure of "young marriage age" often collides with the
most critical years of higher education and career building.
Institutional Bias: Gender bias in performance evaluations and hiring processes that
often favor men for "strenuous" STEM roles.
Falling Action- This exclusion leads to a massive loss of innovation. When 50% of the
population is underrepresented in the rooms where the future is built, the technology
created is inherently biased. The burden of domestic expectations and the lack of workplace
support act as a "Leaky Pipeline," where female talent is lost at every stage of the journey.
Resolution- To bridge this gap, we must move beyond just "offering seats." The resolution
lies in structural empathy:
1. Shared Responsibility: Shifting the mindset that household chores are a "woman’s
job."
2. Mentorship: Creating strong support systems within IITs to help women navigate
gender bias.
3. Policy Change: Implementing gender-neutral hiring and support for early-career
researchers.
Summary Poster Text:
"India has 2.6 Million STEM graduates, yet women represent less than 15% in our top IITs.
It's time to break the bias and share the burden."
PROGRAM – 14 Data Story telling
A 2023 survey analyzed smartphone usage patterns among Indian teenagers:
Age Group % Using Smartphone Daily
13–15 65
16–18 78
19–21 85
22–25 90
Possible reasons for high smartphone usage:
● Increased access to affordable smartphones and internet.
● Dependence on social media, messaging apps, and online entertainment.
● Online learning and digital education resources.
● Peer pressure and social connectivity expectations.
1. Analyse trends in smartphone usage among different age groups.
According to the given data, the apparent trend is an increase in % usage of
smartphones as age increases. There is a 13% increase between young teens and older
teens, a 7% increase between older teens and young adults, and a 5% increase between
young adults and older adults.
2. Create an effective visual (e.g., line chart or bar chart) to represent the data.
(ATTACH THE GRAPH)
3. Craft a data story using Freytag’s Pyramid:
o Introduction: These days, there has been an alarming increase in smartphone usage,
especially among young people. The rise of affordable smartphones, easy internet access,
and the growth of social media have turned smartphones into an indispensable part of daily
life. According to a 2023 survey of Indian teenagers, smartphone usage patterns reveal
notable trends that raise concerns about digital habits, especially as users grow older.
o Rising Action: The survey shows that smartphone usage increases steadily as teenagers
grow older. Among 13-15-year-olds, only 65% of the group use smartphones daily. However,
as the age group advances, the percentage rises. There is a 13% increase between young
teens and older teens, a 7% increase between older teens and young adults, and a 5%
increase between young adults and older adults. This pattern highlights the gradual but
consistent dependence on smartphones as people transition from adolescence into
adulthood.
o Climax: The age group with the highest daily smartphone usage is 22–25 years, where 90%
of individuals rely on their smartphones every day. This group represents young adults, who
are often navigating college life, early careers, and adult responsibilities. Their high
smartphone usage can be attributed to increased reliance on digital resources for both
personal and professional activities—social media, messaging apps, entertainment, and
online learning platforms.
O Falling Action: While the rise in smartphone usage offers undeniable conveniences, it also
raises concerns. There are potential negative implications, such as digital literacy, which is
the increasing dependency on smartphones— which may lead to the development of digital
skills, but it may also result in over-reliance on technology, reducing face-to-face interaction
and critical thinking. Another potential implication is eye strain, poor sleep patterns, and
mental health issues like anxiety and depression. This is due to poor screen time
management. Your academic performance can also get affected due to the constant
distractions provided. Overuse could result in reduced productivity, particularly among
younger students.
OUTPUT :
The survey data reveals a consistent upward trend in smartphone adoption as age
increases. The primary findings include:
The Adolescent Surge: There is a significant 13% jump between the 13–15 and 16–
18 age groups, suggesting that entry into high school marks a major shift in digital
dependency.
Steady Growth: Usage continues to climb as students enter college (19–21 years),
showing a 7% increase.
The Digital Peak: The 22–25 age group shows the highest usage at 90%, as
smartphones become essential for professional networking, job searching, and
financial independence.
Introduction: In the modern era, smartphones have evolved from luxury items to daily
necessities. A 2023 survey of Indian teenagers highlights a sharp rise in digital engagement,
driven by affordable data, the surge of social media, and the shift toward digital education.
Rising Action: The data shows a steady climb in usage across age brackets. Starting at 65%
for young teens (13–15), the numbers jump significantly by 13% as they enter late
adolescence. This rise continues into the early twenties, reflecting a growing reliance on
digital tools for social connectivity and academic resources.
Climax: Usage peaks at 90% within the 22–25 age group. This stage represents the
"Digital Zenith," where young adults are almost entirely dependent on smartphones for
managing college, early career responsibilities, and personal administration.
Falling Action: However, this high saturation comes with a cost. The transition to near-
total digital immersion brings risks like reduced face-to-face interaction, "technostress," and
physical health issues like eye strain or disrupted sleep cycles due to excessive screen time.
Resolution: To ensure technology remains a tool for progress rather than a hindrance, it is
vital for young adults to practice digital mindfulness. Balancing online productivity with
offline well-being is the key to mastering the digital age without compromising mental and
physical health.