A13 Miniproject
A13 Miniproject
A13 Miniproject
PREDICTION
A Mini Project thesis submitted to the JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY in partial fulfillment of the
requirement for the award of the degree of
BACHELOR OF TECHNOLOGY
In
Submitted by
BOPPA SREEJA (19D31A0520)
ALETI KAVYA (19D31A0502)
B. ARUN KUMAR (19D31A0516)
Jan 2023
I
Date: / /2023
CERTIFICATE
This is to certify that the thesis “MACHINE LEARNING BASED RAINFALL
PREDICTION” being submitted by
The results embodied in this thesis have not been submitted to any other
University or Institute for the award of any degree or diploma.
EXTERNAL EXAMINER
II
ACKNOWLEDGEMENT
We are thankful to Mr. CH. Shekhar, Asst, Prof., Project Guide, Dept. of
CSE who guided us a lot by her favorable suggestions to complete our project. She is
theresearch oriented personality with higher end technical exposure.
We are thankful to Mr. Ritesh Thakur, Prof & Head of the department,
CSE, Indur Institute Of Engineering & Technology, for extending his help in the
department academic activities in the course duration. He is the personality of
dynamic, enthusiastic in the academic activities.
We sincerely acknowledge to all the lecturers of the Dept. of CSE for their
motivation during our B.Tech course.
We would like to say thanks to all of our friends for their timely help and
encouragement.
III
DECLARATION
IV
ABSTRACT
Rainfall prediction is the one of the important technique to predict the climatic
conditions in any country. This paper proposes a rainfall prediction model using
Multiple Linear Regression (MLR) for Indian dataset.
The data taken from 1901 to 2015 monthly wise. The input data is having
multiple meteorological parameters and to predict the rainfall in more precise.
The Mean Square Error (MSE), accuracy, correlation are the parameters used
to validate the proposed model. From the results, the proposed machine learning model
provides better results than the other algorithms in the literature.
V
CONTENTS
2 SYSTEM ANALYSIS 8
2.1 Existing System 8
2.1.1 Disadvantages of Existing System 8
2.2 Proposed System 9
2.2.1 Advantages of Proposed System 9
2.3 System Study 9
2.3.1 Feasibility Study
2.4 Project Specifications 10
2.4.1 Hardware Requirements 11
2.4.2 Software Requirements 11
2.5 Project Requirements 11
2.6 Software Environment 12
2.6.1 Python 12
2.6.2 Django 21
3 SYSTEM DESIGN 32
VI
4 IMPLEMENTATION 40
4.1 Modules 40
4.2 Input Design 42
4.3 Output Design 43
4.4 Source Code 44
5 RESULT 66
6 SYSTEM TESTING 77
6.1 Sample Test Cases 77
6.2 Unit Testing 79
6.3 Integration Testing 79
6.4 Functional Test 79
6.5 White Box Testing 80
6.6 Black Box Testing 80
6.7 Unit Testing 81
6.8 Integration Testing 81
6.9 Acceptance Testing 82
7 CONCLUSION 83
8 FUTURE IMPROVEMENT 84
9 REFERENCES 85
VII
LIST OF FIGURES
IX
CHAPTER 1
INTRODUCTION
Contracts based on the rainfall index are decisive for farmers and other users
whose income is directly or indirectly affected by the rain. A lack or too much rainfall
is capable of destroying a farmer’s crops and hence their income. Thus, rainfall
derivatives are a method for reducing the risk posed by adverse or uncertain whether
circumstances.
Moreover, they are a better alternative than insurance, because it can be hard to
prove that the rainfall has had an impact unless it is destructive, such as severe floodsor
drought. Similar contracts exist for other weather variables, such as temperature and
wind. Within the literature rainfall derivatives is split into two main parts. Firstly,
predicting the level of rainfall over a specified time and secondly, pricing the
derivatives based on different contract periods/length. The latter has its own unique
problem, as rainfall derivatives constitutes an incomplete mar-ket1.
This means the standard option pricing models such as the Black-Scholes model
are incapable of pricing rainfall derivatives, because of the violation of the assumptions
of the model; namely no arbitrage pricing.
1
Thus, a new pricing framework needs to be established. This paper focuses on
the first aspect of predicting the level of rainfall. Note that it is essential to have a model
that can accurately predict the level of rainfall, before pricing derivatives, because the
contracts are priced on the predicted accumulated rainfall over a period of time.
In order to predict the level of rainfall for rainfall derivatives, the statistical
approach of Markov-chain extended with rainfall prediction (MCRP) is used. Other
methods do exist, but this approach in particular is the most commonly used, and will
thus be acting as a benchmark for our proposed methodology. The use of these models
allows for the simulation of rainfall on a daily time scale, thus giving more flexibility
in the problem domain.
The reason why we are interested in daily amounts, rather than monthly or
annual amount models is because the models are a lot more flexible to changes.
Moreover, one is able to capture trends and more information from studying daily
values. Thus, increasing the accuracy of pricing, which is crucial because contracts are
priced ahead of time—sometimes this can be up to a year ahead. It is outside the scope
of this paper to cover rainfall derivatives in detail.
As already mentioned, the use of MCRP is the most prevalent approach, due to
its simplicity. The general approach of MCRP is often referred to as a ‘chain-dependent
process’, which splits the model into capturing first the occurrence pattern, and then the
rainfall intensities.
2
level of rainfall observed across the study period and does not take into account annual
deviations in weather patterns.
Due to the disadvantages highlighted above, we divert away from the use of
statistical approaches and in this paper we propose using a machine learning technique
called Genetic Programming (GP). Rainfall prediction has not been covered in great
detail within the machine learning literature and the applications are mainly focused on
the short term predictions i.e. up to a few hours.
Little literature exists for the daily predictions, e.g. used a feed-forward back-
propagation neural network for rainfall prediction in Sri Lanka, which was inspired by
the chain-dependent approach from statistics. To the best of our knowledge, the only
work that exists for daily predictions using Genetic Programming is. However, the GP
performed poorly by itself, although when assisted by wavelets the predictive accuracy
did improve.
However, there has been no previous work in using GP in the context of rainfall
weather derivatives. The goal of this paper is thus to explore whether GP is able to
outperform the usual approach adopted within the rainfall derivative literature, namely
MCRP.
GP is chosen for this paper over other machine learning techniques, because it
has the benefit of producing white box (interpretable, as opposed to black box) models,
which allows us to probe the models produced. Moreover, we can capture nonlinear
patterns in data without any assumptions regarding the data.
This should allow us to produce a model that can reflect the ever changing
process of rainfall. As a result, we could capture yearly deviations that the current
MCRP is unable to replicate. Additionally, we are able to produce a more general
model, which can be applied to a range of cities/climates, without having to build a new
model each time.
Hence, the main contribution of this paper is that we propose a new GP for the
problem of rainfall prediction, and compare its predictive performance against the
performance of the current state-of-the-art MCRP approach. This will be the first step
towards pricing rainfall derivatives using GP.
3
1.1 LITERATURE REVIEW
A literature review identifies, evaluates and synthesises the relevant literarute
within a particular field of research. It includes the existing research information of
different scholars as follows.
Also, through support vector machine (SVM), it has been observed that
generation of clusters impacts positively on the prediction of the Indian summer
monsoon rainfall. Results have been presented through statistical and graphical
analyses. Behaviour of systems with many interdependent components that lead to
organized as well as irregular features is referred to as complexity.
In such systems the knowledge of the parts does not necessarily lead to the
predictable behaviour of the entire system Modelling complexity of atmospheric
phenomena and generating prediction schemes accordingly has long been an area of
major concentration for the meteorologists over the globeIn view of importance of the
estimation of the future projected precipitation and rainfall on short- and long-term
basis detrended fluctuation analysis has been implemented by Efstathiou and Varotsos
(2012) in rainfall time series to explore the intrinsic properties of their temporal
variability.
4
since 1900, did not occur smoothly and slowly, but with two rapid shifts in 1925/1926
and 1987/1988, which are more obvious over the tropics and the northern midlatitudes.
In back-propagation algorithm, there are two phases in its learning cycle, one
to propagate the input patterns through the network and other to adapt the output by
changing the weights in the network.
The paper implements one of these applications by building training and testing
data sets and finding the number of hidden neurons in these layers for the best
performance. In the present research, possibility of predicting average rainfall over
Udupi district of Karnataka has been analyzed through artificial neural network models.
Authors: Minghui Qiu, Peilin Zhao, Ke Zhang, Jun Huang, Xing Shi,
Xiaoguang Wang, Wei Chu
Precipitation prediction, such as short-term rainfall prediction, is a very
important problem in the field of meteorological service. In practice, most of recent
studies focus on leveraging radar data or satellite images to make predictions.
However, there is another scenario where a set of weather features are
collected by various sensors at multiple observation sites.
5
The observations of a site are sometimes incomplete but provide important
clues for weather prediction at nearby sites, which are not fully exploited in existing
work yet.
To solve this problem, we propose a multi-task convolutional neural network
model to automatically extract features from the time series measured at observation
sites and leverage the correlation between the multiple sites for weather prediction via
multi-tasking.
To the best of our knowledge, this is the first attempt to use multi-task
learning and deep learning techniques to predict short-term rainfall amount based on
multi-site features.
Specifically, we formulate the learning task as an end-to-end multi-site neural
network model which allows to leverage the learned knowledge from one site to other
correlated sites, and model the correlations between different sites.
Extensive experiments show that the learned site correlations are insightful
and the proposed model significantly outperforms a broad set of baseline models
including the European Centre for Medium-range Weather Forecasts system
(ECMWF).
Rainfall is one of the major source of freshwater for all the organism around the
world. Rainfall prediction model provides the information regarding various
climatological variables on the amount of rainfall. In recent days, Deep Learning
enabled the self-learning data labels which allows to create a data-driven model for a
time series dataset.
It allows to make the anomaly/change detection from the time series data and
also predicts the future event's data with respect to the events occurred in the past. This
paper deals with obtaining models of the rainfall precipitation by using Deep Learning
Architectures (LSTM and ConvNet) and determining the better architecture withRMSE
of LSTM as 2.55 and RMSE of ConvNet as 2.44 claiming that for any time series
dataset, Deep Learning models will be effective and efficient for the modellers.
6
1.1.5 The Research Of Rainfall Prediction Models Based On Matlab Neural
Network
After it has been trained by input forecast samples, network forecast model that
has three neural cells possesses very good generalization capability. After we contrast
fitting rate and accuracy rate of network model with ones of regression model, network
model has a distinct advantage over regression model.
7
CHAPTER 2
SYSTEM ANALYSIS
System analysis is conducted for the purpose of studying a system or its parts
in order to identify its objectives. It is a problem solving technique that improves the
system and ensures that all the components of the system work efficiently to
accomplish their purpose. Analysis specifies what the system should do.
In the Existing system used back propagation neural network for rainfall
prediction. This model used by Xianggen Gan and he was tested using the dataset from
1970 to 2000 which has 16 meteorological parameters. During network training the
target error is set as 0.01 and learning rate is set as 0.01.
The disadvantage of MCRP is that it predicts accurate only for annual rainfall
when compared with monthly rainfall prediction.
The assumptions which are made by the multiple linear regression are: linear
relationship between the both the descriptive and independent variables, the
highly correlated variables are independent variables, yi is calculated randomly.
Weather is extremely difficult to forecast correctly.
It is expensive to monitor-so many variables from so many sources.
The computers needed to perform the millions of calculations necessary are
expensive.
Algorithm: Markov-chain extended with rainfall prediction (MCRP), Genetic
Programming
8
2.2 PROPOSED SYSTEM
The proposed method is based on the multiple linear regression. The data for
the prediction is collected from the publically available sources and the 70 percentage
of the data is for training and the 30 percentage of the data is for testing. Multiple
regression is used to predict the values with the help of descriptive variables and is a
statistical method.
It is having a linear relationship between the descriptive variable and the output
values. The number of observation is indicated by n. The dependent variable is yi and
the descriptive variable is xi. β0 and β p are the constant y intercept and slop of
descriptive variable respectively.
The error free prediction provides better planning in the agriculture and other
industries.
The linear relationship between the both the descriptive and independent
variables, the highly correlated variables are independent variables, yi is
calculated randomly and the mean and variance are 0 and σ.
The ability to determine the relative influence of one or more predictor
variables to the criterion value.
Ability to identify outliers or anomalies.
9
1. 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.
2. 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 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.
3. 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.
10
2.4.1 HARDWARE REQUIREMENTS
System : Intel i3
Ram : 4GB.
Designing : Html,css,javascript.
The project involved analyzing the design of few applications so as to make the
application more users friendly. To do so, it was really important to keep the
navigations from one screen to the other well ordered and at the same time reducing the
amount of typing the user needs to do. In order to make the application more accessible,
the browser version had to be chosen so that it is compatible with most of the browsers.
1. Functional Requirements
2. Hardware Requirements
For developing the application the following are the Hardware Requirements:
Processor: Intel i3
RAM: 4 GB
Space on Hard Disk: minimum 1 TB
11
3. Software Requirements
For developing the application the following are the Software Requirements:
1. Python
2. Django
1. Windows 10 64 bit OS
1. Python
2.6.1 Python
It provides constructs that enable clear programming on both small and large
scales. Python interpreters are available for many operating systems. CPython,the
reference implementation of Python, is open source software and has a community-
based development model, as do nearly all of its variant implementations. CPython is
managed by the non-profit Python Software Foundation. Python features a dynamic
type system and automatic memory management. It supports multiple programming
12
paradigms, including object-oriented, imperative, functional and procedural, and has a
large and comprehensive standard library.
$ python
>>>
Type the following text at the Python prompt and press the Enter −
If you are running new version of Python, then you would need to use print statement
with parenthesis as in print ("Hello, Python!");. However in Python version 2.4.3, this
produces the following result −
Hello, Python!
Invoking the interpreter with a script parameter begins execution of the script
and continues until the script is finished. When the script is finished, the interpreter is
no longer active.
Let us write a simple Python program in a script. Python files have extension .py. Type
the following source code in a test.py file −
Live Demo
We assume that you have Python interpreter set in PATH variable. Now, try to run this
program as follows −
$ python test.py
13
This produces the following result −
Hello, Python!
Let us try another way to execute a Python script. Here is the modified test.py file −
Live Demo
#!/usr/bin/python
We assume that you have Python interpreter available in /usr/bin directory. Now, try to
run this program as follows −
$./test.py
Hello, Python!
Python Identifiers
Python does not allow punctuation characters such as @, $, and % within identifiers.
Python is a case sensitive programming language. Thus, Manpower and manpower are
two different identifiers in Python.
Class names start with an uppercase letter. All other identifiers start with a lowercase
letter.
Starting an identifier with a single leading underscore indicates that the identifier is
private.
14
If the identifier also ends with two trailing underscores, the identifier is a language-
defined special name.
Reserved Words
The following list shows the Python keywords. These are reserved words and
you cannot use them as constant or variable or any other identifier names. All the
Python keywords contain lowercase letters only.
Assert Finally or
def If return
elif in while
else is with
except lmbdayield
Python provides no braces to indicate blocks of code for class and function
definitions or flow control. Blocks of code are denoted by line indentation, which is
rigidly enforced.
The number of spaces in the indentation is variable, but all statements within
the block must be indented the same amount. For example −
if True:
print "True"
else:
print "False"
15
However, the following block generates an error −
if True:
print "Answer"
print "True"
else:
print "Answer"
print "False"
Thus, in Python all the continuous lines indented with same number of spaces would
form a block. The following example has various statement blocks −
Note − Do not try to understand the logic at this point of time. Just make sure you
understood various blocks even if they are without braces.
#!/usr/bin/python
import sys
try:
# open file stream
file = open(file_name, "w")
except IOError:
print "There was an error writing to", file_name
sys.exit()
print "Enter '", file_finish,
print "' When finished"
while file_text != file_finish:
file_text = raw_input("Enter text: ")
if file_text == file_finish:
# close the file
file.close
break
file.write(file_text)
file.write("\n")
16
file.close()
file_name = raw_input("Enter filename: ")
if len(file_name) == 0:
print "Next time please enter something"
sys.exit()
try:
file = open(file_name, "r")
except IOError:
print "There was an error reading file"
sys.exit()
file_text = file.read()
file.close()
print file_text
Multi-Line Statements
Statements in Python typically end with a new line. Python does, however, allow the use
of the line continuation character (\) to denote that the line should continue. For example
−
total = item_one + \
item_two + \
item_three
Statements contained within the [], {}, or () brackets do not need to use the line
continuation character. For example −
The triple quotes are used to span the string across multiple lines. For example, all the
following are legal −
word = 'word'
17
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is
made up of multiple lines and sentences."""
Comments in Python
A hash sign (#) that is not inside a string literal begins a comment. All characters after
the # and up to the end of the physical line are part of the comment and the Python
interpreter ignores them.
Live Demo
#!/usr/bin/python
# First comment
print "Hello, Python!" # second comment
This produces the following result −
Hello, Python!
You can type a comment on the same line after a statement or expression −
# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.
Following triple-quoted string is also ignored by Python interpreter and can be used as a
multiline comments:
'''
This is a multiline
comment.
'''
Using Blank Lines
A line containing only whitespace, possibly with a comment, is known as a blank line
and Python totally ignores it.
18
In an interactive interpreter session, you must enter an empty physical line to terminate
a multiline statement.
#!/usr/bin/python
if expression :
suite
elif expression :
suite
else :
suite
19
Command Line Arguments
Many programs can be run to provide you with some basic information about
how they should be run. Python enables you to do this with -h −
$ python -h
usage: python [option] ... [-c cmd | -m mod | file | -] [arg]
You can also program your script in such a way that it should accept various
options. Command Line Arguments is an advanced topic and should be studied a bit
later once you have gone through rest of the Python concepts.
Python Lists
The list is a most versatile datatype available in Python which can be written
asa list of comma-separated values (items) between square brackets. Important thing
about a list is that items in a list need not be of the same type.
list2 = [1, 2, 3, 4, 5 ];
For example −
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5 );
tup3="a","b","c","d";
20
Properties of Dictionary Keys
Dictionary values have no restrictions. They can be any arbitrary Python object,
either standard objects or user-defined objects. However, same is not dict = {'Name':
'Zara', 'Age': 7, 'Name': 'Manni'}
2.6.2 DJANGO
21
Django also provides an optional administrative create, read, update and delete
interface that is generated dynamically through introspection and configured viaadmin
models
Create a Project
Whether you are on Windows or Linux, just get a terminal or a cmd prompt and
navigate to the place you want your project to be created, then use this code −
myproject/
manage.py
myproject/
init .py
settings.py
urls.py
wsgi.py
22
The Project Structure
The “myproject” folder is just your project container, it actually contains two elements−
manage.py − This file is kind of your project local django-admin for interacting with
your project via command line (start the development server, sync db...). To get a full
list of command accessible via manage.py you can use the code −
The “myproject” subfolder − This folder is the actual python package of your
project. It contains four files −
urls.py − All links of your project and the function to call. A kind of ToC of
your project.
DEBUG = True
This option lets you set if your project is in debug mode or not. Debug mode
lets you get more information about your project's error. Never set it to ‘True’ for a live
project. However, this has to be set to ‘True’ if you want the Django light server to
serve static files. Do it only in the development mode.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'database.sql',
'USER': '',
23
'PASSWORD': '',
'HOST': '',
'PORT': '',
Database is set in the ‘Database’ dictionary. The example above is for SQLite
engine. As stated earlier, Django also supports −
MySQL (django.db.backends.mysql)
PostGreSQL(django.db.backends.postgresql_psycopg2)
MongoDB (django_mongodb_engine)
Before setting any new engine, make sure you have the correct db driver installed.
Now that your project is created and configured make sure it's working −
You will get something like the following on running the above code −
Validating models...
0 errors found
24
A project is a sum of many applications. Every application has an objective and
can be reused into another project, like the contact form on a website can be an
application, and can be reused for others. See it as a module of your project.
Create an Application
We assume you are in your project folder. In our main “myproject” folder, the
same folder then manage.py −
You just created myapp application and like project, Django create a “myapp”
folder with the application structure −
myapp/
init .py
admin.py
models.py
tests.py
views.py
init .py − Just to make sure python handles this folder as a package.
admin.py − This file helps you make the app modifiable in the admin interface.
At this stage we have our "myapp" application, now we need to register it with
our Django project "myproject". To do so, update INSTALLED_APPS tuple in the
settings.py file of your project (add your app name) −
INSTALLED_APPS = (
'django.contrib.admin',
25
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
myapp/forms.py
class LoginForm(forms.Form):
As seen above, the field type can take "widget" argument for html rendering; in
our case, we want the password to be hidden, not displayed. Many others widget are
present in Django: DateInput for dates, CheckboxInput for checkboxes, etc.
There are two kinds of HTTP requests, GET and POST. In Django, the request
object passed as parameter to your view has an attribute called "method" where the type
of the request is set, and all data passed via POST can be accessed via the request.POST
dictionary.
26
from myapp.forms import LoginForm
def login(request):
if request.method == "POST":
MyLoginForm = LoginForm(request.POST)
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data['username']
else:
MyLoginForm = Loginform()
The view will display the result of the login form posted through the
loggedin.html. To test it, we will first need the login form template.
<html>
<body>
<center>
</center>
</div>
<br>
27
<div style = "max-width:470px;">
<center>
</center>
</div>
<br>
<center>
<strong>Login</strong>
</button>
</center>
</div>
</form>
</body>
</html>
The template will display a login form and post the result to our login view above. You
have probably noticed the tag in the template, which is just to prevent Cross-site
Request Forgery (CSRF) attack on your site.
{% csrf_token %}
Once we have the login template, we need the loggedin.html template that will be
rendered after form treatment.
28
<html>
<body>
</body>
</html>
urlpatterns = patterns('myapp.views',
url(r'^connection/',TemplateView.as_view(template_name = 'login.html')),
Setting Up Sessions
'django.contrib.sessions.middleware.SessionMiddleware'
'django.contrib.sessions'
When session is enabled, every request (first argument of any view in Django) has a
session (dict) attribute.
29
Let's create a simple sample to see how to create and save sessions. We have
built a simple login system before (see Django form processing chapter and Django
Cookies Handling chapter). Let us save the username in a cookie so, if not signed out,
when accessing our login page you won’t see the login form. Basically, let's make our
login system we used in Django Cookies handling more secure, by saving cookies
server side.
For this, first lets change our login view to save our username cookie server side −
def login(request):
if request.method == 'POST':
MyLoginForm = LoginForm(request.POST)
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data['username']
request.session['username'] = username
else:
MyLoginForm = LoginForm()
Then let us create formView view for the login form, where we won’t display
the form if cookie is set −
def formView(request):
if request.session.has_key('username'):
username = request.session['username']
30
else:
Now let us change the url.py file to change the url so it pairs with our new view −
urlpatterns = patterns('myapp.views',
url(r'^connection/','formView', name = 'loginform'),
url(r'^login/', 'login', name = 'login'))
When accessing /myapp/connection, you will get to see the following page
31
CHAPTER 3
SYSTEM DESIGN
Software design is a mechanism to transform user requirements into some
suitable form, which helps the programmer in software coding and implementation. It
deals with representing the client's requirement, as described in SRS document, into a
form, i.e., easily implementable using programming language.
32
3.2 DATA FLOW DIAGRAM
1. The DFD is also called as bubble chart. It is a simple graphical formalism that
can be used to represent a system in terms of input data to the system, various
processing carried out on this data, and the output data is generated by this
system.
2. The data flow diagram (DFD) is one of the most important modeling tools. It is
used to model the system components. These components are the system
process, the data used by the process, an external entity that interacts with the
system and the information flows in the system.
3. DFD shows how the information moves through the system and how it is
modified by a series of transformations. It is a graphical technique that depicts
information flow and the transformations that are applied as data moves from
input to output.
4. DFD is also known as bubble chart. A DFD may be used to represent a system
at any level of abstraction. DFD may be partitioned into levels that represent
increasing information flow and functional detail.
33
Fig-3.2 Data Flow Diagram
34
3.3 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 in 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.
35
3.3.1 USE CASE DIAGRAM
A use case diagram in the Unified Modeling Language (UML) is a type of
behavioral 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.
Users Admin
36
3.3.2 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 Admin
+str username +str loginid
+str pswd +str pswd
+register() +activateusers()
+datapreprocess() +addData()
+getmse()
DataPreprocess
+pandas Datafrome MLR
+model DataModel
+pandas dataframe
+hist()
+mse()
+scatterplot()
+rmse()
+cleanedata()
+correlation()
37
3.3.3 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 timing diagrams.
1 : Register()
2 : Activated()
3 : Start Pr eprocess()
5 : hist graph()
6 : ploted graph()
7 : confusion matrix()
8 : predections()
9 : mse()
10 : rmse()
11 : result displayed()
38
3.3.4 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.
39
CHAPTER 4
IMPLEMENTATION
Implementation is a realization of a technical specification or algorithm as a
program, software component. The translated code may either be directly executed by
hardware, or serve as input to another interpreter or another compiler.
4.1 MODULES
User
Admin
Data preprocess
Multiple Linear Regression (MLR)
1. User:
The User can register the first. While registering he required a valid user email
and mobile for further communications. Once the user register then admin can activate
the customer. Once admin activated the customer then customer can login into our
system. After login he can search the weather report based on city.
For searching the weather report we use open weather map api. The rest
connection we are sending to the server and it will return the json data. The json data
we are parsing and required information converted into python dictionary sent to the
user side. Once it done then the user can perform the preprocess operations. The hist
diagram plot diagram are displayed based on the data.
2. Admin:
Admin can login with his credentials. Once he login he can activate the users.
The activated user only login in our applications. The admin can set the data set by
Indian metrological weather report. In this report the data has consider as monthly wise
and yearly quarterly wise.
The admin can add new data to the dataset. So this data user can perform the
testing process. The admin can view data based on paginations. The total paginations
will be displayed on the browser.
40
3. Data Preprocess:
The admin provided data has been stored in the sqlite database. To process our
methodology we need to perform data cleaning process. By using pandas data frame
we can fill the missing values with its mean type. Once data cleaned the hist diagram
will be displayed.
This hist diagram, is monthly wise will be displayed. Alter monthly wise bar
graph and quarter wise bar graph will be displayed. Then we are calculating the
confusion matrix of the selected model. Once its done the user can see the cleaned data
in the browser.
41
4.2 INPUT DESIGN
The input design is the link between the information system and the user. It
comprises the developing specification and procedures for data preparation and those
steps are necessary to put transaction data in to a usable form for processing can be
achieved by inspecting the computer to read data from a written or printed document or
it can occur by having people keying the data directly into the system. The design of
input focuses on controlling the amount of input required, controlling the errors,
avoiding delay, avoiding extra steps and keeping the process simple. The input is
designed in such a way so that it provides security and ease of use with retaining the
privacy.
OBJECTIVES
the input into a computer-based system. This design is important to avoid errors in the
data input process and show the correct direction to the management for getting correct
information from the computerized system.
large volume of data. The goal of designing input is to make data entry easier and to be
free from errors. The data entry screen is designed in such a way that all the data
manipulates can be performed. It also provides record viewing facilities.
3. When the data is entered it will check for its validity. Data can be entered
with the help of screens. Appropriate messages are provided as when needed so that the
user will not be in maize of instant. Thus the objective of input design is to create an
input layout that is easy to follow
42
4.3 OUTPUT DESIGN
A quality output is one, which meets the requirements of the end user and
presents the information clearly. In any system results of processing are communicated
to the users and to other system through outputs. In output design it is determined how
the information is to be displaced for immediate need and also the hard copy output. It
is the most important and direct source information to the user. Efficient and intelligent
output design improves the system’s relationship to help user decision-making.
43
4.4 SOURCE CODE
GeneratePltGraph.py
# autolabel(rects1)
for rect in rects1:
h = rect.get_height()
ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * h, '%d' % int(h),
ha='center', va='bottom')
44
for rect in rects2:
h = rect.get_height()
ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * h, '%d' % int(h),
ha='center', va='bottom')
# autolabel(rects2)
# os.path.join(BASE_DIR, 'assets/templates')
plt.savefig(os.path.join(BASE_DIR, 'assets/static/graphs/') + title + "." + 'png')
plt.show()
plt.close()
class GeneratePltGraph:
def preProcessGraphs(self,data):
data = data.fillna(data.mean())
data.info()
print(data.head())
print(data.describe())
# plt.savefig('models_accuracy.png') #for Saving pic
# plt.savefig('figure1.png',data.hist(figsize=(24, 24)))
data.hist(figsize=(24, 24));
#plt.savefig('hist.png')
data.groupby("YEAR").sum()['ANNUAL'].plot(figsize=(12, 8));
data[['YEAR', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP',
'OCT', 'NOV', 'DEC']].groupby(
"YEAR").sum().plot(figsize=(13, 8));
data[['YEAR', 'JanToFeb', 'MarToMay', 'JunToSep',
'OctToDec']].groupby("YEAR").sum().plot(figsize=(13, 8));
data[['SUBDIVISION', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG',
'SEP', 'OCT', 'NOV',
'DEC']].groupby("SUBDIVISION").mean().plot.barh(stacked=True,
figsize=(13, 8));
data[['SUBDIVISION', 'JanToFeb', 'MarToMay', 'JunToSep',
'OctToDec']].groupby("SUBDIVISION").sum().plot.barh(
stacked=True, figsize=(16, 8));
plt.figure(figsize=(11, 4))
45
sns.heatmap(data[['JanToFeb', 'MarToMay', 'JunToSep', 'OctToDec',
'ANNUAL']].corr(), annot=True)
plt.show()
plt.figure(figsize=(11, 4))
sns.heatmap(
data[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT',
'NOV', 'DEC', 'ANNUAL']].corr(),
annot=True)
plt.show()
plt.close()
def genMlrCodes(self,data):
# seperation of training and testing data
division_data = np.asarray(
data[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT',
'NOV', 'DEC']])
X = None;
y = None
for i in range(division_data.shape[1] - 3):
if X is None:
X = division_data[:, i:i + 3]
y = division_data[:, i + 3]
else:
X = np.concatenate((X, division_data[:, i:i + 3]), axis=0)
y = np.concatenate((y, division_data[:, i + 3]), axis=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1,
random_state=42)
# test 2010
temp = data[['SUBDIVISION', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV', 'DEC']].loc[data['YEAR'] == 2010]
data_2010 = np.asarray(temp[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV',
'DEC']].loc[temp['SUBDIVISION'] == 'TELANGANA'])
X_year_2010 = None;
y_year_2010 = None
46
for i in range(data_2010.shape[1] - 3):
if X_year_2010 is None:
X_year_2010 = data_2010[:, i:i + 3]
y_year_2010 = data_2010[:, i + 3]
else:
X_year_2010 = np.concatenate((X_year_2010, data_2010[:, i:i + 3]),
axis=0)
y_year_2010 = np.concatenate((y_year_2010, data_2010[:, i + 3]), axis=0)
# test 2005
temp = data[['SUBDIVISION', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV', 'DEC']].loc[data['YEAR'] == 2005]
data_2005 = np.asarray(temp[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV',
'DEC']].loc[temp['SUBDIVISION'] == 'TELANGANA'])
X_year_2005 = None;
y_year_2005 = None
for i in range(data_2005.shape[1] - 3):
if X_year_2005 is None:
X_year_2005 = data_2005[:, i:i + 3]
y_year_2005 = data_2005[:, i + 3]
else:
X_year_2005 = np.concatenate((X_year_2005, data_2005[:, i:i + 3]),
axis=0)
y_year_2005 = np.concatenate((y_year_2005, data_2005[:, i + 3]), axis=0)
# terst 2015
temp = data[['SUBDIVISION', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV', 'DEC']].loc[data['YEAR'] == 2015]
data_2015 = np.asarray(temp[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
'AUG', 'SEP', 'OCT', 'NOV',
'DEC']].loc[temp['SUBDIVISION'] == 'TELANGANA'])
X_year_2015 = None;
y_year_2015 = None
for i in range(data_2015.shape[1] - 3):
if X_year_2015 is None:
47
X_year_2015 = data_2015[:, i:i + 3]
y_year_2015 = data_2015[:, i + 3]
else:
X_year_2015 = np.concatenate((X_year_2015, data_2015[:, i:i + 3]),
axis=0)
y_year_2015 = np.concatenate((y_year_2015, data_2015[:, i + 3]), axis=0)
from sklearn import linear_model
# linear model
reg = linear_model.ElasticNet(alpha=0.5)
reg.fit(X_train, y_train)
y_pred = reg.predict(X_test)
print(mean_absolute_error(y_test, y_pred))
y_year_pred_2005 = reg.predict(X_year_2005)
# 2010
y_year_pred_2010 = reg.predict(X_year_2010)
y_year_pred_2015 = reg.predict(X_year_2015)
print("MEAN 2005")
print(np.mean(y_year_2005), np.mean(y_year_pred_2005))
print("Standard deviation 2005")
print(np.sqrt(np.var(y_year_2005)), np.sqrt(np.var(y_year_pred_2005)))
print("MEAN 2010")
print(np.mean(y_year_2010), np.mean(y_year_pred_2010))
print("Standard deviation 2010")
print(np.sqrt(np.var(y_year_2010)), np.sqrt(np.var(y_year_pred_2010)))
print("MEAN 2015")
print(np.mean(y_year_2015), np.mean(y_year_pred_2015))
print("Standard deviation 2015")
print(np.sqrt(np.var(y_year_2015)), np.sqrt(np.var(y_year_pred_2015)))
plot_graphs(y_year_2005, y_year_pred_2005, "Year-2005")
plot_graphs(y_year_2010, y_year_pred_2010, "Year-2010")
plot_graphs(y_year_2015, y_year_pred_2015, "Year-2015")
plt.close()
def testMltMSE(self,data):
rsltdict = {}
48
X = data['JAN'].values
y = data['DEC'].values
X = X.reshape(-1, 1)
y = y.reshape(-1, 1)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1,
random_state=42)
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
# print('Predection result ',y_pred)
# print('Test ',X_test)
mse = metrics.mean_squared_error(y_test, y_pred)
rmse = np.sqrt(mse)
lrcorr = regressor.coef_
lcoe = sum(lrcorr) / len(lrcorr)
rsltdict.update({'lgmse': mse, 'lgrmse': rmse, 'lgcorr': lcoe})
accuracy = metrics.accuracy_score(y_test.round(), y_pred.round(),
normalize=False)
# print('LR accuracy ', accuracy)
# print(mse, "==", rmse)
division_data = np.asarray(data[['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL',
'AUG', 'SEP', 'OCT', 'NOV', 'DEC']])
X = None;
y = None
for i in range(division_data.shape[1] - 3):
if X is None:
X = division_data[:, i:i + 3]
y = division_data[:, i + 3]
else:
X = np.concatenate((X, division_data[:, i:i + 3]), axis=0)
y = np.concatenate((y, division_data[:, i + 3]), axis=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1,
49
random_state=42)
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
# print('Predection result ',y_pred)
# print('Test ',X_test)
mse = metrics.mean_squared_error(y_test, y_pred)
rmse = np.sqrt(mse)
mlrco = regressor.coef_
mlrcorre = sum(mlrco) / len(mlrco)
# accuracy = metrics.accuracy_score(y_test.round(),
y_pred.round(),normalize=False)
# print('MLR accuracy ',accuracy)
print(mse, "==", rmse)
# plt.scatter(x=y_test, y=y_pred, c="red")
# plt.show()
rsltdict.update({'mlrmse': mse, 'mlrrmse': rmse, 'mlrcorr': lcoe})
####QPF CODE
from keras.models import Model
from keras.layers import Dense, Input, Conv1D, Flatten
# NN model
inputs = Input(shape=(3, 1))
x = Conv1D(64, 2, padding='same', activation='elu')(inputs)
x = Conv1D(128, 2, padding='same', activation='elu')(x)
x = Flatten()(x)
x = Dense(128, activation='elu')(x)
x = Dense(64, activation='elu')(x)
x = Dense(32, activation='elu')(x)
x = Dense(1, activation='linear')(x)
model = Model(inputs=[inputs], outputs=[x])
model.compile(loss='mean_squared_error', optimizer='adamax', metrics=['mae'])
model.summary()
50
model.fit(x=np.expand_dims(X_train, axis=2), y=y_train, batch_size=64,
epochs=10, verbose=1,
validation_split=0.1,
shuffle=True)
y_pred = model.predict(np.expand_dims(X_test, axis=2))
qmse = metrics.mean_squared_error(y_test, y_pred)
qrmse = np.sqrt(qmse)
print('Qmse = ', qmse, " QRmse=", qrmse)
qcorr = qmse / qrmse
rsltdict.update({'qpfmse': qmse, 'qpfrmse': qrmse, 'qpfcorr': qcorr})
# accuracy = metrics.accuracy_score(y_test.round(),
y_pred.round(),normalize=False)
# print('QPF accuracy ',accuracy)
plt.close()
return rsltdict
import math
from django.shortcuts import render,HttpResponse
from sklearn.model_selection import train_test_split
from .forms import UserRegistrationForm
import requests
from django.contrib import messages
from .forms import UserRegistrationForm
from .models import RainFallUserRegistrationModel,IndiaRainFallDataModel
import io,csv
from django_pandas.io import read_frame
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
from sklearn.preprocessing import StandardScaler
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from sklearn import metrics
51
import os
from .GenGraphCode import GeneratePltGraph
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath( file )))
# Create your views here.
def UserLogin(request):
return render(request,'UserLogin.html',{})
def UserRegister(request):
form = UserRegistrationForm()
return render(request,'UserRegisterForm.html',{'form':form})
def GetWeatherInfo(request):
if request.method == 'POST':
city = request.POST.get('cityname')
accesKey = '9c5781db8bb4ee7c96f7dee77728e353'
url =
'http://api.openweathermap.org/data/2.5/weather?q={}&units=imperial&appid=9c578
1db8bb4ee7c96f7dee77728e353'
#city = 'Las Vegas'
city_weather = requests.get( url.format(city)).json() # request the API data and
convert the JSON to Python data types
print("Weather info ",city_weather)
weather = {
'city': city,
'temperature': city_weather['main']['temp'],
'description': city_weather['weather'][0]['description'],
'icon': city_weather['weather'][0]['icon'],
#'message':city_weather['message']
}
context = {'weather': weather}
return render(request, 'weatherinfo.html', context)
def UserRegisterAction(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
print('Data is Valid')
52
form.save()
messages.success(request, 'You have been successfully registered')
# return HttpResponseRedirect('./CustLogin')
form = UserRegistrationForm()
return render(request, 'UserRegisterForm.html', {'form': form})
else:
print("Invalid form")
else:
form = UserRegistrationForm()
return render(request, 'UserRegisterForm.html', {'form': form})
def UserLoginCheck(request):
if request.method == "POST":
loginid = request.POST.get('loginid')
pswd = request.POST.get('pswd')
print("Login ID = ", loginid, ' Password = ', pswd)
try:
check = RainFallUserRegistrationModel.objects.get(loginid=loginid,
password=pswd)
status = check.status
print('Status is = ', status)
if status == "activated":
request.session['id'] = check.id
request.session['loggeduser'] = check.name
request.session['loginid'] = loginid
request.session['email'] = check.email
print("User id At", check.id, status)
return render(request, 'users/UserHomePage.html', {})
else:
messages.success(request, 'Your Account Not at activated')
return render(request, 'UserLogin.html')
# return render(request, 'user/userpage.html',{})
except Exception as e:
print('Exception is ', str(e))
pass
53
messages.success(request, 'Invalid Login id and password')
return render(request, 'UserLogin.html', {})
def GetWeatherInfo(request):
if request.method == 'POST':
city = request.POST.get('cityname')
accesKey = '9c5781db8bb4ee7c96f7dee77728e353'
url =
'http://api.openweathermap.org/data/2.5/weather?q={}&units=imperial&appid=9c578
1db8bb4ee7c96f7dee77728e353'
city_weather = requests.get( url.format(city)).json() # request the API data and
convert the JSON to Python data types
print("Weather info ",city_weather)
code = city_weather['cod']
if code==200:
print('Data valid')
else:
messages.success(request, 'Data Not Found')
return render(request, 'users/GetWeatherInfo.html', {})
print('Status code ',code)
weather = {
'city': city,
'temperature': city_weather['main']['temp'],
'description': city_weather['weather'][0]['description'],
'icon': city_weather['weather'][0]['icon'],
#'message':city_weather['message']
}
context = {'weather': weather}
return render(request, 'users/GetWeatherInfo.html', context)
def SearchByCity(request):
return render(request,'users/SearchByCity.html',{})
def UserUploadData(request):
return render(request,'users/uploaddata.html',{})
def UploadCSVToDataBase(request):
54
# declaring template
template = "users/UserHomePage.html"
data = IndiaRainFallDataModel.objects.all()
# prompt is a context variable that can have different values depending on their
context
prompt = {
'order': 'Order of the CSV should be name, email, address, phone, profile',
'profiles': data
}
# GET request returns the value of the data with the specified key.
if request.method == "GET":
return render(request, template, prompt)
csv_file = request.FILES['file']
# let's check if it is a csv file
if not csv_file.name.endswith('.csv'):
messages.error(request, 'THIS IS NOT A CSV FILE')
data_set = csv_file.read().decode('UTF-8')
# setup a stream which is when we loop through each line we are able to handle a
data in a stream
io_string = io.StringIO(data_set)
next(io_string)
for column in csv.reader(io_string, delimiter=',', quotechar="|"):
_, created = IndiaRainFallDataModel.objects.update_or_create(
SUBDIVISION=column[0],
YEAR=column[1],
JAN=column[2],
FEB=column[3],
MAR=column[4],
APR=column[5],
MAY=column[6],
JUN=column[7],
JUL=column[8],
AUG=column[9],
55
SEP=column[10],
OCT=column[11],
NOV=column[12],
DEC=column[13],
ANNUAL=column[14],
JanToFeb=column[15],
MarToMay=column[16],
JunToSep=column[17],
OctToDec=column[18]
)
context = {}
return render(request, 'users/UserHomePage.html', context)
def UserDataPreProcess(request):
qs = IndiaRainFallDataModel.objects.all()
data = read_frame(qs)
g = GeneratePltGraph()
g.preProcessGraphs(data)
return render(request,'users/PreProcessedData.html',{'data':qs})
def UserMLRCode(request):
qs = IndiaRainFallDataModel.objects.all()
data = read_frame(qs)
gf = GeneratePltGraph()
gf.genMlrCodes(data)
return render(request,'users/UsersMachineLearningGraphs.html',{})
def TestMlR(request):
qs = IndiaRainFallDataModel.objects.all()
data = read_frame(qs)
gh = GeneratePltGraph()
rsltdict = gh.testMltMSE(data)
return render(request,"users/MlrTestResult.html",rsltdict)
56
user side models.py
57
ANNUAL = models.FloatField(default=0.0);
JanToFeb = models.FloatField(default=0.0);
MarToMay = models.FloatField(default=0.0);
JunToSep = models.FloatField(default=0.0);
OctToDec = models.FloatField(default=0.0);
def str (self):
return self.SUBDIVISION
class Meta:
db_table = 'IndianRainfall'
58
'autocomplete': 'off','pattern':'[A-Za-z ]+', 'title':'Enter Characters Only '}),
required=True,max_length=100)
status = forms.CharField(widget=forms.HiddenInput(), initial='waiting'
,max_length=100)
class Meta():
model = RainFallUserRegistrationModel
fields=' all '
59
print("PID = ", id, status)
RainFallUserRegistrationModel.objects.filter(id=id).update(status=status)
data = RainFallUserRegistrationModel.objects.all()
return render(request,'admins/AdminViewUsers.html',{'data':data})
def AdminAddData(request):
if request.method == 'POST':
form = IndiaRainFallDataForm(request.POST)
if form.is_valid():
print('Data is Valid')
form.save()
messages.success(request, 'Data Added Successfull')
form = IndiaRainFallDataForm()
return render(request, 'admins/AddRainFallData.html', {'form': form})
else:
print("Invalid form")
else:
form = IndiaRainFallDataForm()
return render(request, 'admins/AddRainFallData.html', {'form': form})
def AdminViewData(request):
data_list = IndiaRainFallDataModel.objects.all()
page = request.GET.get('page', 1)
paginator = Paginator(data_list, 60)
try:
users = paginator.page(page)
except PageNotAnInteger:
users = paginator.page(1)
except EmptyPage:
users = paginator.page(paginator.num_pages)
return render(request, 'admins/AdminViewWeather.html', {'users': users})
60
base.html
{%load static%}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0,maximum-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></scr
ipt>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<title>Compass Starter by India, Rian</title>
<link href="http://fonts.googleapis.com/css?family=Roboto:300,400,700|"
rel="stylesheet" type="text/css">
<link href="{%static 'fonts/font-awesome.min.css'%}" rel="stylesheet"
type="text/css">
<link rel="stylesheet" href="{%static 'style.css'%}">
</head>
<body>
<div class="site-content">
<div class="site-header">
<div class="container">
<a href="index.html" class="branding">
<img src="{%static 'images/logo.png'%}" alt="" class="logo">
<div class="logo-type">
61
<h1 class="site-title">Rainfall Prediction</h1>
<small class="site-description">Machine Learning based</small>
</div>
</a>
62
</div>
<p class="colophon">Copyright 2020 Alex Corporation. Designed by Alex.
All rights reserved</p>
</div>
</footer> <!-- .site-footer -->
</div>
<script src="{%static 'js/jquery-1.11.1.min.js'%}"></script>
<script src="{%static 'js/plugins.js'%}"></script>
<script src="{%static 'js/app.js'%}"></script>
</body>
</html>
userregisterform.html
{%extends 'base.html'%}
{%block contents %}
<center>
<p>
<form method="POST" action="{%url 'UserRegisterAction'%}" >
{% csrf_token %}
<h2>User Register Form</h2>
<table>
<tr><td>Customer Name</td><td>{{form.name}}</td></tr>
<tr><td>Login ID</td><td>{{form.loginid}}</td></tr>
<tr><td>Password</td><td>{{form.password}}</td></tr>
<tr><td>Mobile</td><td>{{form.mobile}}</td></tr>
<tr><td>email</td><td>{{form.email}}</td></tr>
<tr><td>Locality</td><td>{{form.locality}}</td></tr>
<tr><td>Address</td><td>{{form.address}}</td></tr>
<tr><td>City</td><td>{{form.city}}</td></tr>
<tr><td>State</td><td>{{form.state}}</td></tr>
<tr><td></td><td>{{form.status}}</td></tr>
<tr><td><button class="btn btn-primary my-2 my-sm-0" type="submit"
style = "margin-left:20%;">Register</button></td></tr>
{% if messages %}
63
{% for message in messages %}
<font color='GREEN'> {{ message }}</font>
{% endfor %}
{% endif %}
</table>
</form>
</p>
</center>
{%endblock%}
Urls.py
64
### User Side all urs
path('UserLogin/',usr.UserLogin,name='UserLogin'),
path('UserRegister/',usr.UserRegister,name='UserRegister'),
path('GetWeatherInfo/',usr.GetWeatherInfo,name='GetWeatherInfo'),
path('UserRegisterAction/',usr.UserRegisterAction,name='UserRegisterAction'),
path('UserLoginCheck/',usr.UserLoginCheck, name='UserLoginCheck'),
path('GetWeatherInfo/',usr.GetWeatherInfo, name='GetWeatherInfo'),
path('SearchByCity/',usr.SearchByCity, name='SearchByCity'),
path('UserUploadData/',usr.UserUploadData,name='UserUploadData'),
path('UploadCSVToDataBase/', usr.UploadCSVToDataBase,
name='UploadCSVToDataBase'),
path('UserDataPreProcess/',usr.UserDataPreProcess, name='UserDataPreProcess'),
path('UserMLRCode/',usr.UserMLRCode,name='UserMLRCode'),
path('TestMlR/',usr.TestMlR, name='TestMlR'),
65
CHAPTER 5
RESULTS
The information that they get from users is called input, and the information
that they give to users is called output. The input and output is the result of the
proposed model.
67
Fig-5.5 View Registered Users
68
Fig-5.7 Admin View Data
69
Fig-5.9 User Home Page
70
Fig-5.11 Report
71
Fig-5.13 Monthly Wise Correlated Graph
72
Fig-5.15 State wise Graph
73
Fig-5.17 Confusion Matrix
74
Fig-5.19 Preprocessed Data
75
Fig-5.21 Epoch Running
76
CHAPTER 6
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.
Excepted Remarks(IF
S.no Test Case Result
Result Fails)
If already user
If User
1. User Register Pass email exist then
registration
it fails.
successfully.
If User name
and password is Un Register
2. User Login correct then it Pass Users will not
will getting logged in.
valid page.
According to
India
metrological
A new record
Admin Add repository the
3. will added to Pass
the Data data must be
our dataset.
float fields
otherwise its
failed.
77
The data will
be in int or float
format,
Data will be
4. Data Cleaning otherwise
cleaned.
Pass algorithm will
not work..
If data not
Hist diagram
cleaned or NA
5. Hist digram generated bsed Pass
then it give you
on months
an error
78
TYPES OF TESTS
There are various types of test. Each test type addresses a specific testing
requirement, as discussed below.
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.
79
Functions : identified functions must be exercised.
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.
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 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.
80
6.7 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.
Field testing will be performed manually and functional tests will be written
in detail.
Test objectives
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.
81
6.9 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.
82
CHAPTER 7
CONCLUSION
Rain fall prediction plays the major role in agriculture production. The growth
of the agricultural products is based on the rainfall amount.
So it is necessary to predict the rainfall of a season to assist farmers in
agriculture. The proposed method predicts the rainfall for the Indian dataset using
multiple linear regression and provides improved results in terms of accuracy, MSE and
correlation.
83
CHAPTER 8
FUTURE IMPROVEMENT
As rainfall is dependent on the various parameters it is also required to study
how other meteorological parameters affect the Rainfall prediction.
We can also perform the same exercise on monthly data using various
parameters to forecast next month rainfall. A study can also be done using more
observations for particular region or area, and design this kind of model on big data
framework so that computation can be faster with higher accuracy.
84
CHAPTER 9
REFERENCES
3. Minghui Qiu, Peilin Zhao, Ke Zhang, Jun Huang, Xing Shi, Xiaoguang Wang, Wei
Chu, “A Short-Term Rainfall Prediction Model using Multi-Task Convolutional Neural
Networks”, IEEE International Conference on Data Mining, pp. 395-400, 2017, DOI
10.1109/ICDM.2017.49.
4. Aswin S, Geetha P and Vinayakumar R, “Deep Learning Models for the Prediction
of Rainfall”, International Conference on Communication and Signal Processing, April
3-5, 2018, India, pp. 0657-0661.
5. Xianggen Gan, Lihong Chen, Dongbao Yang, Guang Liu, “The Research Of
Rainfall Prediction Models Based On Matlab Neural Network”, Proceedings of IEEE
CCIS2011, pp. 45- 48.
85
7. Mohini P. Darji, Vipul K. Dabhi, Harshadkumar B.Prajapati, “Rainfall Forecasting
Using Neural Network: A Survey”, 2015 International Conference on Advances in
Computer Engineering and Applications (ICACEA) IMS Engineering College,
Ghaziabad, India, pp.706 – 713
10. Mr. Sunil Navadia, Mr. Pintukumar Yadav, Mr. Jobin Thomas, Ms. Shakila
Shaikh, “Weather Prediction: A novel approach for measuring and analyzing weather
data”, International conference on I-SMAC (IoT in Social, Mobile, Analytics and
Cloud) (I-SMAC 2017), pp. 414 - 417
86