0% found this document useful (0 votes)
3 views

Weather Forecast ML

The document presents a project on weather prediction using machine learning, developed by Pavithrapriya K at Sathyabama Institute of Science and Technology. It outlines the application of various algorithms, including Linear Regression and Naïve Bayesian Classification, to forecast weather conditions based on historical data. The project aims to provide accessible weather information, particularly benefiting visually impaired users through features like speech recognition.

Uploaded by

Shrey sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Weather Forecast ML

The document presents a project on weather prediction using machine learning, developed by Pavithrapriya K at Sathyabama Institute of Science and Technology. It outlines the application of various algorithms, including Linear Regression and Naïve Bayesian Classification, to forecast weather conditions based on historical data. The project aims to provide accessible weather information, particularly benefiting visually impaired users through features like speech recognition.

Uploaded by

Shrey sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Weather Prediction Using Machine Learning

Sathyabama Institute of Science and Technology


(Deemed to be University)

Submitted in partial fulfillment of the requirements for the award of


Bachelor of Technology Degree in

Information Technology
By

PAVITHRAPRIYA K
38120056

DEPARTMENT OF INFORMATION TECHNOLOGY


SCHOOL OF COMPUTING
SATHYABAMA INSTITUTE OF SCIENCE AND TECHNOLOGYUNIVERSITY
JEPPIAAR NAGAR, RAJIV GANDHI SALAI,
CHENNAI – 600119. TAMILNADU.
JANUARY 2021

SATHYABAMA UNIVERSITY
(Established under Section 3 of UGC Act, 1956)
Jeppiaar Nagar, Rajiv Gandhi Salai, Chennai - 600119
www.sathyabamauniversity.ac.in

_________________________________________________________________

SCHOOL OF COMPUTING

BONAFIDE CERTIFICATE

This is to certify that this Professional Training Report is the bonafide work of
PAVITHRAPRIYA.K (Reg. No. 38120056.) who underwent the professional
training in “WEATHER PREDICTION” under our supervision from JULY 2021 to
DEC 2021.

Internal Guide
Dr.G.Mathivanan M.E., Ph.D.,

Head of the Department


Dr. R.SUBHASHINI M.E., Ph.D.,

Submitted for Viva voce Examination held on_____________________

Internal Examiner External Examiner


DECLARATION

I, PAVITHRAPRIYA.K (Reg. No. 38120056) hereby declare that the Professional

Training Report on “WEATHER PREDICTION USING MACHINE LEARNING”

done by me under the guidance of DR.G.MATHIVANAN, at Sathyabama university

is submitted in partial fulfillment of the requirements for the award of Bachelor of

Engineering degree in Computer Science and Engineering.

DATE: 13/11/2021
PLACE: CHENNAI SIGNATURE OF THE CANDIDATE
ACKNOWLEDGEMENT

I am pleased to acknowledge my sincere thanks to Board of Management of

SATHYABAMA INSTITUTE OF SCIENCE AND TECHNOLOGY for their kind

encouragement in doing this project and for completing it successfully. I am

grateful to them.

I convey my thanks to Dr. T.Sasikala M.E., Ph.D, Dean, School of Computing

,Dr.R.SUBHASHINI M.E., Ph.D. , Head of the Department of Information and

Technology for providing me necessary support and details at the right time during

the progressive reviews.

I would like to express my sincere and deep sense of gratitude to my Project

Guide Dr.G.MATHIVANAN, for his valuable guidance, suggestions and constant

encouragement paved way for the successful completion of my project work.

I wish to express my thanks to all Teaching and Non-teaching staff members of

the Department of Information Technology who were helpful in many ways for the

completion of the project.


TRAINING CERTIFICATE
ABSTRACT

Weather is a vital part of a person's life because it can tell us whether it will rain or
be sunny. Weather forecasting is meteorologists' attempt to predict weather
conditions in the future, as well as weather conditions that may be predicted.
Temperature, pressure, humidity, dew point, rainfall, precipitation, wind speed, and
dataset size are all used to calculate the climatic state parameters. To begin, the
data must be educated. We can use 75-90% of the data from the data collection to
train the data. User can predict daily weather report using the particular dataset
which is already imported like API. Here API is vital role for current data. Here one of
the main feature is Speech Recognition(like alexa). It will ask question and user can
ask query which will send result. Mainly this will helpful for blind people. Based on
this user can get output for weather without click anything. If user want to access
directly they can go with visualization. Using this project user can get current
weather report and only need the input of name of the city once enter the city name
full report will be generated for current situation. We can analyze the predict
temperature with original temperature and can predict future rain fall. We'll use the
Linear Regression Algorithm and the Nave Bayesian Classification Algorithm to
make this prediction. Python, NumPy, Jupiter Notebook, Spyder, and Panda will be
used in this project. The project is split into three separate Jupiter Notebooks: one to
collect the weather data, inspect it, and clean it; a second to further refine the
features and fit the data to a Linear Regression model and Naïve Bayesian model
and a third to train and evaluate our output.
TABLE OF CONTENTS

Chapter TITLE Page


No. No.

ABSTRACT vi
LIST OF FIGURES ix
LIST OF ABBREVIATIONS AND MODULES ix

1 INTRODUCTION
1.1 GENERAL 1
1.2 OBJECTIVE 1
1.3 OVERVIEW OF THE PROJECT 1

2. AIM AND SCOPE


2.1 AIM 2
2.2 PROJECT SCOPE 2
2.3 PROBLEM STATEMENT 3
2.4 EXISTING SYSTEM 3
2.5 DISADVANTAGE OF EXISTING SYSTEM 3
2.6 ADVANTAGE OF OVER CURRENT SYSTEM 3

3 PROJECT DESCRIPTION
3.1 OVERVIEW 4
3.2 FEATURES OF THIS APPLICATION 4
3.3 FORECAST DATA 5
3.6 WEATHER PREDICTION 6
3.5 TEMPERATURE PREDICTION 6
3.6 ADVANTAGE AND DISADVANTAGE OF WEATHER 7
FORECASTING
3,7 PRACTICAL APPLICATION OF WEATHER 7
FORECASTING
3.8 APPLICATION IN VARIOUS FIELDS 8
3.9 SUMMARY 8

4 SYSTEM ANALYSIS AND DESIGN


4.1 GENERAL 9
4.2 SOFTWARE USED 9
4.3 SYSTEM REQUIREMENT 10
4.4 PROCESSING DATA 11
4.5 FUNCTIONAL REQUIREMENT 11
4.6 DATA COLLECTION 12
4.4 PROJECT DESCRIPTION 12
4.5 WORKFLOW DIAGRAM 13

5 CONCLUSION AND FUTURE WORK


5.1 PROJECT OUTLOOK 22
5.2 CONCLUSION 22
5.3 FUTURE WORK 23

REFERENCES
6 APPENDIX
A. SOURCE CODE
B. SCREEN SHOTS
LIST OF FIGURE

FIGURE No. TITLE PAGE No.


4.1 WORK FLOW 15
4.2 DATA FLOW 16
4.3 SPEECH RECOGNITION FLOW 17
DIAGRAM
4.4 WEATHER FLOW DIAGRAM 18
4.5 TEMPERATURE FLOW DIAGRAM 19
4.6 DATASET FOR TEMPERATURE 20
4.7 DATASET FOR RAINFALL 21
6.1 OUTPUT 37

LIST OF ABBREVIATIONS AND MODULES

Python - Using Source Language


ML - Machine Learning
MODULES - Tkinter, request, time, matplotlib, pandas, skylearn
CHAPTAR 1

INTRODUCTION

1.1 GENERAL

A Weather prediction is used to predict the current weather situation. The


application of physics principles, augmented by a range of statistical and analytical
methods, to predict the weather is known as weather forecasting. Weather
forecasting provides forecasts of shifts in the Earth's surface temperature in
addition to predictions of atmospheric phenomena. These shifts are influenced by
atmospheric conditions such as snow and ice cover. The foundation for weather
prediction began with ancient Greek philosophers' theories and continued with
Renaissance scientists. Any weather prediction requires a systematic compilation
of weather records from different locations, as well as adequate data analysis and
prediction.

1.2 OBJECTIVE

The objective of this application is that it saves time, simple and efficient. It is
mainly to avoid scared about weather related problems. The blind people can also
handle this application.

1.3 OVERVIEW OF THE PROJECT

We have developed the system in such a way that it can be used efficiently by all
the users. Let’s Assume all the webpages and logics related to admin and users
as separate modules. We have two modules and each of these modules have
their own unique functions. Important thing is that it is not designed for particular
type peoples. This application can help all the users to access the weather report
details through internet or intranet that means anytime and anywhere. We wanted
to create a tool that fits into modern age, but still stays true to the “concepts of
studying”. So, this process also helps in maintaining consistency and integrity.
This system helps the user to generate the dynamic legwork.

CHAPTER 2

AIM AND SCOPE

2.1 AIM

The goal of weather prediction is to provide information people and organizations


can use to reduce weather-related losses and enhance societal benefits, including
protection of life and property, public health and safety, and support of economic
prosperity and quality of life. In economic terms, the benefit of the investment in
public weather forecasts and warnings is substantial: the estimated annualized
benefit is about $31.5 billion, compared to the $5.1 billion cost of generation the
information.

2.2 PROJECT SCOPE

The main aim of this project is predict the weather report and should be useful for
all kind of peoples. Based on this type of application we can avoid unwanted
weather related problem. The Linear Regression algorithm, which is used to
forecast weather using these data, is at the center of this project, the higher the
precision, the more parameters considered. This project has the potential to assist
a large number of people in predicting tomorrow's weather. Temperature, dew,
pressure, and humidity are simply used to train the data in this project. These data
are then used to train a prediction model using Linear Regression.
2.3 PROBLEM STATEMENT

The peoples cannot know rainfall, snow etc.., and they couldn’t be able to prevent
from that natural disaster. Though using this application one can easily find out
their current weather situation in live location.

2.4 EXISTING SYSTEM

The people cannot know the current weather situation. So that the people face many
issues (like people going for outside purchase during the rain fall). Abstract weather
problem is defined in many areas and it’s hard to solve, because it includes many
constraints that should be solved. Its doesn’t have analysing process.

2.5 DISADVANTAGE OF CURRENT SYSTEM

• Takes a lot of time.


• Less Accurate.
• Not capable to contain all the information.
• Separate social media required.
• High complexity and additional setting efforts.

2.6 ADVANTAGES OVER CURRENT SYSTEM

• Easy to handle and operate.


• Friendly interface.
• Fast and convenient.
• Easy to update.
• Easy message passing.
• Smart way of communication
• Secure
CHAPTER 3

SYSTEM IMPLEMENTATION

3.1 OVERVIEW

The fundamental idea behind my project is to create a website that would make
greater this easier. I wanted to create a tool that fits into modern age, but still stays
true to the concepts of studying. Following is the detail of different modules of my
project.

3.2 FEATURES OF THE APPLICATION

Using this application we comes to know the weather situation in live locations.
This application dashboard contains speech recognition, current weather report for
specific city, Analyze average rainfall for every month in India, Rainfall predict the
Tomorrow, Predict the temperature for year, comparing original temperature vs
predict temperature.
Speech Recognition
The blind people can also access this project using this features.
Its option features the user can take this option once if need.
Current weather report for specific city
Using this feature the people can know current weather report for
live location and specific city. Its contains humidity, temperature, etc…,
Analyze average rainfall for every month
Using this feature one can analyse the monthly fall rain level.
Based on this we can analyse the rainfall and predict the rainfall for next
year.
Rainfall predict the tomorrow
Using this feature one can predict the rainfall will happen for
tomorrow or not

Predict the temperature for every year


Using this feature can predict the temperature for yearly and
analyse.
Comparing original vs predict temperature
Using this features the developer can comes to know the
difference between the original to predicted temperature.

3.3 FORECASTE DATA


 Between 1980 and 2009 - 96 weather disasters in the United States each
caused at least$1 billion in damages, with total losses exceeding $700
billion (NCDC, 2010).
 Between 1999 and 2008 - there were an average of 629 direct weather
fatalities per year (NWS, 2010).
 The annual impacts of adverse weather on the national highway system
and roads are staggering:
 1.5 million weather-related crashes with 7,400 deaths, more than 700,000
injuries, and $42 billion in economic losses (BTS, 2007).
 In addition, $4.2 billion is lost each year as a result of weather-related air
traffic delays (NOAA, 2010).
 Weather is also a major factor in the complex set of interactions that
determine air quality; more than 60,000 premature deaths each year are
attributed to poor air quality (Schwartz and Dockery, 1992).
3.4 WEATHER PREDICTION

Get the current weather report for a location by city name. Using this we can get
the temperature for current location get to know temperature, humidity, chill, cold
etc…, The OpenWeatherMap API currently provides a wide variety of weather
data including current weather, forecasts, historical, weather stations and weather
alerts. The API documentation is comprehensive, easy to follow and includes
many examples of API requests and the responses returned.

3.5 TEMPERATURE PREDICTION

We will work on forecasting the average global land and ocean temperature using
over 100 years of historical weather data. We’ll pretend that we don’t have access
the any weather forecasts. Through a comparative study of weather data
collected in Central Kerala from 2007 to 2015. We propose a system for
temperature prediction using three machine learning models. Multiple Linear
Regression (MLR), Artificial Neural Network (ANN), and Support Vector Machine
(SVM). We still have a century's worth of historical global temperature averages,
including global maximum and minimum temperatures, as well as global land and
ocean temperatures. Having all of this, we know that this is a supervised,
regression machine learning problem. Mean Error (ME), Mean Absolute Error
(MAE), and other metrics are used to assess the experimental outcomes.
3.6 ADVANTAGE AND DISADVANTAGE OF WEATHER FORECASTING

WEATHER FORECASTING
ADVANTAGES DISADVANTAGES
 Farmers can know when to  Weather is extremely difficult to
plant or harvest their crops forecast correctly
 People can choose where and  It is expensive to monitor-so
when to take their holidays to many variables from so many
take advantages of good sources
weather
 Surfers known when large  The computers needed to
waves are expected perform the millions of
calculations necessary are
expensive
 Regions can be evacuated if  The weather forecasters get
hurricanes or floods are blamed if the weather is
expected different from the forecast
 Aircraft and shipping rely  Weather is extremely difficult to
heavily on accurate weather forecast correctly
forecasting

3.7 PRACTICAL APPLICATIONS FOR WEATHER FORECASTING

 Systematic weather records were kept after the invention of the instruments
for measuring atmospheric conditions during the 17th century. Undoubtedly,
these early records were employed mainly by those engaged in agriculture.
 Planting and harvesting can be planned better and carried out more
efficiently if all the long-term weather patterns are estimated in advance.
 Weather warnings are a special kind of short-range forecasts. It is needed
for the protection of human life from weather extremes. Weather warnings
are issued by government and military organizations throughout the world
for all kinds of threatening weather events like tropical storms which are
called as hurricanes, typhoons, or tropical cyclones, depending on location.
3.8 APPLICATIONS IN VARIOUS FIELDS

There are a number of sectors with their own specific needs for weather forecasts
and specialist services are provided to these users.

AIR TRAFFIC:

 Accurate weather forecasting is critical in the aviation industry


because it is so weather-sensitive. Many planes are unable to land
or take off due to fog or very low ceilings. Turbulence and freezing
are two other major in-flight dangers.
 Thunderstorms cause extreme turbulence due to updrafts and
outflow boundaries, icing, and are a concern for all aircraft. Volcanic
ash is also a significant issue for aviation, as ash clouds can cause
aircraft to lose engine power.
 Airliners are diverted on a daily basis to take advantage of the jet
stream tailwind to increase fuel quality. Prior to take off, aircrews are
briefed on what to expect en route and at their destination.
Furthermore, airports often alter which runway is in use.

MARINE
 Wind direction and intensity, wave periodicity and heights, tides, and
precipitation can all restrict commercial and recreational use of
waterways. Any of these factors may have an effect on the safety of
marine transportation.
 As a result, a number of codes have been developed to effectively
transmit comprehensive marine weather forecasts to vessel pilots via
radio, such as the MAFOR (marine forecast) code.
 RTTY, Navtex, and Radiofax can all be used to receive standard
weather forecasts at sea.

AGRICULTURE

 Farmers use weather forecasts to determine what work they can do


on any given day. Drying hay, for example, is only possible in dry
weather. Dry spells will wreak havoc on cotton, wheat, and corn
crops.
 Drought can destroy corn crops, but their dried remains, known as
silage, can be used as a cattle feed substitute. Both in the spring and
the fall, frosts and freezes wreak havoc on crops. A spring freeze, for
example, will decimate the future peach crop of peach trees in full
bloom. Orange groves can be severely harmed by frosts and
freezes, regardless of when they occur.

FORESTRY
 Wind, precipitation, and humidity forecasting are critical for
preventing and managing wildfires.Various indices have been
created, such as the Forest fire weather index and the Haines
Index, to predict which areas are more likely to experience fire
due to natural or human causes.

UTILITY COMPANIES

 Rain forecasts are used by electricity and gas firms to predict


demand, which is heavily influenced by the weather. They
calculate the degree day to see how much heating (heating
degree day) or cooling (cooling degree day) can be used (cooling
degree day).
 These figures are based on a daily average temperature of 65
degrees Fahrenheit (18 degrees Celsius).Heating degree days
(one per degree Fahrenheit) are triggered by cooler
temperatures, whereas cooling degree days are triggered by
warmer temperatures.
 In the winter, when people turn up their heating, extreme cold
weather can cause a surge in demand. Similarly, increased use
of air conditioning systems in hot weather will lead to a rise in
demand in the summer. By foreseeing a spike in demand.

3.9 SUMMARY

The prediction method is in good working order. Many of the attribute values had
been correctly preprocessed. So all kinds of can use this application and get to
know the weather report easily without knowing the technical knowledge. This
application is very useful for professionals to analyse the temperature and rainfall
for monthly or yearly level. Blind people can handle this efficiently using speech
recognition.
CHAPTER 4

SYSTEM ANALYSIS AND DESIGN

4.1 GENERAL

4.1.1 PYTHON

Python is a widely used open-source Object oriented language that is especially


suited for Machine Learning, Data Science, Visualization and Gaming etc.., can be
design using tkinter like webpage.

4.1.2 USER INTERFACE (UI)

The user interface (UI) is the point of human-computer interaction and


communication in a device. This can include display screens, keyboards, a mouse
and the appearance of a desktop. It is also the way through which a user interacts
with an application or a website

4.2 SOFTWARE USED

4.2.1 CODE EDITOR USED

Python IDLE

IDLE is an integrated development environment for Python, which has been


bundled with the default implementation of the language since 1.5.2b1. It is
packaged as an optional part of the Python packaging with many Linux
distributions. It is completely written in Python and the Tkinter GUI toolkit.
4.2.2 PROGRAMMING LANGUAGE USED

Python 3.7

Python is an interpreter, high level, general programming language. Its formatting


is visually uncluttered, and it often uses English keywords where other languages
use punctuation. It provides a vast library for data mining and predictions.

4.2.3 ALGORITHMS USED

Linear Algorithm
Regression is a method of modeling a target value based on independent
prediction. This method is mostly used for forecasting and finding out cause and
effect relationship between variables. Regression techniques mostly differ based
on the member of independent variables and the type of relationship between the
independent and dependent variable.
Naïve Bayes Classification

Naïve bayes algorithm is a probability machine learning algorithm which can be


widely used in various classification tasks which is based on Bays theorem. The
term naïve is given because is assumes the data that is given so the model are
independent of each other, that is they have independent distribution. So, if we
change the value of one feature than it doesn’t affect the value of other features
used in the algorithm.

4.3 SYSTEM REQUIREMENT

 Operating System: Windows/Mac


 RAM: 4GB
 Processor: 64x 1.0Ghz processor
 ROM: 8GB
4.4 PREPROCESSING DATA

The steps involved in pre-processing are

Features selection

The data we have collected has many unwanted attributes which


will not be needed in our project. Hence, we use the attributes which we
need only.

Normalization

The data we collected from internet should be first normalized.


Normalization refers to rescaling real valued numeric attributes into the rage
or 0 and 1. After the data are filtered it is then normalized.

Machine Learning

Training a model is the process of iteratively improving your


prediction equation by looping through the dataset multiple times, each time
updating the weight and bias values in the direction indicated by the slope
of the cost function (gradient). Training is complete when we reach an
acceptable error threshold, or when subsequent training irritations fail to
reduce irritations.

4.4 FUNCTIONAL REQUIREMENTS

 The system must provide the predicted weather.


 The system must have an easy to use interface for using the system for all
the users.
 The Admin must be able to update/modify the Dataset.
 The Dataset of the weather must be available for the system.
4.5 DATA COLLECTION

The data of weather forecast was obtained from Kaggle. We took about 4000
trained data and 800 test data.

Parameters are:

 Temperature
 Pressure
 Humidity
 Dew point
 Rainfall
 Precipitation

4.4 PROJECT DESCRIPTION

The project aim is to show the weather report for everyone. This project used to
show the report for all attributes and user can easily know about the weather
forecast, chillness, sunset, sunrise etc…, According to that the user comes to
know weather problems. Here speech recognition also included for extra one
feature. Despite of the blind people also able to work with it. Using the API
included all kinds of weather attributes. From the data collection, we know the
weather report either current or specific city which is defined by users. The
Government can analyze every year or every month wise rainfall level in order to
that we can predict rainfall for future year or month. Based on comparing the
original versus predicted temperature the developers can find the difference of the
temperature.
4.4 WORKFLOW DIAGRAM

4.1 FIGURE
4.4.1 DATA FLOW DIAGRAM

4.2 FIGURE
4.4.2 FLOW DIAGRAM FOR SPEECH RECOGNITION

4.3 FIGURE

4.4.3 ALGORITHM FOR WEATHER REPORT

STEP 1: Import libraries

STEP 2: Using API can predict the weather report for current specific city once
enter the city name.

STEP 3: API URL:

"https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=06c921750b
9a82d8f5d1294e1586276f“

STEP 4: Using the Json to get data

STEP 5: Display the output


4.4 FIGURE

4.4.4 ALOGRITHM FOR LINEAR REGRESSION ( Temperature prediction)

STEP 1: Load the dataset into the python and import the libraries

STEP 2: Data pre-processing

Step 2.1: Drop the unnecessary column from the dataset

Step 2.2: Delete all values from te pressure which has a value -9999

Step 2.3: Taking all the features into x variable and y for prediction

Step 2.4: Set the dummies value as a level for the weather classification

Step 2.5: Delete last dummies value which is null


Step 2.6: Concatenate the dummies value with the input feature X

Step 2.7: Created the new dataset after apply the preprocess

STEP 3: Train and test the data

Step 3.1: Splitting Dataset into train set and test set

STEP 4: Fitting the Linear Regression model

STEP 5: Histogram of data (visualization)

STEP 6: Analyze the original with predicted data (using visualize)

STEP 7: Output

4.5 FIGRUE
4.4.5 ALGORITHM FOR RAINFALL PREDICTION

STEP 1: Load the data and import libraries

STEP 2:Replace the value for ‘RainToday’ and ‘RainTomorrow’ columns with
(No:0, yes:1)

STEP 3: Visualize the data

STEP 4: Output

4.5 DATASET CLASSIFICATION

4.5.1 DATASET FOR TEMPERATURE

4.6 FIGURE
4.5.2 DATASET FOR RAINFALL

4.7 FIGURE
CHAPTER 5

CONCLUSION AND FUTUTE WORK

5.1 PROJECT OUTLOOK

A weather prediction goal is show the weather report for everyone. This project
used to show the report for all attributes and user can easily know about the
weather forecast, chillness, sunset, sunrise etc…, According to that the user
comes to know weather problems. Here speech recognition also included for
extra one feature. Despite of the blind people also able to work with it. Using the
API included all kinds of weather attributes.

5.2 CONCLUSION

Weather forecasting using the linear regression algorithm and the Naïve Bayes
algorithm is critical for improving people’s future results. The linear regression
algorithm and the Naïve Bayes algorithm were used to forecast the weather using
weather datasets. Using some selected input variables obtained from kaggle,
GitHub we created a model to predict the weather. The issue with the current
weather situation is that we are unable to organize ourselves and complete
essential tasks. As a result, this model was developed in order to know the
weather scenario with high precision while taking into account all of the factors that
influence the weather scenario.

5.3 FUTURE WORK


A weather prediction technology can stipulate university growth and development.
The scope magnitude of change that are occurring in department today are both
exciting and daunting, very particularly we are contemplating how we will manage
the many streams of technological innovations pouring into our department and
networked information world. All the social medias combine to create one. This
application should need to know to avoid natural disaster. To overcome that
problem we have improve this to advanced features included. And then using
speech recognition we need to pronounce correctly or else it will not work
correctly. So that need to improve without this critical.

REFERENCES

 Weather: Forecasting from the Beginning". InfoPlease. Retrieved January


14, 2020.
 University of California Museum of Paleontology. "Aristotle (384-
322 B.C.E.) Archived November 20, 2016, at the Wayback Machine".
Retrieved January 12, 2008.
 David Pingree (December 14, 2017). "The Indian and Pseudo-indian
Passages in Greek and Latin Astronomical and Astrological Texts"(PDF).

 pp. 141–195 [143–4]. Retrieved March 1, 2010.[permanent dead link]


 Bible Gateway passage: Matthew 16:2-3 - English Standard Version". Bible
Gateway. Retrieved December 1, 2016.
 Further Reading - Ian Roulstone & John Norbury (2013). Invisible in the
Storm: the role of mathematics in understanding weather.
APPENDIX
SOURCE CODE

Grid.py
[1] from tkinter import *
[2] #import speech
[3] import speech_recognition as sr
[4] import pyttsx3
[5]
[6] def weather():
[7] import Api
[8] Api.mains()
[9] def tomorrow():
[10] import rainfall
[11] rainfall.possible_rain()
[12] def analyze():
[13] import rainfall
[14] rainfall.analyze()
[15] def pred():
[16] import temp
[17] temp.predict()
[18] def ori():
[19] import temp
[20] temp.original()
[21]
[22]
[23]
[24] def main():
[25] root = Tk() #makes a blank popup, under the variable name 'root'
[26]
[27] topFrame = Frame(root,bg="#837E7C")
[28] root.geometry("1000x900")
[29] topFrame.pack()
[30] bottomFrame = Frame(root)
[31] bottomFrame.pack(side=BOTTOM)
[32] root.title("Weather App")
[33] root.configure(bg='#2C3539')
[34] f = ("poppins", 15, "bold")
[35] t = ("poppins", 35, "bold")
[36] label1 = Label(topFrame,borderwidth = 1,font = t)
[37] label1.pack()
[38] title = "\n" + "WEATHER REPORT " + "\n"
[39] label1.config(text = title,foreground = "white",bg="#837E7C",width = 20)
[40]
[41] button3 = Button(topFrame, text='Analyze avarage rainfall every month
for india', fg='green',command = analyze,font = f,bg='#0C090A')
[42] button1 = Button(topFrame, text='Current weather report for specific
city..........',command = weather, fg='red',font = f,bg='#0C090A')
[43] button2 = Button(topFrame, text='Do you need to predict rainfall
tomorrow......?', fg='blue',command = tomorrow,font = f,bg='#0C090A')
[44] button4 = Button(topFrame, text='Predict the temparature for
year....................', fg='pink',command = pred,font = f,bg='#0C090A')
[45] button5 = Button(topFrame, text='original vs prected
temparature....................', fg='yellow',command = ori,font = f,bg='#0C090A')
[46]
[47]
[48] button5.pack(side=BOTTOM,padx=20, pady=20)
[49] button4.pack(side=BOTTOM,padx=20, pady=20)

[50] button2.pack(side=BOTTOM,padx=20, pady=20)


[51] button3.pack(side=BOTTOM,padx=20, pady=20)
[52] button1.pack(side=BOTTOM,padx=20, pady=20)
[53] root.mainloop() #loops the program forever until its closed
[54] listener = sr.Recognizer()
[55] engine = pyttsx3.init()
[56] voices = engine.getProperty('voices')
[57] engine.setProperty('voice',voices[1].id)
[58] engine.say("Hi I am alexa")
[59] engine.say("Are you blind")
[60] engine.runAndWait()
[61] count = 0
[62] def talk(text):
[63] engine.say(text)
[64] engine.runAndWait()
[65] def take():
[66] try:
[67] with sr.Microphone() as source:
[68] print("Listening.....")
[69] voice = listener.listen(source)
[70] command = listener.recognize_google(voice)
[71] command = command.lower()
[72] print(command)
[73] except:
[74] command = 'pls say correctly'
[75] return command
[76]
[77] def run_alexa(count):
[78] if count == 1:
[79] talk("say yes or no")
[80] else:
[81] talk("Do you want again")
[82] command = take()
[83] if 'yes' in command or 's' in command:
[84] talk("What is your query")
[85] command = take()
[86] if 'city' in command:
[87] weather()
[88] elif 'tomorrow' in command:
[89] tomorrow()
[90] elif 'analyze' in command:
[91] analyze()
[92] elif 'predict' in command:
[93] pred()
[94] elif 'original' in command:
[95] ori()
[96] else:
[97] main()
[98] while True:
[99] count += 1
[100] run_alexa(count)
Main.py

[101] from PIL import Image, ImageTk


[102] import tkinter as tk
[103] def answer(canvas):
[104] city = textField.get()
[105] if city == '1':
[106] import Api
[107]
[108] elif city == '2':
[109] import rainfall
[110] rainfall.possible_rain()
[111] elif city == '3':
[112] import rainfall
[113] rainfall.analyze()
[114]
[115]
[116] if __name__ == "__main__":
[117]
[118]
[119] canvas = tk.Tk()
[120] canvas.title("Weather App")
[121] canvas.configure(bg='#6b8e23')
[122] f = ("poppins", 15, "bold")
[123] t = ("poppins", 35, "bold")
[124] label1 = tk.Label(canvas,borderwidth = 1,font=f)
[125] label1.pack()
[126] title = "\n" + "WEATHER REPORT " + "\n"
[127] swi = "\n" +
"***********************************************************************"
[128] switch = title + swi + "\n" + "1:Current weather report for specific city " +
"\n" + swi + "\n" + "2:Do you need to predict rainfall tomorrow?" + "\n" + swi +
"\n"+ "3:Analyze the avarage rainfall every month for india"
[129] label1.config(text = switch,foreground = "white",bg="#6b8e23")
[130]
[131] textField = tk.Entry(canvas, justify='center', width = 20, font = t,
foreground="red")
[132] textField.configure(bg="#C04000", insertbackground='black')
[133] textField.pack(pady = 20)
[134] textField.focus()
[135] textField.bind('<Return>', answer)
[136]
[137] #label2 = tk.Label(canvas, font=f)
[138] #label2.pack()
[139]
[140] canvas.mainloop()
Api.py

[141] import tkinter as tk


[142] import requests
[143] import time
[144]
[145]
[146] def getWeather(canvas):
[147] city = textField.get()
[148] api =
"https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=06c9217
50b9a82d8f5d1294e1586276f"
[149]
[150] json_data = requests.get(api).json()
[151] condition = json_data['weather'][0]['main']
[152] temp = int(json_data['main']['temp'] - 273.15)
[153] min_temp = int(json_data['main']['temp_min'] - 273.15)
[154] max_temp = int(json_data['main']['temp_max'] - 273.15)
[155] pressure = json_data['main']['pressure']
[156] humidity = json_data['main']['humidity']
[157] wind = json_data['wind']['speed']
[158] sunrise = time.strftime('%I:%M:%S',
time.gmtime(json_data['sys']['sunrise'] - 21600))
[159] sunset = time.strftime('%I:%M:%S', time.gmtime(json_data['sys']['sunset']
- 21600))
[160]
[161] final_info = condition + "\n" + str(temp) + "°C"
[162] final_data = "\n"+ "Min Temp: " + str(min_temp) + "°C" + "\n" + "Max
Temp: " + str(max_temp) + "°C" +"\n" + "Pressure: " + str(pressure) + "\n"
+"Humidity: " + str(humidity) + "\n" +"Wind Speed: " + str(wind) + "\n" +
"Sunrise: " + sunrise + "\n" + "Sunset: " + sunset
[163] label1.config(text = final_info,foreground = "white",bg="#8C001A")
[164] label2.config(text = final_data,foreground = "white",bg="#8C001A")
[165]
[166]
[167] canvas = tk.Tk()
[168] canvas.geometry("600x500")
[169] canvas.configure(bg='#8C001A')
[170] canvas.title("Weather App")
[171] f = ("poppins", 15, "bold")
[172] t = ("poppins", 35, "bold")
[173] label3 = tk.Label(canvas,borderwidth = 4,font=f)
[174] label3.pack()
[175] switch = "\n" + "Enter your city:" + "\n"
[176] label3.config(text = switch,foreground = "white",bg="#8C001A")
[177] textField = tk.Entry(canvas,justify='center', width = 20, font =
t,foreground="white")
[178] textField.configure(bg="#C04000", insertbackground='black')
[179] textField.pack(pady = 20)
[180] textField.focus()
[181] textField.bind('<Return>', getWeather)
[182]
[183] label1 = tk.Label(canvas, font=t)
[184] label1.pack()
[185] label2 = tk.Label(canvas, font=f)
[186] label2.pack()
[187] canvas.mainloop()
temp.py

[188] import matplotlib.pyplot as plt


[189] import pandas as pd
[190] import numpy as np
[191]
[192] dataset=pd.read_csv('subdataset(1000data).csv')
[193]
[194] #print(dataset.head(5))
[195]
[196] dataset.drop([" _heatindexm"],axis=1,inplace=True)
[197] dataset.drop([" _precipm"],axis=1,inplace=True)
[198]
[199] dataset.dropna(inplace=True)
[200] dataset.drop(["datetime_utc"],axis=1,inplace=True)
[201] #delete all values from the pressure which has a value -9999
[202] indexn=dataset[dataset[' _pressurem']==-9999].index
[203] dataset.drop(indexn,inplace=True)
[204] #taking all the features into x variable and y for prediction
[205] Y=dataset.iloc[:,len(dataset.columns)-1]
[206] X=dataset.iloc[:,0:len(dataset.columns)-1]
[207] '''
[208] print("Prediction data for x and y:")
[209] print(' prediction data for Y\n',Y)
[210] print()
[211] print('prediction data for X\n',X)
[212] '''
[213] #set the dummies value as a level for the weather clasification
[214] weather_condition=pd.get_dummies(X[' _conds'])
[215] #delete last dummies value which is null
[216] weather_condition.drop(["Unknown"],axis=1,inplace=True)
[217] print("After did the Normalization:\n\n",weather_condition.head(10))
[218] #concat the dummies value with the input feature X
[219] X=pd.concat([X,weather_condition],axis=1)
[220]
[221] print(X.head(10))
[222] X.drop([" _conds"],axis=1,inplace=True)
[223] print(X.shape)
[224] #now final data set has been created
[225] print("After finished pre-procession and create filter dataset:\n\n\n")
[226] print(X.head(10))
[227]
[228] ############################################################
#########
[229]
[230] # train and testing
[231]
[232] from sklearn.model_selection import train_test_split
[233] from sklearn.linear_model import LinearRegression
[234] from sklearn.metrics import r2_score
[235] def predict():
[236] #splitting Dataset into train set and test set
[237]
X_train,X_test,y_train,y_test=train_test_split(X,Y,test_size=0.2,random_state=
0)
[238] model=LinearRegression()
[239] model.fit(X_train,y_train)
[240]
[241] y_prediction=model.predict(X_test)
[242]
[243] score=r2_score(y_test,y_prediction)
[244]
[245] print("Temprature prediction Accuracy= ",score*100)
[246]
[247] #histogram of data how they looks like on graphical represantation
[248]
plt.hist(y_prediction,facecolor='red',edgecolor='blue',bins=10,range=(5,35))
[249] plt.title("predicted temprature histogram")
[250] plt.show()
[251]
[252]
[253] def original():
[254] # original temprature vs predicted temprature graph
[255]
X_train,X_test,y_train,y_test=train_test_split(X,Y,test_size=0.2,random_state=
0)
[256] model=LinearRegression()
[257] model.fit(X_train,y_train)
[258]
[259] y_prediction=model.predict(X_test)
[260]
[261] score=r2_score(y_test,y_prediction)
[262]
[263]
[264] plt.plot(y_test)
[265] plt.plot(y_prediction)
[266] plt.title('original temprature vs temprature')
[267] plt.xlabel("------------x-axis-------------")
[268] plt.ylabel("------------y-axis-----------")
[269] plt.legend()
[270] plt.show()
[271] #predict()
[272] original()

rainfall.py

[273] import pandas as pd


[274] import matplotlib.pyplot as plt
[275] df = pd.read_csv('weatherAUS.csv')
[276] print(df.head(5))
[277] print(df.columns)
[278] df['RainToday'].replace({'No': 0, 'Yes': 1},inplace = True)
[279] df['RainTomorrow'].replace({'No': 0, 'Yes': 1},inplace = True)
[280] def possible_rain():
[281]
[282] fig = plt.figure(figsize = (8,5))
[283] df.RainTomorrow.value_counts(normalize = True).plot(kind='bar', color=
['skyblue','navy'], alpha = 0.9, rot=0)
[284] plt.title('RainTomorrow Indicator No(0) and Yes(1) in the Imbalanced
Dataset')
[285] plt.show()
[286]
[287] def datatype():
[288] fig, axarr = plt.subplots(1, 2, figsize=(20, 8))

[289]
df.dtypes.value_counts().plot.pie(explode=[0.1,0.1],autopct='%1.1f%%',shadow
=True,ax=axarr[1])
[290] axarr[1].set_title("type of our data ", fontsize=18)
[291]
[292] df.dtypes.value_counts().plot(kind='bar',ax=axarr[0])
[293] plt.title('type of our data');
[294] axarr[0].set_title("type of our data ", fontsize=18)
[295] plt.show()
[296]
[297] def analyze():
[298] data = pd.read_csv("Weather Data in India from 1901 to 2017.csv")
[299] # Average monthly rainfall in India
[300] ax=data[['JAN', 'FEB', 'MAR', 'APR','MAY', 'JUN', 'AUG', 'SEP',
'OCT','NOV','DEC']].mean().plot.bar(width=0.5, linewidth=2, figsize=(16,10))
[301] plt.xlabel('Month',fontsize=30)
[302] plt.ylabel('Monthly Rainfall (in mm)', fontsize=30)
[303] plt.title('Monthly Rainfall in Subdivisions of India', fontsize=25)
[304] ax.tick_params(labelsize=10)
[305] plt.grid()
[306] plt.show()
OUTPUT

USING SPEECH RECOGNITION

6.1 FIGURE
FOR NORMAL USER

6.2 FIGURE
DASHBOARD

6.3 FIGURE

WEATHER REPORT
6.4 FIGURE

MONTHLY RAINFALL ANALYZE

6.5 FIGURE
RAINFALL PROBABILITY

6.6 FIGURE

TEMPERATURE PREDICTION
6.7 FIGURE

COMPARING ORIGINAL VS PREDICTED TEMPERATURE

6.8 FIGURE

You might also like