Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to predict epidemic situation

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use Python to predict the epidemic situation, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let the editor take you to know it.

1. Preparatory work

Programming environment: Spyder under anaconda.

Data source: compiled from the official website of the National Health Commission.

The dependent libraries that need to be installed are: scipy. Scipy is an open source scientific computing library for mathematics, science and other fields. It is based on Numpy and can be used to deal with integration, optimization, numerical solution of ordinary differential equations, signal processing and other problems. This paper is mainly used for function fitting.

two。 Algorithm flow

1)。 Theoretical explanation

At present, the commonly used methods to predict the cumulative number of diagnosed COVID-19 are the infectious disease model based on SIR and the method based on Logistic equation. The implementation of SIR model is relatively complex, this paper will be based on a simpler model-using Logistic equation for prediction.

Logistic equation can be used to describe the species growth model, when a species moves into a new ecosystem, if the species has survival resistance in the non-ideal ecosystem (natural enemies, shortage of food, space and other resources, etc.), the number of species roughly shows an S-shaped growth. It began to produce a slow growth period, slowly showing an exponential outbreak, and gradually stabilized with the change of environmental resistance in the later stage.

The function can be expressed as:

The meaning of the parameter is as follows:

: indicates the number of species in the environment over time.

Represents the limit that species can reach in the environment.

: indicates the number of species at the beginning of the environment.

It represents the growth rate, and what is shown in the graph is the steepness of the curve. The greater the number of species, the faster the number of species approaches the N value.

: represents the time.

2)。 Program realization

In the program, we first define the function to be fitted, then obtain the data of the number of people with "cumulative diagnosis", and use the curve_fit () function to fit the parameters to get the parameters that need to be fitted. Finally, the fitting curve and the actual number of diagnosed patients are displayed in the same picture, and the effect of the model is observed intuitively.

Through the Logistic equation fitting of the data from January 20 to February 8, the predicted data are in good agreement with the actual data from February 9 to 11. But on February 12th, there was a sudden surge in official data, which invalidated our model.

In readjusting the training data, we choose the data from January 20 to February 26 as the training data, and the February 27-28 data as the control data, we can get a new fitting curve, and the predicted values are relatively consistent with the actual values.

Thank you for reading this article carefully. I hope the article "how to use Python to predict epidemic situation" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report