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 realize the data Prediction of birth rate in Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is about how to achieve the birth rate data prediction in Python. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

1. Prepare for

The data are as follows, we only take the birth rate as our data set.

two。 Data prediction

In the following tutorial, you have installed Python by default and can use pip in CMD or Terminal. If not, please see this article: install python, same as the sales forecast of Tmall in 2019 in the previous section, there is not much change, but we need to find the most suitable curve instead of using a ternary regression curve:

2.1 data preprocessing

The cubic polynomial feature needs to be in the form of columns, so the numpy array reshape will be in column form in the code.

2.2 data Visualization

Display the existing data and use the blue dot as a mark to display the Abscissa of each year. The curve we start from the binary regression curve to find the curve that is most in line with the data trend.

The result of running the code is as follows:

Obviously, the binary regression curve is not very suitable for these data, and many points are distributed far away from the straight line. Let's try the ternary regression curve and modify the degree of the poly_reg variable to 3:

Poly_reg = PolynomialFeatures (degree=3)

The results are as follows:

If it feels a little spicy, try the quaternary regression curve again:

It is found that there is not much change compared with the ternary regression curve, so we can choose the ternary regression curve for prediction.

2.3 data modeling and prediction

The predicted birth rate of 2019 people is: [11.25692317]. The predicted value is represented by a yellow dot, and the resulting graph is as follows:

The above is how to achieve the birth rate data forecast in Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report