Deep Learning Based Deforestation Classification

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

Domain: Artificial Intelligence

Technology: Python

DEEP LEARNING BASED DEFORESTATION CLASSIFICATION

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

ABSTRACT
Human-induced deforestation has a major impact on forest ecosystems and therefore its
detection and analysis methods should be improved. Where, this type of detection or
classification helps us to degrade the deforestations in future. In this project we are mainly
focusing on the problem of deforestation, performing the classification of deforestation and
the healthy forests with the help of deep learning model. CNN is the algorithm that which are
been using here for the classification process. We are preparing a dataset which is trained
using the algorithm and classification will be performed in testing.

Keywords: Deforestation, Deep learning, CNN

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

CHAPTER 1
INTRODUCTION
Deforestation, clearance, clear cutting, or clearing is the removal of a forest or stand of trees
from land that is then converted to non-forest use. Deforestation can involve conversion of
forest land to farms, ranches, or urban use. The most concentrated deforestation occurs in
tropical rainforests. About 31% of Earth's land surface is covered by forests. Between 15
million to 18 million hectares of forest, an area the size of Belgium, are destroyed every year,
on average 2,400 trees are cut down each minute.

The Food and Agriculture Organization of the United Nations defines deforestation as the
conversion of forest to other land uses (regardless of whether it is human-induced).
"Deforestation" and "forest area net change" are not the same: the latter is the sum of all
forest losses (deforestation) and all forest gains (forest expansion) in a given period. Net
change, therefore, can be positive or negative, depending on whether gains exceed losses, or
vice versa.

The removal of trees without sufficient reforestation has resulted in habitat damage,
biodiversity loss, and aridity. Deforestation causes extinction, changes to climatic conditions,
desertification, and displacement of populations, as observed by current conditions and in the
past through the fossil record. Deforestation also has adverse impacts on bio sequestration of
atmospheric carbon dioxide, increasing negative feedback cycles contributing to global
warming. Global warming also puts increased pressure on communities who seek food
security by clearing forests for agricultural use and reducing arable land more generally.
Deforested regions typically incur significant other environmental effects such as adverse soil
erosion and degradation into wasteland.

The resilience of human food systems and their capacity to adapt to future change depends on
that very biodiversity – including dry land-adapted shrub and tree species that help combat
desertification, forest-dwelling insects, bats and bird species that pollinate crops, trees with
extensive root systems in mountain ecosystems that prevent soil erosion, and mangrove
species that provide resilience against flooding in coastal areas. With climate change
exacerbating the risks to food systems, the role of forests in capturing and storing carbon and
mitigating climate change is of ever-increasing importance for the agricultural sector.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Causes:
According to the United Nations Framework Convention on Climate Change (UNFCCC)
secretariat, the overwhelming direct cause of deforestation is agriculture. Subsistence farming
is responsible for 48% of deforestation; commercial agriculture is responsible for 32%;
logging is responsible for 14%, and fuel wood removals make up 5%.

Experts do not agree on whether industrial logging is an important contributor to global


deforestation. Some argue that poor people are more likely to clear forest because they have
no alternatives, others that the poor lack the ability to pay for the materials and labour needed
to clear forest. One study found that population increases due to high fertility rates were a
primary driver of tropical deforestation in only 8% of cases.

Other causes of contemporary deforestation may include corruption of government


institutions, the inequitable distribution of wealth and power, population growth and
overpopulation, and urbanization. Globalization is often viewed as another root cause of
deforestation, though there are cases in which the impacts of globalization (new flows of
labor, capital, commodities, and ideas) have promoted localized forest recovery.

Another cause of deforestation is climate change. 23% of tree cover losses result from
wildfires and climate change increase their frequency and power. The rising temperatures
cause massive wildfires especially in the Boreal forests. One possible effect is the change of
the forest composition.

In 2000 the United Nations Food and Agriculture Organization (FAO) found that "the role of
population dynamics in a local setting may vary from decisive to negligible", and that
deforestation can result from "a combination of population pressure and stagnating economic,
social and technological conditions".

The degradation of forest ecosystems has also been traced to economic incentives that make
forest conversion appear more profitable than forest conservation. Many important forest
functions have no markets, and hence, no economic value that is readily apparent to the
forests' owners or the communities that rely on forests for their well-being. From the

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

perspective of the developing world, the benefits of forest as carbon sinks or biodiversity
reserves go primarily to richer developed nations and there is insufficient compensation for
these services. Developing countries feel that some countries in the developed world, such as
the United States of America, cut down their forests centuries ago and benefited
economically from this deforestation, and that it is hypocritical to deny developing countries
the same opportunities, i.e. that the poor should not have to bear the cost of preservation
when the rich created the problem.

Some commentators have noted a shift in the drivers of deforestation over the past 30 years.
Whereas deforestation was primarily driven by subsistence activities and government-
sponsored development projects like transmigration in countries like Indonesia and
colonization in Latin America, India, Java, and so on, during the late 19th century and the
earlier half of the 20th century, by the 1990s the majority of deforestation was caused by
industrial factors, including extractive industries, large-scale cattle ranching, and extensive
agriculture. Since 2001, commodity-driven deforestation, which is more likely to be
permanent, has accounted for about a quarter of all forest disturbance, and this loss has been
concentrated in South America and Southeast Asia.

Environmental effects
Atmospheric
Deforestation is a contributor to global warming, and is often cited as one of the major causes
of the enhanced greenhouse effect. Tropical deforestation is responsible for approximately
20% of world greenhouse gas emissions. According to the Intergovernmental Panel on
Climate Change deforestation, mainly in tropical areas, could account for up to one-third of
total anthropogenic carbon dioxide emissions. But recent calculations suggest that carbon
dioxide emissions from deforestation and forest degradation (excluding peatland emissions)
contribute about 12% of total anthropogenic carbon dioxide emissions with a range from 6%
to 17%. Deforestation causes carbon dioxide to linger in the atmosphere. As carbon dioxide
accrues, it produces a layer in the atmosphere that traps radiation from the sun. The radiation
converts to heat which causes global warming, which is better known as the greenhouse
effect.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Plants remove carbon in the form of carbon dioxide from the atmosphere during the process
of photosynthesis, but release some carbon dioxide back into the atmosphere during normal
respiration. Only when actively growing can a tree or forest remove carbon, by storing it in
plant tissues. Both the decay and the burning of wood release much of this stored carbon back
into the atmosphere. Although an accumulation of wood is generally necessary for carbon
sequestration, in some forests the network of symbiotic fungi that surround the trees' roots
can store a significant amount of carbon, storing it underground even if the tree which
supplied it dies and decays, or is harvested and burned. Another way carbon can be
sequestered by forests is for the wood to be harvested and turned into long-lived products,
with new young trees replacing them. Deforestation may also cause carbon stores held in soil
to be released. Forests can be either sinks or sources depending upon environmental
circumstances. Mature forests alternate between being net sinks and net sources of carbon
dioxide.

Hydrological
The water cycle is also affected by deforestation. Trees extract groundwater through their
roots and release it into the atmosphere. When part of a forest is removed, the trees no longer
transpire this water, resulting in a much drier climate. Deforestation reduces the content of
water in the soil and groundwater as well as atmospheric moisture. The dry soil leads to
lower water intake for the trees to extract. Deforestation reduces soil cohesion, so that
erosion, flooding and landslides ensue.

Shrinking forest cover lessens the landscape's capacity to intercept, retain and transpire
precipitation. Instead of trapping precipitation, which then percolates to groundwater
systems, deforested areas become sources of surface water runoff, which moves much faster
than subsurface flows. Forests return most of the water that falls as precipitation to the
atmosphere by transpiration. In contrast, when an area is deforested, almost all precipitation
is lost as run-off. That quicker transport of surface water can translate into flash flooding and
more localized floods than would occur with the forest cover. Deforestation also contributes
to decreased evapotranspiration, which lessens atmospheric moisture which in some cases
affects precipitation levels downwind from the deforested area, as water is not recycled to
downwind forests, but is lost in runoff and returns directly to the oceans. According to one

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

study, in deforested north and northwest China, the average annual precipitation decreased by
one third between the 1950s and the 1980s.

Trees, and plants in general, affect the water cycle significantly:

 Their canopies intercept a proportion of precipitation, which is then evaporated back


to the atmosphere (canopy interception)
 Their litter, stems and trunks slow down surface runoff
 Their roots create macropores – large conduits – in the soil that increase infiltration of
water
 They contribute to terrestrial evaporation and reduce soil moisture via transpiration;
 Their litter and other organic residue change soil properties that affect the capacity of
soil to store water.
 Their leaves control the humidity of the atmosphere by transpiring. 99% of the water
absorbed by the roots moves up to the leaves and is transpired.
As a result, the presence or absence of trees can change the quantity of water on the surface,
in the soil or groundwater, or in the atmosphere. This in turn changes erosion rates and the
availability of water for either ecosystem functions or human services. Deforestation on
lowland plains moves cloud formation and rainfall to higher elevations.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

CHAPTER 2
LITERATURE REVIEW

[1] Banskota, Kayastha, Falkowski, Wulder, Froese and White: Unique among Earth
observation programs, the Landsat program has provided continuous earth observation data
for the past 41 years. Landsat data are systematically collected and archived following a global
acquisition strategy. With the successful launch of Landsat-8, the continuity of measures at
scales of particular relevance to management and scientific activities is ensured in the short
term. In particular, forest monitoring benefits from LTS, whereby a baseline of conditions can
be interrogated for both abrupt and gradual changes and attributed to different drivers. Such
benefits are enabled by data availability, analysis-ready image products, increased computing
power and storage, as well as sophisticated image processing approaches. In this review, we
present the status of remote sensing of forests and forest dynamics using LTS, including issues
related to the sensors, data availability, data preprocessing, variables used in LTS, analysis
approaches, and validation issues.
Summary: With the successful launch of Landsat-8, the continuity of measures at scales of
particular relevance to management and scientific activities is ensured in the short term Such
benefits are enabled by data availability, analysis-ready image products, increased computing
power and storage, as well as sophisticated image processing approaches. In this review, we
present the status of remote sensing of forests and forest dynamics using LTS, including issues
related to the sensors, data availability, data preprocessing, variables used in LTS, analysis
approaches, and validation issues.

[2] Liu, Zhan. Q, Gao. S, Yang: There has been a growing concern for the urbanization
induced local warming, and the underlying mechanism between urban thermal environment
and the driving landscape factors. However, relatively little research has simultaneously
considered issues of spatial non-stationarity and seasonal variability, which are both intrinsic
properties of the environmental system. In this study, the newly proposed multi-scale

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

geographically weighted regression (MGWR) is employed to investigate the seasonal


variations of the spatial non-stationary associations between land surface temperature (LST)
and urban landscape indicators under different operating scales. Specifically, by taking Wuhan
as a case study, Landsat-8 images were used to achieve the LSTs in summer, winter and the
transitional season, respectively. Landscape composition indicators including fractional
vegetation cover (FVC), albedo and water percentage (WP) and urban morphology indicators
covering building density (BD), building height (BH) and building volume density (BVD)
were employed as potential landscape drivers of LST.
Summary: In this study, the newly proposed multi-scale geographically weighted regression
(MGWR) is employed to investigate the seasonal variations of the spatial non-stationary
associations between land surface temperature (LST) and urban landscape indicators under
different operating scales. Specifically, by taking Wuhan as a case study, Landsat-8 images
were used to achieve the LSTs in summer, winter and the transitional season, respectively.
Landscape composition indicators including fractional vegetation cover (FVC), albedo and
water percentage (WP) and urban morphology indicators covering building density (BD),
building height (BH) and building volume density (BVD) were employed as potential
landscape drivers of LST.

[3] Wang. C, Myint S.W, Hutchins. M: Myanmar is rich in forest resources. Deforestation
and forest degradation in Myanmar have recently attracted much attention worldwide. This
Chapter explores spatio-temporal patterns of deforestation and forest degradation, and assesses
forest carbon release in Myanmar between 2000 and 2010 using Moderate Resolution Imaging
Spectroradiometer (MODIS) satellite imagery. Results suggest that the total deforestation area
during the study period was 82,426 km2 with an annual deforestation rate of 2.07%. The total
forest degradation area was 85.5 km2 with an annual degradation rate of 0.002%. Evergreen
needle leaf forests had the highest degradation rate, and mixed forests had the largest
degradation area. The total forest carbon release was 18.5 million tons with an annual rate of
0.45%. Mixed forests released the largest amount of carbon, and evergreen needle leaf forests
had the highest carbon release rate. No carbon sequestration has been found for any type of
forest in this study.
Summary: Deforestation and forest degradation in Myanmar have recently attracted much
attention worldwide. This Chapter explores spatio-temporal patterns of deforestation and
forest degradation, and assesses forest carbon release in Myanmar between 2000 and 2010

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

using Moderate Resolution Imaging Spectroradiometer (MODIS) satellite imagery. Results


suggest that the total deforestation area during the study period was 82,426 km2 with an
annual deforestation rate of 2.07%.

[4] Dalponte. M, Bruzzone. L, Gianelle. D: In this paper, we propose an analysis on the


joint effect of hyperspectral and light detection and ranging (LIDAR) data for the
classification of complex forest areas. In greater detail, we present: 1) an advanced system for
the joint use of hyperspectral and LIDAR data in complex classification problems; 2) an
investigation on the effectiveness of the very promising support vector machines (SVMs) and
Gaussian maximum likelihood with leave-one-out-covariance algorithm classifiers for the
analysis of complex forest scenarios characterized from a high number of species in a
multisource framework; and 3) an analysis on the effectiveness of different LIDAR returns
and channels (elevation and intensity) for increasing the classification accuracy obtained with
hyperspectral images, particularly in relation to the discrimination of very similar classes.
Summary: In greater detail, we present: 1) an advanced system for the joint use of
hyperspectral and LIDAR data in complex classification problems; 2) an investigation on the
effectiveness of the very promising support vector machines (SVMs) and Gaussian maximum
likelihood with leave-one-out-covariance algorithm classifiers for the analysis of complex
forest scenarios characterized from a high number of species in a multisource framework; and
3) an analysis on the effectiveness of different LIDAR returns and channels (elevation and
intensity) for increasing the classification accuracy obtained with hyperspectral images,
particularly in relation to the discrimination of very similar classes.

[5] Frohn. R, McGwire. K, Dale. V, Estes. J: The effectiveness of an integrated socio-


economic and ecological simulation model for estimating patterns and rates of deforestation in
Rondônia, Brazil is evaluated using Landsat data and landscape pattern metrics. The Percent
Cleared, Contagion, and Fractal Dimension of image classifications are compared to those
determined from model outputs. Results indicate that rates and spatial patterns of deforestation
are similar between model outputs and Landsat image analysis. Differences in clearing
patterns between the model and Landsat data are due in part to topography, localized farming

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

obstacles and the patchiness of clearings. The effects of varying spatial resolution on the
metrics is also examined.
Summary: The effectiveness of an integrated socio-economic and ecological simulation
model for estimating patterns and rates of deforestation in Rondônia, Brazil is evaluated using
Landsat data and landscape pattern metrics. The Percent Cleared, Contagion, and Fractal
Dimension of image classifications are compared to those determined from model outputs.
Results indicate that rates and spatial patterns of deforestation are similar between model
outputs and Landsat image analysis. Differences in clearing patterns between the model and
Landsat data are due in part to topography, localized farming obstacles and the patchiness of
clearings.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

CHAPTER 3
EXISTING METHOD

This model emphasizes an existing method that which is designed using the ANN algorithm
of deep learning. As the deforestation has a major impact on forest ecosystems and therefore
its detection and analysis methods should be improved. Where, the classification of healthy
forest and the areas of deforestation is important to recognize for which ANN is used that
which can classify the deforestation area and healthy forest area.

Disadvantages:

 Less feature compatibility


 Fixed size input and output
 Low accuracy

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

CHAPTER 4
PROPOSED METHOD

In our proposed method we are performing the deforestation classification using convolution
neural network (CNN) of deep learning. Human-induced deforestation has a major impact on
forest ecosystems and therefore its detection and analysis methods should be improved.
Where, this type of detection or classification helps us to degrade the deforestations in future.
In this project we are mainly focusing on the problem of deforestation, performing the
classification of deforestation and the healthy forests with the help of deep learning model.
CNN is the algorithm that which are been using here for the classification process. We are
preparing a dataset which is trained using the algorithm and classification will be performed
in testing. The block diagram of the proposed system is shown in below figure.

Fig. Block diagram of proposed method

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Advantages:
 Accurate classification
 Less complexity
 High performance

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

APPLICATIONS

 Image processing
 Picture retrieval
 Classifications

SYSTEM SPECIFICATIONS
HARDWARE & SOFTWARE REQUIREMENTS

H/W Configuration:
• Processor : I3/Intel Processor
• Hard Disk : 160GB
• RAM : 8Gb

S/W Configuration:
• Operating System : Windows 7/8/10 .

• Server side Script : HTML, CSS & JS.

• IDE : Pycharm.

• Libraries Used : Numpy, IO, OS, Flask, keras.

• Technology : Python 3.6+.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

ARCHITECTURE

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

SOFTWARE INSTALLATION FOR MACHINE LEARNING


PROJECTS
Installing Python:

1. To download and install Python visit the official website of


Python https://www.python.org/downloads/ and choose your version.

2. Once the download is complete, run the exe for install Python. Now click on Install Now.
3.  You can see Python installing at this point.
4. When it finishes, you can see a screen that says the Setup was successful. Now click on
"Close".

Installing PyCharm:

1. To download PyCharm visit the


website https://www.jetbrains.com/pycharm/download/ and Click the
"DOWNLOAD" link under the Community Section.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

2. Once the download is complete, run the exe for install PyCharm. The setup wizard
should have started. Click “Next”.
3. On the next screen, Change the installation path if required. Click “Next”.
4. On the next screen, you can create a desktop shortcut if you want and click on “Next”.
5. Choose the start menu folder. Keep selected Jet Brains and click on “Install”.
6. Wait for the installation to finish.
7. Once installation finished, you should receive a message screen that PyCharm is
installed. If you want to go ahead and run it, click the “Run PyCharm Community
Edition” box first and click “Finish”.
8.  After you click on "Finish," the Following screen will appear.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

9. You need to install some packages to execute your project in a proper way.

10. Open the command prompt/ anaconda prompt or terminal as administrator.

11. The prompt will get open, with specified path, type “pip install package name” which
you want to install (like numpy, pandas, seaborn, scikit-learn, matplotlib.pyplot)

Ex: pip install numpy

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

MODULES
System
User
1. System:
1.1 Create Dataset:

The dataset containing images are taken which are to be classified is split into training and
testing dataset with the test size of 30-20%.

1.2 Pre-processing:

Resizing and reshaping the images into appropriate format to train our model.

1.3Training:

Use the pre-processed training dataset is used to train our model using CNN algorithm.

2. User:

2.1 Register

The user needs to register and the data stored in MySQL database.

2.2 Login

A registered user can login using the valid credentials to the website to use a application.

2.1 About-Project

In this application, we have successfully created an application which takes to classify the
given images.

2.2 Upload Image

The user has to upload an image which needs to be classified.

2.3 Prediction

The results of our model is display of classified as a healthy forest or deforestration.

2.6 Logout

Once the classification is over, the user can logout of the application.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

ALGORITHM

1. Convolutional Neural Network

Step1: convolutional operation

The first building block in our plan of attack is convolution operation. In this step, we will
touch on feature detectors, which basically serve as the neural network's filters. We will also
discuss feature maps, learning the parameters of such maps, how patterns are detected, the
layers of detection, and how the findings are mapped out.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Step (1b): ReLU Layer

The second part of this step will involve the Rectified Linear Unit or Relook. We will cover
Relook layers and explore how linearity functions in the context of Convolutional Neural
Networks.

Not necessary for understanding CNN's, but there's no harm in a quick lesson to improve
your skills.

Step 2: Pooling Layer

In this part, we'll cover pooling and will get to understand exactly how it generally works.
Our nexus here, however, will be a specific type of pooling; max pooling. We'll cover various
approaches, though, including mean (or sum) pooling. This part will end with a
demonstration made using a visual interactive tool that will definitely sort the whole concept
out for you.

Step 3: Flattening

This will be a brief breakdown of the flattening process and how we move from pooled to
flattened layers when working with Convolutional Neural Networks.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Step 4: Full Connection

In this part, everything that we covered throughout the section will be merged together. By
learning this, you'll get to envision a fuller picture of how Convolutional Neural Networks
operate and how the "neurons" that are finally produced learn the classification of images.

Summary
In the end, we'll wrap everything up and give a quick recap of the concept covered in the
section. If you feel like it will do you any benefit (and it probably will), you should check out
the extra tutorial in which Soft ax and Cross-Entropy are covered. It's not mandatory for the
course, but you will likely come across these concepts when working with Convolutional
Neural Networks and it will do you a lot of good to be familiar with them.

Fig 2. CNN Architecture

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

STEPS FOR EXECUTING THE PROJECTS

1. Install the required packages

2. Defining the custom model.

3. Loading the dataset.

4. Pre-Processing the dataset.

5. Training the custom model.

6. Training the pre-trained model with our own dataset using CNN.

7. Performing classification.

8. Create a Flask based User Interface.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

SYSTEM DESIGN

UML Diagrams

UML stands for Unified Modeling Language. UML is a standardized general-purpose


modeling language in the field of object-oriented software engineering. The standard is
managed, and was created by, the Object Management Group.
The goal is for UML to become a common language for creating models of object
oriented computer software. In its current form UML is comprised of two major components:
a Meta-model and a notation. In the future, some form of method or process may also be
added to; or associated with, UML.
The Unified Modeling Language is a standard language for specifying, Visualization,
Constructing and documenting the artifacts of software system, as well as for business
modeling and other non-software systems.
The UML represents a collection of best engineering practices that have proven
successful insists the modeling of large and complex systems.
The UML is a very important part of developing objects oriented software and the
software development process. The UML uses mostly graphical notations to express the
design of software projects.

Goals:
The Primary goals in the design of the UML are as follows:
1. Provide users a ready-to-use, expressive visual modeling Language so that they can
develop and exchange meaningful models.
2. Provide extendibility and specialization mechanisms to extend the core concepts.
3. Be independent of particular programming languages and development process.
4. Provide a formal basis for understanding the modeling language.
5. Encourage the growth of OO tools market.
6. Support higher level development concepts such as collaborations, frameworks,
patterns and components.
7. Integrate best practices.
Use Case Diagram:

A use case diagram in the Unified Modeling Language (UML) is a type of behavioral

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

diagram defined by and created from a Use-case analysis. Its purpose is to present a
graphical overview of the functionality provided by a system in terms of actors, their
goals (represented as use cases), and any dependencies between those use cases. The
main purpose of a use case diagram is to show what system functions are performed
for which actor. Roles of the actors in the system can be depicted.

Take Dataset Register

Login
Preprocessing

User
System

About project
Training

Classification

Class Diagram:

In software engineering, a class diagram in the Unified Modeling Language (UML) is a type
of static structure diagram that describes the structure of a system by showing the system's
classes, their attributes, operations (or methods), and the relationships among the classes. It
explains which class contains information.

User
System email
name : type = initval password

Take dataset() Register()


Preprocessing() Login()
Training() About Project()
Classification()
Logout()

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Sequence Diagram:

A sequence diagram in Unified Modeling Language (UML) is a kind of interaction


diagram that shows how processes operate with one another and in what order. It is a
construct of a Message Sequence Chart. Sequence diagrams are sometimes called event
diagrams, event scenarios, and time diagrams.

System User

Take Dataset

Register

Preprocessing

Login

Training

About Project

Classification

Logout

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Collaboration Diagram:

In collaboration diagram the method call sequence is indicated by some numbering technique
as shown below. The number indicates how the methods are called one after another. We
have taken the same order management system to describe the collaboration diagram. The
method calls are similar to that of a sequence diagram. But the difference is that the sequence
diagram does not describe the object organization whereas the collaboration diagram shows
the object organization.

1: Take Dataset
3: Preprocessing
5: Training

System User

2: Register
4: Login
6: About Project
7: Classification
8: Logout

Deployment diagram

Deployment diagram represents the deployment view of a system. It is related to the


component diagram. Because the components are deployed using the deployment diagrams.
A deployment diagram consists of nodes. Nodes are nothing but physical hardware’s used to
deploy the application.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Activity Diagram:

Activity diagrams are graphical representations of workflows of stepwise activities and


actions with support for choice, iteration and concurrency. In the Unified Modeling
Language, activity diagrams can be used to describe the business and operational step-by-step
workflows of components in a system. An activity diagram shows the overall flow of control.

User

System

Register

Take Dataset Login

About Project

Preprocessing

Classification

Training Logout

Component diagram:

A component diagram, also known as a UML component diagram, describes the organization


and wiring of the physical components in a system. Component diagrams are often drawn to
help model implementation details and double-check that every aspect of the system's
required functions is covered by planned development.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

ER Diagram:

An Entity–relationship model (ER model) describes the structure of a database with the help
of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER model is
a design or blueprint of a database that can later be implemented as a database. The main
components of E-R model are: entity set and relationship set.

An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes. In terms of DBMS, an entity is a table or
attribute of a table in database, so by showing relationship among tables and their attributes,
ER diagram shows the complete logical structure of a database. Let’s have a look at a simple
ER diagram to understand this concept.

DFD Diagram:

A Data Flow Diagram (DFD) is a traditional way to visualize the information flows within a
system. A neat and clear DFD can depict a good amount of the system requirements
graphically. It can be manual, automated, or a combination of both. It shows how information
enters and leaves the system, what changes the information and where information is stored.
The purpose of a DFD is to show the scope and boundaries of a system as a whole. It may be

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

used as a communications tool between a systems analyst and any person who plays a part in
the system that acts as the starting point for redesigning a system.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

INTRODUCTION TO PYTHON
 Python
What is a Script?
Up to this point, I have concentrated on the interactive programming capability of Python. 
This is a very useful capability that allows you to type in a program and to have it executed
immediately in an interactive mode

Scripts are reusable


Basically, a script is a text file containing the statements that comprise a Python program. 
Once you have created the script, you can execute it over and over without having to retype it
each time.

Scripts are editable


Perhaps, more importantly, you can make different versions of the script by modifying the
statements from one file to the next using a text editor.  Then you can execute each of the
individual versions.  In this way, it is easy to create different programs with a minimum
amount of typing.

You will need a text editor


Just about any text editor will suffice for creating Python script files.
You can use Microsoft Notepad, Microsoft WordPad, Microsoft Word, or just about any
word processor if you want to.

Difference between a script and a program

Script:

Scripts are distinct from the core code of the application, which is usually written in a
different language, and are often created or at least modified by the end-user. Scripts are
often interpreted from source code or byte code, whereas the applications they control are
traditionally compiled to native machine code.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Program:

The program has an executable form that the computer can use directly to execute the
instructions.

The same program in its human-readable source code form, from which executable programs
are derived (e.g., compiled)

Python

What is Python? Chances you are asking yourself this. You may have found this book
because you want to learn to program but don’t know anything about programming
languages. Or you may have heard of programming languages like C, C++, C#, or Java and
want to know what Python is and how it compares to “big name” languages. Hopefully I can
explain it for you.

Python concepts

If you’re not interested in the hows and whys of Python, feel free to skip to the next chapter.
In this chapter I will try to explain to the reader why I think Python is one of the best
languages available and why it’s a great one to start programming with.

• Open source general-purpose language.

• Object Oriented, Procedural, Functional

• Easy to interface with C/ObjC/Java/Fortran

• Easy-is to interface with C++ (via SWIG)

• Great interactive environment

Python is a high-level, interpreted, interactive and object-oriented scripting language. Python


is designed to be highly readable. It uses English keywords frequently where as other
languages use punctuation, and it has fewer syntactical constructions than other languages.

 Python is Interpreted − Python is processed at runtime by the interpreter. You do not need
to compile your program before executing it. This is similar to PERL and PHP.
 Python is Interactive − you can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

 Python is Object-Oriented − Python supports Object-Oriented style or technique of


programming that encapsulates code within objects.
 Python is a Beginner's Language − Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from simple text
processing to WWW browsers to games.

History of Python

Python was developed by Guido van Possum in the late eighties and early nineties at the
National Research Institute for Mathematics and Computer Science in the Netherlands.

Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
Smalltalk, and UNIX shell and other scripting languages.

Python is copyrighted. Like Perl, Python source code is now available under the GNU
General Public License (GPL).

Python is now maintained by a core development team at the institute, although Guido van
Possum still holds a vital role in directing its progress.

Python Features

Python's features include −

 Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax.
This allows the student to pick up the language quickly.
 Easy-to-read − Python code is more clearly defined and visible to the eyes.
 Easy-to-maintain − Python's source code is fairly easy-to-maintain.
 A broad standard library − Python's bulk of the library is very portable and cross-platform
compatible on UNIX, Windows, and Macintosh.
 Interactive Mode − Python has support for an interactive mode which allows interactive
testing and debugging of snippets of code.
 Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
 Extendable − you can add low-level modules to the Python interpreter. These modules
enable programmers to add to or customize their tools to be more efficient.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

 Databases − Python provides interfaces to all major commercial databases.


 GUI Programming − Python supports GUI applications that can be created and ported to
many system calls, libraries and windows systems, such as Windows MFC, Macintosh, and
the X Window system of Unix.
 Scalable − Python provides a better structure and support for large programs than shell
scripting.
Apart from the above-mentioned features, Python has a big list of good features, few are
listed below −

 It supports functional and structured programming methods as well as OOP.


 It can be used as a scripting language or can be compiled to byte-code for building large
applications.
 It provides very high-level dynamic data types and supports dynamic type checking.
 IT supports automatic garbage collection.
 It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Dynamic vs. Static

Types Python is a dynamic-typed language. Many other languages are static typed, such as
C/C++ and Java. A static typed language requires the programmer to explicitly tell the
computer what type of “thing” each data value is.

For example, in C if you had a variable that was to contain the price of something, you
would have to declare the variable as a “float” type.

This tells the compiler that the only data that can be used for that variable must be a floating
point number, i.e. a number with a decimal point.

If any other data value was assigned to that variable, the compiler would give an error when
trying to compile the program.

Python, however, doesn’t require this. You simply give your variables names and assign
values to them. The interpreter takes care of keeping track of what kinds of objects your
program is using. This also means that you can change the size of the values as you develop
the program. Say you have another decimal number (a.k.a. a floating point number) you need
in your program.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

With a static typed language, you have to decide the memory size the variable can take when
you first initialize that variable. A double is a floating point value that can handle a much
larger number than a normal float (the actual memory sizes depend on the operating
environment).

If you declare a variable to be a float but later on assign a value that is too big to it, your
program will fail; you will have to go back and change that variable to be a double.

With Python, it doesn’t matter. You simply give it whatever number you want and Python
will take care of manipulating it as needed. It even works for derived values.

For example, say you are dividing two numbers. One is a floating point number and one is an
integer. Python realizes that it’s more accurate to keep track of decimals so it automatically
calculates the result as a floating point number

Variables

Variables are nothing but reserved memory locations to store values. This means that when
you create a variable you reserve some space in memory.
Based on the data type of a variable, the interpreter allocates memory and decides what can
be stored in the reserved memory. Therefore, by assigning different data types to variables,
you can store integers, decimals or characters in these variables.

Standard Data Types

The data stored in memory can be of many types. For example, a person's age is stored as a
numeric value and his or her address is stored as alphanumeric characters. Python has various
standard data types that are used to define the operations possible on them and the storage
method for each of them.

Python has five standard data types −

 Numbers
 String
 List
 Tuple
 Dictionary

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Python Numbers
Number data types store numeric values. Number objects are created when you assign a value
to them

Python Strings
Strings in Python are identified as a contiguous set of characters represented in the quotation
marks. Python allows for either pairs of single or double quotes. Subsets of strings can be
taken using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the
string and working their way from -1 at the end.

Python Lists
Lists are the most versatile of Python's compound data types. A list contains items separated
by commas and enclosed within square brackets ([]). To some extent, lists are similar to
arrays in C. One difference between them is that all the items belonging to a list can be of
different data type.
The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes
starting at 0 in the beginning of the list and working their way to end -1. The plus (+) sign is
the list concatenation operator, and the asterisk (*) is the repetition operator. 

Python Tuples
A tuple is another sequence data type that is similar to the list. A tuple consists of a number
of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
The main differences between lists and tuples are: Lists are enclosed in brackets ([ ]) and
their elements and size can be changed, while tuples are enclosed in parentheses (( )) and
cannot be updated. Tuples can be thought of as read-only lists.

Python Dictionary
Python's dictionaries are kind of hash table type. They work like associative arrays or hashes
found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type,
but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python
object.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using
square braces ([]).

Different modes in python


Python has two basic modes: normal and interactive.
The normal mode is the mode where the scripted and finished .pie files are run in the Python
interpreter.
Interactive mode is a command line shell which gives immediate feedback for each
statement, while running previously fed statements in active memory. As new lines are fed
into the interpreter, the fed program is evaluated both in part and in whole

20 Python libraries
1. Requests. The most famous http library written by Kenneth remits. It’s a must have for
every python developer.
2. Scrappy. If you are involved in web scraping then this is a must have library for you. After
using this library you won’t use any other.
3. Python. A guy toolkit for python. I have primarily used it in place of tinder. You will really
love it.
4. Pillow. A friendly fork of PIL (Python Imaging Library). It is more user friendly than PIL
and is a must have for anyone who works with images.
5. SQLAlchemy. A database library. Many love it and many hate it. The choice is yours.
6. Beautiful Soup. I know it’s slow but this xml and html parsing library is very useful for
beginners.
7. Twisted. The most important tool for any network application developer. It has a very
beautiful ape and is used by a lot of famous python developers.
8. Numbly. How can we leave this very important library? It provides some advance math
functionalities to python.
9. Skippy. When we talk about numbly then we have to talk about spicy. It is a library of
algorithms and mathematical tools for python and has caused many scientists to switch from
ruby to python.
10. Matplotlib. A numerical plotting library. It is very useful for any data scientist or any data
analyser.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

11. Pygmy. Which developer does not like to play games and develop them? This library will
help you achieve your goal of 2d game development.
12. Piglet. A 3d animation and game creation engine. This is the engine in which the
famous python port of mine craft was made
13. Pit. A GUI toolkit for python. It is my second choice after python for developing GUI’s
for my python scripts.
14. Pit. Another python GUI library. It is the same library in which the famous Bit torrent
client is created.
15. Scaly. A packet sniffer and analyser for python made in python.
16. Pywin32. A python library which provides some useful methods and classes for
interacting with windows.
17. Notch. Natural Language Toolkit – I realize most people won’t be using this one, but it’s
generic enough. It is a very useful library if you want to manipulate strings. But its capacity is
beyond that. Do check it out.
18. Nose. A testing framework for python. It is used by millions of python developers. It is a
must have if you do test driven development.
19. Simply. Simply can do algebraic evaluation, differentiation, expansion, complex
numbers, etc. It is contained in a pure Python distribution.
20. I Python. I just can’t stress enough how useful this tool is. It is a python prompt on
steroids. It has completion, history, shell capabilities, and a lot more. Make sure that you take
a look at it.

Numpy

Humpy’s main object is the homogeneous multidimensional array. It is a table of elements


(usually numbers), all of the same type, indexed by a tuple of positive integers. In numbly
dimensions are called axes. The number of axes is rank.

• Offers Matlab-ish capabilities within Python

• Fast array operations

• 2D arrays, multi-D arrays, linear algebra etc.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Matplotlib

• High quality plotting library.

Python class and objects

These are the building blocks of OOP. Class creates a new object. This object can be
anything, whether an abstract data concept or a model of a physical object, e.g. a chair. Each
class has individual characteristics unique to that class, including variables and methods.
Classes are very powerful and currently “the big thing” in most programming languages.
Hence, there are several chapters dedicated to OOP later in the book.

The class is the most basic component of object-oriented programming. Previously, you
learned how to use functions to make your program do something.

Now will move into the big, scary world of Object-Oriented Programming (OOP). To be
honest, it took me several months to get a handle on objects.

When I first learned C and C++, I did great; functions just made sense for me.

Having messed around with BASIC in the early ’90s, I realized functions were just like
subroutines so there wasn’t much new to learn.

However, when my C++ course started talking about objects, classes, and all the new
features of OOP, my grades definitely suffered.

Once you learn OOP, you’ll realize that it’s actually a pretty powerful tool. Plus many Python
libraries and APIs use classes, so you should at least be able to understand what the code is
doing.

One thing to note about Python and OOP: it’s not mandatory to use objects in your code in a
way that works best; maybe you don’t need to have a full-blown class with initialization code
and methods to just return a calculation. With Python, you can get as technical as you want.

As you’ve already seen, Python can do just fine with functions. Unlike languages such as
Java, you aren’t tied down to a single way of doing things; you can mix functions and classes
as necessary in the same program. This lets you build the code

Objects are an encapsulation of variables and functions into a single entity. Objects get their
variables and functions from classes. Classes are essentially a template to create your objects.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Here’s a brief list of Python OOP ideas:

• The class statement creates a class object and gives it a name. This creates a new
namespace.

• Assignments within the class create class attributes. These attributes are accessed by
qualifying the name using dot syntax: ClassName.Attribute.

• Class attributes export the state of an object and its associated behaviour. These attributes
are shared by all instances of a class.

• Calling a class (just like a function) creates a new instance of the class.

This is where the multiple copies part comes in.

• Each instance gets ("inherits") the default class attributes and gets its own namespace. This
prevents instance objects from overlapping and confusing the program.

• Using the term self identifies a particular instance, allowing for per-instance attributes. This
allows items such as variables to be associated with a particular instance.

Inheritance

First off, classes allow you to modify a program without really making changes to it.

To elaborate, by sub classing a class, you can change the behavior of the program by simply
adding new components to it rather than rewriting the existing components.

As we’ve seen, an instance of a class inherits the attributes of that class.

However, classes can also inherit attributes from other classes. Hence, a subclass inherits
from a superclass allowing you to make a generic superclass that is specialized via
subclasses.

The subclasses can override the logic in a superclass, allowing you to change the behavior of
your classes without changing the superclass at all.

Operator Overloads

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Operator overloading simply means that objects that you create from classes can respond to
actions (operations) that are already defined within Python, such as addition, slicing, printing,
etc.

Even though these actions can be implemented via class methods, using overloading ties the
behaviour closer to Python’s object model and the object interfaces are more consistent to
Python’s built-in objects, hence overloading is easier to learn and use.

User-made classes can override nearly all of Python’s built-in operation methods

Exceptions

I’ve talked about exceptions before but now I will talk about them in depth. Essentially,
exceptions are events that modify program’s flow, either intentionally or due to errors.

They are special events that can occur due to an error, e.g. trying to open a file that doesn’t
exist, or when the program reaches a marker, such as the completion of a loop.

Exceptions, by definition, don’t occur very often; hence, they are the "exception to the rule"
and a special class has been created for them. Exceptions are everywhere in Python.

Virtually every module in the standard Python library uses them, and Python itself will raise
them in a lot of different circumstances.

Here are just a few examples:

• Accessing a non−existent dictionary key will raise a Key Error exception.

• Searching a list for a non−existent value will raise a Value Error exception

. • Calling a non−existent method will raise an Attribute Error exception.

• Referencing a non−existent variable will raise a Name Error exception.

• Mixing data types without coercion will raise a Type Error exception.

One use of exceptions is to catch a fault and allow the program to continue working; we have
seen this before when we talked about files.

This is the most common way to use exceptions. When programming with the Python
command line interpreter, you don’t need to worry about catching exceptions.

Your program is usually short enough to not be hurt too much if an exception occurs.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Plus, having the exception occur at the command line is a quick and easy way to tell if your
code logic has a problem.

However, if the same error occurred in your real program, it will fail and stop working.
Exceptions can be created manually in the code by raising an exception.

It operates exactly as a system-caused exceptions, except that the programmer is doing it on


purpose. This can be for a number of reasons. One of the benefits of using exceptions is that,
by their nature, they don’t put any overhead on the code processing.

Because exceptions aren’t supposed to happen very often, they aren’t processed until they
occur.

Exceptions can be thought of as a special form of the if/elf statements. You can realistically
do the same thing with if blocks as you can with exceptions.

However, as already mentioned, exceptions aren’t processed until they occur; if blocks are
processed all the time.

Proper use of exceptions can help the performance of your program.

The more infrequent the error might occur, the better off you are to use exceptions; using if
blocks requires Python to always test extra conditions before continuing.

Exceptions also make code management easier: if your programming logic is mixed in with
error-handling if statements, it can be difficult to read, modify, and debug your program.

User-Defined Exceptions

I won’t spend too much time talking about this, but Python does allow for a programmer to
create his own exceptions.

You probably won’t have to do this very often but it’s nice to have the option when
necessary.

However, before making your own exceptions, make sure there isn’t one of the built-in
exceptions that will work for you.

They have been "tested by fire" over the years and not only work effectively, they have been
optimized for performance and are bug-free.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Making your own exceptions involves object-oriented programming, which will be covered
in the next chapter. To make a custom exception, the programmer determines which base
exception to use as the class to inherit from, e.g. making an exception for negative numbers
or one for imaginary numbers would probably fall under the Arithmetic Error exception class.
To make a custom exception, simply inherit the base exception and define what it will do.

Python modules

Python allows us to store our code in files (also called modules). This is very useful for more
serious programming, where we do not want to retype a long function definition from the
very beginning just to change one mistake. In doing this, we are essentially defining our own
modules, just like the modules defined already in the Python library.

To support this, Python has a way to put definitions in a file and use them in a script or in an
interactive instance of the interpreter. Such a file is called a module; definitions from a
module can be imported into other modules or into the main module.

Testing code

As indicated above, code is usually developed in a file using an editor.

To test the code, import it into a Python session and try to run it.

Usually there is an error, so you go back to the file, make a correction, and test again.

This process is repeated until you are satisfied that the code works. T

His entire process is known as the development cycle.

There are two types of errors that you will encounter. Syntax errors occur when the form of
some command is invalid.

This happens when you make typing errors such as misspellings, or call something by the
wrong name, and for many other reasons. Python will always give an error message for a
syntax error.

Functions in Python

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

It is possible, and very useful, to define our own functions in Python. Generally speaking, if
you need to do a calculation only once, then use the interpreter. But when you or others have
need to perform a certain type of calculation many times, then define a function.

You use functions in programming to bundle a set of instructions that you want to use
repeatedly or that, because of their complexity, are better self-contained in a sub-
program and called when needed. That means that a function is a piece of code written to
carry out a specified task.

To carry out that specific task, the function might or might not need multiple inputs.
When the task is carved out, the function can or cannot return one or more values.
There are three types of functions in python:
Help (), min (), print ().

Python Namespace
Generally speaking, a namespace (sometimes also called a context) is a naming system for
making names unique to avoid ambiguity. Everybody knows a name spacing system from
daily life, i.e. the naming of people in first name and family name (surname).

An example is a network: each network device (workstation, server, printer,) needs a unique
name and address. Yet another example is the directory structure of file systems.

The same file name can be used in different directories, the files can be uniquely accessed via
the pathnames. 
Many programming languages use namespaces or contexts for identifiers. An identifier
defined in a namespace is associated with that namespace.

This way, the same identifier can be independently defined in multiple namespaces. (Like
the same file names in different directories) Programming languages, which support
namespaces, may have different rules that determine to which namespace an identifier
belongs. 

Namespaces in Python are implemented as Python dictionaries, this means it is a mapping


from names (keys) to objects (values). The user doesn't have to know this to write a Python
program and when using namespaces. 

Some namespaces in Python:

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

 global names of a module


 local names in a function or method invocation
 built-in names: this namespace contains built-in functions (e.g. abs(), camp(), ...) and built-in
exception names
Garbage Collection

Garbage Collector exposes the underlying memory management mechanism of Python, the
automatic garbage collector. The module includes functions for controlling how the collector
operates and to examine the objects known to the system, either pending collection or stuck
in reference cycles and unable to be freed.

Python XML Parser

XML is a portable, open source language that allows programmers to develop applications
that can be read by other applications, regardless of operating system and/or developmental
language.

What is XML? The Extensible Markup Language XML is a markup language much like
HTML or SGML.

This is recommended by the World Wide Web Consortium and available as an open standard.

XML is extremely useful for keeping track of small to medium amounts of data without
requiring a SQL-based backbone.

XML Parser Architectures and APIs the Python standard library provides a minimal but
useful set of interfaces to work with XML.

The two most basic and broadly used APIs to XML data are the SAX and DOM interfaces.

Simple API for XML SAX: Here, you register call-backs for events of interest and then let
the parser proceed through the document.

This is useful when your documents are large or you have memory limitations, it parses the
file as it reads it from disk and the entire file is never stored in memory.

Document Object Model DOM API : This is a World Wide Web Consortium
recommendation wherein the entire file is read into memory and stored in a hierarchical tree
− based form to represent all the features of an XML document.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

SAX obviously cannot process information as fast as DOM can when working with large
files. On the other hand, using DOM exclusively can really kill your resources, especially if
used on a lot of small files.

SAX is read-only, while DOM allows changes to the XML file. Since these two different
APIs literally complement each other, there is no reason why you cannot use them both for
large projects.

Python Web Frameworks

A web framework is a code library that makes a developer's life easier when building
reliable, scalable and maintainable web applications.

Why are web frameworks useful?


Web frameworks encapsulate what developers have learned over the past twenty years while
programming sites and applications for the web. Frameworks make it easier to reuse code for
common HTTP operations and to structure projects so other developers with knowledge of
the framework can quickly build and maintain the application.

Common web framework functionality

Frameworks provide functionality in their code or through extensions to perform common


operations required to run web applications. These common operations include:

1. URL routing
2. HTML, XML, JSON, and other output format tinplating
3. Database manipulation
4. Security against Cross-site request forgery (CSRF) and other attacks
5. Session storage and retrieval
Not all web frameworks include code for all of the above functionality. Frameworks fall on
the spectrum from executing a single use case to providing every known web framework
feature to every developer. Some frameworks take the "batteries-included" approach where
everything possible comes bundled with the framework while others have a minimal core
package that is amenable to extensions provided by other packages.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Comparing web frameworks


There is also a repository called compare-python-web-frameworks where the same web
application is being coded with varying Python web frameworks, tinplating engines and
object.

Web framework resources


 When you are learning how to use one or more web frameworks it's helpful to have an idea of
what the code under the covers is doing.
 Frameworks is a really well done short video that explains how to choose between web
frameworks. The author has some particular opinions about what should be in a framework.
For the most part I agree although I've found sessions and database ORMs to be a helpful part
of a framework when done well.
 What is a web framework? Is an in-depth explanation of what web frameworks are and their
relation to web servers?
 Jingo vs. Flash vs. Pyramid: Choosing a Python web framework contains background
information and code comparisons for similar web applications built in these three big Python
frameworks.
 This fascinating blog post takes a look at the code complexity of several Python web
frameworks by providing visualizations based on their code bases.
 Python’s web frameworks benchmarks  is a test of the responsiveness of a framework with
encoding an object to JSON and returning it as a response as well as retrieving data from the
database and rendering it in a template. There were no conclusive results but the output is fun
to read about nonetheless.
 What web frameworks do you use and why are they awesome? Is a language agnostic Reedit
discussion on web frameworks? It's interesting to see what programmers in other languages
like and dislike about their suite of web frameworks compared to the main Python
frameworks.
 This user-voted question & answer site asked "What are the best general purpose Python web
frameworks usable in production?” The votes aren't as important as the list of the many
frameworks that are available to Python developers.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Web frameworks learning checklist


1. Choose a major Python web framework (Jingo or Flask are recommended) and stick with it.
When you're just starting it's best to learn one framework first instead of bouncing around
trying to understand every framework.
2. Work through a detailed tutorial found within the resources links on the framework's page.
3. Study open source examples built with your framework of choice so you can take parts of
those projects and reuse the code in your application.
4. Build the first simple iteration of your web application then go to the deployment section to
make it accessible on the web.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

SYSTEM STUDY

Feasibility Study

The feasibility of the project is analysed in this phase and business proposal is put forth with
a very general plan for the project and some cost estimates. During system analysis the
feasibility study of the proposed system is to be carried out. This is to ensure that the
proposed system is not a burden to the company. For feasibility analysis, some
understanding of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are

 Economical Feasibility
 Technical Feasibility
 Social Feasibility

Economical Feasibility

This study is carried out to check the economic impact that the system will have on the
organization. The amount of fund that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus the developed
system as well within the budget and this was achieved because most of the technologies
used are freely available. Only the customized products had to be purchased.

Technical Feasibility
This study is carried out to check the technical feasibility, that is, the technical requirements
of the system. Any system developed must not have a high demand on the available technical
resources. This will lead to high demands on the available technical resources. This will lead

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

to high demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this system.

Social Feasibility

The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system
and to make him familiar with it. His level of confidence must be raised so that he is also able
to make some constructive criticism, which is welcomed, as he is the final user of the system.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

SYSTEM TESTING
The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality
of components, sub-assemblies, assemblies and/or a finished product It is the process of
exercising software with the intent of ensuring that the

Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a specific
testing requirement.

Types of Tests
Unit testing
Unit testing involves the design of test cases that validate that the internal program logic is
functioning properly, and that program inputs produce valid outputs. All decision branches
and internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests
perform basic tests at component level and test a specific business process, application,
and/or system configuration. Unit tests ensure that each unique path of a business process
performs accurately to the documented specifications and contains clearly defined inputs and
expected results.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Integration testing
Integration tests are designed to test integrated software components to determine if they
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown by successfully unit testing, the combination of
components is correct and consistent. Integration testing is specifically aimed at exposing
the problems that arise from the combination of components.

Functional test
Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user
manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be exercised.

Systems/Procedures : interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements, key functions, or


special test cases. In addition, systematic coverage pertaining to identify Business process
flows; data fields, predefined processes, and successive processes must be considered for
testing. Before functional testing is complete, additional tests are identified and the effective
value of current tests is determined.

System Test
System testing ensures that the entire integrated software system meets requirements. It tests
a configuration to ensure known and predictable results. An example of system testing is the
configuration oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

White Box Testing


White Box Testing is a testing in which in which the software tester has knowledge of the
inner workings, structure and language of the software, or at least its purpose. It is purpose. It
is used to test areas that cannot be reached from a black box level.

Black Box Testing


Black Box Testing is testing the software without any knowledge of the inner workings,
structure or language of the module being tested. Black box tests, as most other kinds of tests,
must be written from a definitive source document, such as specification or requirements
document, such as specification or requirements document. It is a testing in which the
software under test is treated, as a black box .you cannot “see” into it. The test provides
inputs and responds to outputs without considering how the software works.

Unit Testing:

Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.

Test strategy and approach


Field testing will be performed manually and functional tests will be written in detail.

Test objectives
 All field entries must work properly.
 Pages must be activated from the identified link.
 The entry screen, messages and responses must not be delayed.

Features to be tested
 Verify that the entries are of the correct format
 No duplicate entries should be allowed
 All links should take the user to the correct page.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

Integration Testing
Software integration testing is the incremental integration testing of two or more integrated
software components on a single platform to produce failures caused by interface defects.

The task of the integration test is to check that components or software applications, e.g.
components in a software system or – one step up – software applications at the company
level – interact without error.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

CONCLUSION

In this project we have successfully classified the images of healthy forest and the one with
deforestation using the convolution neural network of the deep learning. Here, we have
considered the dataset of images with 2 classes which among one are not deforested and
another are deforested and trained using CNN. After the training we have tested by uploading
the image and classified it.

FUTURE WORK

In future this can be implemented for any type of image classifications and image retrievals
that can be used for the accurate classification purpose.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

REFERENCES
1. World Wide Fund for Nature Home Page. Available online:
https://wwf.panda.org/our_work/forests/importance_forests/ (accessed on 17 June 2020).

2. Banskota, A.; Kayastha, N.; Falkowski, M.J.; Wulder, M.A.; Froese, R.E.; White, J.C.
Forest Monitoring using Landsat Time Series Data: A Review. Can. J. Remote Sens. 2014,
40, 362–384.

3. Yang, J.; Su, J.; Chen, F.; Xie, P.; Ge, Q. A local land use competition cellular automata
model and its application. ISPRS Int. J. Geo-Inf. 2016, 5, 106.

4. He, B.J.; Zhao, Z.Q.; Shen, L.D.; Wang, H.B.; Li, L.G. An approach to examining
performances of cool/hot sources in mitigating/enhancing land surface temperature under
different temperature backgrounds based on landsat 8 image. Sustain. Cities Soc. 2019, 44,
416–427.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

5. Liu, H.; Zhan, Q.; Gao, S.; Yang, C. Seasonal variation of the spatially non-stationary
association between land surface temperature and urban landscape. Remote Sens. 2019, 11,
1016.

6. American Forest Home Page. Available online:


https://www.americanforests.org/blog/much-forests-worth/ (accessed on 21 July 2016).

7. USDA Forest Service and NY State Department of Environmental Conservation Home


Page. Available online: https://www.dec.ny.gov/lands/40243.html (accessed on 20 June
2020).

8. Croitoru, L. Valuing the Non-Timber Forest Products in the Mediterranean Region. Ecol.
Econ. 2007, 63, 768–775.

9. Kim, J.H.; Kim, R.H.; Youn, H.J.; Lee, S.W.; Choi, H.T.; Kim, J.J.; Park, C.R.; Kim, K.D.
Valuation of Nonmarket Forest Resources. Korean Inst. For. Recreat. Welf. 2012, 16, 9–18.

10. Kuvan, Y. Mass Tourism Development and Deforestation in Turkey. Anatolia 2010, 21,
155–168.

11. Hosonuma, N.; Herold, M.; De Sy, V.; De Fries, R.S.; Brockhaus, M.; Verchot, L.;
Angelsen, A.; Romijn, E. An Assessment of Deforestation and Forest Degradation Drivers in
Developing Countries. Environ. Res. Lett. 2012, 7, 044009.

12. Clerici, N.; Armenteras, D.; Kareiva, P.; Botero, R.; Ramírez-Delgado, J.; Forero-
Medina, G.; Ochoa, J.; Pedraza, C.; Schneider, L.; Lora, C. Deforestation in Colombian
Protected Areas Increased during Post-Conflict Periods. Sci. Rep. 2020, 10, 4971.

13. Wang, C.; Myint, S.W.; Hutchins, M. The Assessment of Deforestation, Forest
Degradation, and Carbon Release in Myanmar 2000–2010. In Environmental Change in the
Himalayan Region; Springer: Berlin/Heidelberg, Germany, 2019; pp. 47–64.

14. Korea Forest Service Home Page. Available online: http://forest.go.kr (accessed on 29
August 2019).

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

15. Fuller, D.O. Tropical Forest Monitoring and Remote Sensing: A New Era of
Transparency in Forest Governance? Singap. J. Trop. Geogr. 2006, 27, 15–29.

16. Dalponte, M.; Bruzzone, L.; Gianelle, D. Fusion of Hyperspectral and LIDAR Remote
Sensing Data for Classification of Complex Forest Areas. IEEE Trans. Geosci. Remote Sens.
2008, 46, 1416–1427.

17. Sanchez-Azofeifa, G.A.; Harriss, R.C.; Skole, D.L. Deforestation in Costa Rica: A
quantitative analysis using remote sensing imagery 1. Biotropica 2001, 33, 378–384.

18. Mertens, B.; Sunderlin, W.D.; Ndoye, O.; Lambin, E.F. Impact of Macroeconomic
Change on Deforestation in South Cameroon: Integration of Household Survey and
Remotely-Sensed Data. World Dev. 2000, 28, 983–999.

19. Frohn, R.; McGwire, K.; Dale, V.; Estes, J. Using Satellite Remote Sensing Analysis to
Evaluate a Socio-Economic and Ecological Model of Deforestation in Rondonia, Brazil.
Remote Sens. 1996, 17, 3233–3255.

20. McCracken, S.D.; Brondizio, E.S.; Nelson, D.; Moran, E.F.; Siqueira, A.D.; Rodriguez-
Pedraza, C. Remote Sensing and GIS at Farm Property Level: Demography and Deforestation
in the Brazilian Amazon. Photogramm. Eng. Remote Sens. 1999, 65, 1311–1320.
21. Chowdhury, R.R. Driving Forces of Tropical Deforestation: The Role of Remote Sensing
and Spatial Models. Singap. J. Trop. Geogr. 2006, 27, 82–101.

22. Buchanan, G.M.; Butchart, S.H.; Dutson, G.; Pilgrim, J.D.; Steininger, M.K.; Bishop,
K.D.; Mayaux, P. Using Remote Sensing to Inform Conservation Status Assessment:
Estimates of Recent Deforestation Rates on New Britain and the Impacts upon Endemic
Birds. Biol. Conserv. 2008, 141, 56–66.

23. Achard, F.; Estreguil, C. Forest Classification of Southeast Asia using NOAA AVHRR
Data. Remote Sens. Environ. 1995, 54, 198–208.

24. Desclée, B.; Bogaert, P.; Defourny, P. Forest Change Detection by Statistical Object-
Based Method. Remote Sens. Environ. 2006, 102, 1–11.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433
Domain: Artificial Intelligence
Technology: Python

25. Lary, D.J.; Alavi, A.H.; Gandomi, A.H.; Walker, A.L. Machine Learning in Geosciences
and Remote Sensing. Geosci. Front. 2016, 7, 3–10.

Web: www.takeoffprojects.com Phone: 08772261612


Email: [email protected] +91-9030333433

You might also like