Skumar
Skumar
Diploma in Engineering
In
Date:-
NAME : Umang Kashyap
SEMESTER : 5TH
CLASS ROLL : 23/CSE-030 BOARD
ROLL NO : 511121822030
DEPARTMENT OF C.S.E ,
GOVT. POLYTECHNIC BHAGALPUR
GOVERNMENT POLYTECHNIC, BHAGALPUR
Affiliated to S.B.T.E, Bihar, Patna, Approved by AICTE New Delhi,
Recognized by DSTTE, Govt. of Bihar
Bonafide Certificate
Project Guide
Head of the Department
Amit Sir and Sandeep Sir Er. Sandeep Sir
ACKNOWLEDGENT
My sincere thanks to project guide Amit Sir for potentially explaining the
entire system and clarifying the queries at every stage of the project.
ÎU
CONTENTS :-
TABLE OF CONTENT
6. Basic Python 12
V
1.Introduction to Machine Learning
Mach me Learning:
concerns with developing computational theories of learning and building
learning machines. The goal of machine learning, closely coupled with the
goal ofAl, is to achieve a thorough understanding about the nature of learning
process (both human learning and other forms of learning), about the
computational aspects of learning behaviours, and to implant the learning
capability in computer systems. Machine learning has been recognized as
central to the success of Artificial Intelligence, and it has applications in
various areas of science, engineering and society.
Learning?
Learning is a phenomenon and process which has manifestations of various
aspects. Roughly speaking, learning process includes (one or more ofJ the
following:
1.) Acquisition of new (symbolic) knowledge
2.) Development of cognitive skills through instruction and practice.
3.) Refinement and organization of knowledge into more effective
representations or more useful form
Discovery of new facts and theories through observation and experiment
The general effect of learning in a system is the improvement of the system's
capability to solve problems. It is hard to imagine a system capable of
learning cannot improve its probem-solving performance. A system with
learning capability should be able to do self-changing in order to perform
better in its future problem-solving.
We also note that learning cannot take place in isolation: We typically
learn something (knowledge K) to perform some tasks (T), tough some
experience E, and whether we have learned well or not will be judged by
some performance criteria P at the task T.
2
There are various forms of improvement of a system's problem-solving ability:
1.) To solve wider range of problems than before and perform generalization.
2.) To solve the same problem more effectively and give better quality.
The goal of ML, in simple words, is to understand the nature of(human and
other forms off learning, and to build learning capability in computers. To be
more specific, there are three aspects of the goals of ML.
3
human beings are capable of all the above. ML will produce smarter
computers
capable of all the above intelligent behaviour.
It is clear that central to our intelligence is our ability to learn. Thus a
thorough understanding of human learning process is crucial to understand
human intelligence. ML will gain us the insight into the underlying principles
of human learning and that may lead to the discovery of more effective
education techniques. It will also contribute to the design of machine learning
systems.
4
learning products usually provide some data pre-processing modules to
process the raw or unstructured data.
So, in order to apply the actual algorithm to the data, we need to have that
complete unstructured data into a structured and shaped data for which a
process of pre-massaging is required, through which the data is passed.
Finally, we get a candidate copy of data which could be processes through
the algorithm to get the actual golden copy.
After the data is pre-processed, we get some good structured data, and this
data is now an input for machine learning. But is this a one-time job? Of
course not, the process has to be iterative, and it has to be iterative until the
data is available. In machine learning the major chunk of time is spent in this
process. That is, working on the data to make it structured, clean, ready and
available. Once the data is available, the algorithms could be applied to the
data. Not only pre-processing tools, but the machine learning products also
offer a large number of machine learning algorithms as well. The result of
the algorithm applied data is a model, but now the question is whether this is
the final model we needed.
No, it is the candidate model that we got. Candidate model means the first
most appropriate model that we get, but still it needs to be massaged.
But do we get only one candidate model? Of course not, since this is an
iterative process, we do not actually know what the best candidate model is,
until we again and again produce several candidate models through the
iterative process. We do it until we get the model that is good enough to be
deployed. Once the model is deployed, applications start making use of it, so
there is iteration at small levels and at the largest level as well.
We need to repeat the entire process again and again and re-create the model
at regular intervals. The reason again for this process is very simple, it's
5
because the scenarios and factors change and we need to have our model up
to date and real all the time. This could eventually also mean to process new
data or applying new algorithms altogether.
6
"Supervised learning is a machine learning technique whereby the algorithm
is first presented with training data which consists of examples which include
both the inputs and the desired outputs; thus, enabling it to learn a function.
The learner should then be able to generalize from the presented data to
unseen examples." By Tom M. Mitchel
Types of Learning
Reinforcement
Learning
O lassification Clustering
Regression Association
DimëñÎsiÖ”rÏàlÏiy
Reduction
8
Machine learning comes in many different flavours, depending on the
algorithm and its objectives. You can divide machine learning algorithms into
three main groups based on their purpose:
1.) Supervised Learning Algorithms
2.) Unsupervised Learning Algorithms
3.) Reinforcement Learning Algorithms
Supervised Learning Algorithms: Supervised learning is where you have
input variables (x) and an output variable (Y) and you use an algorithm to
learn the mapping function from the input to the output.
Y=F(X)
The goal is to approximate the mapping function so well that when you have
new input data (x) that you can predict the output variables (Y) for that data.
We know the correct answers, the algorithm iteratively makes predictions on
the training data and is corrected by the teacher. Learning stops when
Supervised learning problems can be further grouped into regression and
classification problems.
Classification: A classification problem is when the output variable is a
category, such as "red" or "blue" or "disease" and "no disease". Regression:
A regression problem is when the output variable is a real(continues) value,
such as "dollars" or "weight".
Regression: A regression problem is when the output variable is a
real(continues) value, such as "dollars" or "weight".
Unsupervised Learning Algorithms: Unsupervised learning is where you
only have input data (X) and no corresponding output variables. The goal for
unsupervised learning is to model the underlying structure or distribution in
the data in order to learn more about the data.
5. Flow Chart
10
11
6. Basic Pvthon
Python is a widely used high-level, general-purpose, interpreted, dynamic
programming language. Its design philosophy emphasizes code readability,
and its syntax allows programmers to express concepts in fewer lines of code
than would be possible in languages such as C** or Java. The language
provides constructs intended to enable clear programs on both a small and large
scale. Python supports multiple programming paradigms, including object-
oriented, imperative and functional programming or procedural styles. It
features a dynamic type system and automatic memory management and has
a large and comprehensive standard library. Python interpreters are available
for installation on many operating systems, allowing Python code execution on
a wide variety of systems.
Historv
Python was conceived in the late 1980s, and its implementation was started
in December 1989 by Guido van Rossum at CWI in the Netherlands as a
successor to the ABC language (itself inspired by SETL) capable of
exception handling and interfacing with the Amoeba operating system. Van
Rossum is Python's principal author, and his continuing central role in deciding
the direction of Python is reflected in the title given to him by the
Python community, benevolent dictator for life (BDFL)
Examples 1:
Input: numl = 5, num2 = 3
Output : 8
Input : num1 = 13, num2 = 6
Output : 19
Input : P = 10000
R 5
T 5
Output :2500.0
We need to find simple interest on Rs.
10,000 at the rate of 5% for 5 units
of time.
Examples 3:
12
a = 7 b
3
print(max(a, b))
7. Conditional Statement, Strings, List, Tuples, indexing and
Slicing.
Python Conditions and If statements
Equals: a == b
Not Equals: a != b
Less than: a < b
Less than or equal to: a b
Greater than: a > b
Greater than or equal to: a >= b
Example
If statement:
a= 33 b= 200 if b>a:
print("b is greater than a")
Elif
13
The elif keyword is Python's way of saying "if the previous conditions were
not true, then try this condition".
Example
a= 33
b= 33
if b>a:
printf"b is greater than a")
elif a == b:
print("a and b are equal")
Else
The else keyword catches anything which isn't caught by the preceding
conditions.
14
Strings in python are surrounded by either single quotation marks, or double
quotation marks. 'hello' is the same as "hello". You can display a string literal
with the print() function:
Example
print("Hello")
print('Hello')
List
Lists are used to store multiple items in a single variable. Lists are one of 4
built-in data types in Python used to store collections of data, the other 3 are
Tu p_le, Set, and Dictiryona, all with different qualities and usage.
Tuple
Tuples are used to store multiple items in a single variable. Tuple is one of 4
built-in data types in Python used to store collections of data, the other 3 are
List, Set, and Dictiryona, all with different qualities and usage. A tuple is a
collection which is ordered and unchangeable. Tuples are written with round
brackets.
Example
Create a Tuple:
thistuple = ("apple", "banana", "cherry") print(thistuple)
15
Pandas
Pandas is a Python library used for working with data sets. It has functions
for analyzing, cleaning, exploring, and manipulating data. The name
"Pandas" has a reference to both "Panel Data", and "Python Data Analysis"
and was created by Wes McKinney in 2008.
Example
Load the CSV into a DataFrame:
import pandas as pd
df = pd.read csv('data.csv')
print(df.to string())
Matplotlib
Example
Draw a line in a diagram from position (0, 0) to position (6, 250):
import matplotlib.pyplot as plt
import numpy as np
plt.plot(xpoints, ypoints)
plt.show()
16
Result:
Scikit-learn
Scikit-learn has emerged as a powerful and user-friendly Python library. Its
simplicity and versatility make it a better choice for both beginners and
seasoned data scientists to build and implement machine learning models. In
this article, we will explore about Sklearn.
# load the iris dataset as an example
X = iris.data y = iris.target
17
# X and y are numpy arrays print(“\nType
of X i s: “ , type(X) )
First 5 rows of X:
[[ 5.1 3.5 1.4 0.21
[ 4.9 3. 1.4 0.21
[ 4.7 3.2 1.3 0.21
[ 4.6 3.1 1.5 0.21
[ 5. 3.6 1.4 0.211
This is the original paper on scikit-learn, the most widely used library for
traditional machine learning in Python. The paper describes its design,
functionality, and algorithms.
This paper discusses the integration of Python tools for data science,
including Pandas, NumPy, and scikit-learn, and how they can be used
effectively in command-line environments for machine learning.
19
This survey paper provides a detailed exploration of the various libraries
available in Python for machine learning, including an in-depth discussion of
scikit-learn, Keras, TensorFlow, and PyTorch.
20