In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use Facebook's Prophet to predict air quality. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
It is difficult for many machine learning engineers to make high-quality predictions. It requires a great deal of experience and very specific skills. In addition, other forecasting tools are too inflexible to incorporate useful assumptions.
For these reasons, Facebook is open source Prophet, a forecasting tool provided in Python and R. The tool allows experts and non-experts to generate high-quality predictions with minimal effort.
Here, Prophet will be used to help us predict air quality!
Import and clean up data
As usual, import some useful libraries first:
Then import the dataset and preview it:
You should see the following:
The first five entries of the dataset
As you can see, the dataset contains information about different gas concentrations. Record it every hour every day. You can find descriptions of all features here.
Https://www.kaggle.com/sayakchakraborty/air-quality-prediction-of-relative-humidity
If you browse the dataset more, you will notice that there are many instances with a value of-200. Of course, negative sets don't make sense, so you need to clean up the data before modeling.
First, get rid of all instances where null values exist:
After that, you need to resolve the date column to a date and convert all measurements to floating-point numbers:
Then, summarize the data by day by taking the average of each measurement:
At this point, the data should look like this:
There are also some NaN to get rid of. You can see how many NaN there are in each column:
Get rid of columns that exceed 8 NaN:
Perfect! It is time to summarize the data on a weekly basis because it gives a smoother analytical trend.
Great! Now we are ready to explore more data.
Exploratory data analysis (EDA)
Draw each column of the dataset:
Take the time to look at each plot and identify interesting trends. Only the concentration of NOx is considered for length.
Nitrogen oxides are very harmful because they react to form smoke and acid rain and are responsible for the formation of fine particles and surface ozone. These have adverse effects on health, so the concentration of NOx is a key feature of air quality.
So before continuing with modeling, delete all unrelated columns:
Modelling
First import Prophet:
Then, Prophet requires that the date column be named ds and the prime column be named y:
Now, the data should look like this:
Then, define a training set. The last 30 entries for prediction and validation will be retained for this purpose.
Then, simply initialize the Prophet, make the model fit the data, and make predictions!
You should see the following:
Here, yhat represents the forecast, while yhat_lower and yhat_upper represent the lower and upper limits of the forecast, respectively.
Prophet allows you to easily draw predictions:
Get:
NOx concentration prediction
As you can see, Prophet simply uses a straight line down the line to predict future NOx concentrations.
You can also use the command to see if the time series has any interesting features, such as seasonality:
Get:
Here, Prophet only sees a downward trend that is not seasonal.
Now, the performance of the model is evaluated by calculating the average absolute percentage error (MAPE) and the average absolute error (MAE) of the model:
You should see that MAPE is 13.86% and MAE is 109.32, which is not so bad! Keep in mind that the model is not fine-tuned at all.
Finally, the prediction is drawn with its upper and lower limits:
Get:
Prediction of weekly average NOx concentration
On how to use Facebook Prophet to predict air quality is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.