AI File
AI File
PRACTICAL FILE
SUBMITTED TO: KANCHAN CHOWDHARY
SUBMITTED BY: simar kumar
CLASS : 10
ROLL NO : 4
Artificial
Intelligence
ACKNOWLEDGEMENT
CERTIFICATE
Index
1. Python Programs
2. Applications of AI
3. Auto Draw
4. Word tune
5. AI Project cycle
6. Machine learning
7. Teachable Machine
11. Pixels
13. Evaluation
1. To print the following patterns using multiple print
commands
Input
print(‘*’)
print(‘**’)
print(‘***’)
print(‘****’)
print(‘*****’)
print(‘*****’)
print(‘****’)
print(‘***’)
print(‘**’)
print(‘*’)
Output
*
**
***
****
*****
*****
****
***
**
*
Output
35
3. To calculate Area of a triangle with Base and Height.
Input
a=input(‘Enter the base:’)
b=input(‘Enter the height:’)
c=½*a*b
print(‘Area of the triangle is’,c)
Output
Enter the base: 2
Enter the height: 2
Area of the triangle is 2
Input
a=input(‘Enter the marks scored in english:’)
b=input(‘Enter the marks scored in hindi:’)
c=input(‘Enter the marks scored in maths:’)
d=a+b+c/3
print(‘Average marks scored are’,d)
Output
Enter the marks scored in english: 47
Enter the marks scored in hindi: 47
Enter the marks scored in maths: 47
Average marks scored are 47
Input
list=[ ‘Arjun’, ‘Sonakshi’, ‘Vikram’, ‘Sandhya’, ‘Sonal’, ‘Isha’, ‘Kartik’]
print(list)
list.del[Vikram]
list.append[Jay]
list.remove[3]
print(list)
Output
[ ‘Arjun’, ‘Sonakshi’, ‘Vikram’, ‘Sandhya’, ‘Sonal’, ‘Isha’, ‘Kartik’]
[ ‘Arjun’, ‘Sonakshi’,‘Sonal’, ‘Isha’, ‘Kartik’, ‘Jay’]
Input
list num=[23,12,5,9,65,44]
print(len[list num])
print(list num[1,2,3])
print(list num[-2,-3,-4)]
Output
6
12,5,9
Input
list1=[ ‘Arjun’, ‘Sonakshi’, ‘Vikram’, ‘Sandhya’, ‘Sonal’, ‘Isha’, ‘Kartik’]
list2=[23,12,5,9,65,44]
list1.extend(list2)
print(list1)
Output
[ ‘Arjun’, ‘Sonakshi’, ‘Vikram’, ‘Sandhya’, ‘Sonal’, ‘Isha’, ‘Kartik’,23,12,5,9,65,44]
8.Write a program to calculate mean, median and mode using
Numpy
Input:
import numpy as np
import statistics
data = [1, 2, 2, 3, 4]
mean = np.mean(data)
median = np.median(data)
mode = statistics.mode(data)
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode))
Output:
Mean: 2.4
Median: 2.0
Mode: 2
9.Write a program to display line chart from (2,5) to (9,10).
Input
import matplotlib.pyplot as plt
x = [2,9]
y = [5,10]
plt.plot(x, y,marker='o')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Chart')
plt.show()
Output
10. Write a program to display a scatter chart for the following
points (2,5), (9,10),(8,3),(5,7),(6,18).
Input
import matplotlib.pyplot as plt
x = [2, 9, 8, 5, 6]
y = [5, 10, 3, 7, 18]
plt.scatter(x, y)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Scatter Chart')
plt.show()
Output
11. Read the csv file saved in your system and display 10
rows.
Input
CSV File(data.csv)
Name,Age,Grade
Alice,14,D
Bella,15,B
Charlie,13,A
David,14,C
Eva,17,,B
Frank,14,A
Grace,13,B
Hannah,15,A
Ivan,14,C
John,13,B
Python File
import pandas as pd
df = pd.read_csv('data.csv')
print(df.head(10))
Output
Name Age Grade
0 Alice 14 D
1 Bella 15 B
2 Charlie 13 A
3 David 14 C
4 Eva 17 B
5 Frank 14 A
6 Grace 13 B
7 Hannah 15 A
8 Ivan 14 C
9 John 13 B
Input
print(df.info())
Output
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 10 entries, 0 to 9
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Name 10 non-null object
1 Age 10 non-null int64
2 Grade 10 non-null object
dtypes: int64(1), object(2)
memory usage: 378.0+ bytes
13. Write a program to read an image and display using
Python
Input
Image(image.jpg)
import cv2
img = cv2.imread('image.jpg')
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output
import cv2
img = cv2.imread('image12.jpg')
print("Image shape:", img.shape)
Output
(1980,1450,9)
15. To print first 10 natural numbers.
Input
list=[1,2,3,4,5,6,7,8,9,10,11,1,2,13,14,15]
print(list)
Output
[1,2,3,4,5,6,7,8,9,10,11,1,2,13,14,15]
Application
The present area is considered as a golden period for artificial intelligence tools and a
wide range of applications in our daily life are based on AI.
Auto Draw
It is a web based tool developed by Google that uses machine
learning algorithms to help users create professional looking
drawings and sketches quickly and easily. It uses CV to recognize
what the user is drawing and suggests a more polished version of
it. The suggestions are displayed on the screen and the user can
choose one that matches their intended drawing.
Wordtune
The tool can learn from previous interactions and improve the
accuracy and relevance of suggestions overtime. It has six buttons
to enhance texts: Rewrite, Casual, Formal, Shorten, Expand and
Spices.
AI Project Cycle
Let us assume that a girl is a makeup artist and she has client who has
to get her makeup done for her birthday . But there are certain
problems and steps that are to be considered while doing the makeup.
To accomplish this task the makeup artist can follow the above 5 steps
mentioned to accomplish the task in a systematic manner.
Similarly, if we have to develop an AI project,we have to follow an
appropriate framework which can lead us towards the goal. This is
called the AI Project Cycle. The AI Project Cycle mainly has 5
stages:
Problem scooping :
Problem scoping involves identifying the underlying problem (Diving deep into the root
cause of the problem ).
In the example taken, The client has a dry and a sensitive skin , she needs glittery yet
simplistic look . Thus achieving this look is the main task .
Data Acquisition:
This stage is about acquiring data for the project.
In the example data acquisition involves:
Looking for some referral pics that the client might want to refer or the makeup artist
would look for the previously done makeup looks similar to the needs of the client .
Data exploration :
Modelling :
It involves making the model.
Doing makeup on the clients face is included in modelling
Evaluation
Testing the model is called evaluation.
If the client is satisfied the makeup look
Supervised Learning
In a supervised learning model, the dataset which is fed to the machine is labelled or
the dataset is known to the person who is training the machine.
Classification Regression
Unsupervised learning:
An unsupervised learning model works on an unlabelled dataset. This means that the
data which is fed to the machine is random.The unsupervised learning models are
used to identify relationships, patterns and trends out of the data which is fed into it.
For example: From random data of 1000 dog images and you wish to understand
some pattern out of it, you would feed this data into the unsupervised learning model
and would train the machine
on it.
Clustering: Refers to the unsupervised learning algorithm which can cluster the
unknown data according to the patterns or trends identified out of it.
Teachable Machine
It is developed by google that allows individuals to create machine learning models
without coding experience. It is mainly used for supervised learning. Users can train
their model using their own labelled dataset.
2. Prepare Data: Define the data points for the x-axis and y-axis.
4. Customize Plot: Add customization like line style, markers, colors, etc.
5. Add Titles and Labels: Include a title for the graph and labels for x and y
axes.
Output:
Scatter plot
It is used to visualize the relationship between 2 numerical variables. It displays data
points as individual dots on a 2D graph, with one variable represented on the x axis
and the other on y axis.
We use the plt.scatter() function to create a scatter plot.
Example code
y =[99, 86, 87, 88, 100, 86, 103, 87, 94, 78, 77, 85, 86]
plt.scatter(x, y, c ="blue"
plt.show()
Outcome:
Computer Vision Tasks
The various applications of Computer Vision are based on a certain number of tasks
which are performed to get certain information from the input image which can be
directly used for prediction. Tasks can be categorized on the basis of number of
objects as single object tasks and multiple object tasks.
Pixels
When a camera captures an image, it becomes a digital file made up of tiny dots
called pixels. All digitally generated images consist of pixels. It is the smallest unit of
information in a digital image.
Pixel art project
PiskelApp is an easy to use platform that allows you to unleash your creativity and
make cool pixel art designs.
Applications of NLP( Natural Language Processing)
Since Artificial Intelligence nowadays is becoming an integral part of our lives, its
applications are very commonly used by the majority of people in their daily lives. Here
are some of the applications of Natural Language Processing which are used in the
real-life scenario:
Evaluation
In machine learning, there are different evaluation techniques to assess the
performance of models. This helps understand how well a model is likely to perform on
new data. Idf a model is not properly evaluated during raining process, it may lead to 2
problems:
Overfitting : Overfitting occurs when the model becomes too complex and adopts
closely to the training data. The model essentially memorizes the training examples
but it struggles to generalize new data.
Perfect Fit : A perfect fit occurs when the model performs exceptionally well on both
the training and testing data. It means the model has learned the underlying patterns
accurately and generalizes well to new.