In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to achieve nonlinear regression in python, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Nonlinear regression analysis by python
Use matplotlib to visualize the scatter plot.
Csv files with date-dependent number of infections
The code is as follows:
From pandas import read_csv
Import matplotlib.pyplot as plt
Plt.rcParams ['font.family'] =' SimHei'# solves Chinese fonts
Data=read_csv ('FRV 2.csventing camera encodingless GBK')
Plt.scatter (data. Date, data. Number of infections)
Data.corr ()
LrModel=LinearRegression ()
X=data [['date']]
Y=data [['number of infections']]
Plt.scatter (XBI y)
Plt.xlabel ('date ordinal')
Plt.ylabel ('number of infections')
Plt.show ()
The result is as shown in the picture (I will take March 11 as my first day)
According to the figure is very close to the quadratic function and the cubic function, I choose to use the cubic function to fit. The code is as follows:
From sklearn.preprocessing import
PolynomialFeatures as pf
Pd=pf (degree=3)
X1=pd.fit_transform (x)
Irmodle=LinearRegression ()
Irmodle.fit (x1BI y)
A=irmodle.score (x1BI y)
B=pd.fit_transform ([[18]])
C=irmodle.predict (b)
Print (a)
Print ("estimated number of infections in 3 / 29 days", irmodle.predict (pd.fit_transform ([17])
Print ("estimated number of infections in 3 / 30 days", c)
Print ("estimated number of infections in March / 31 is", irmodle.predict (pd.fit_transform ([19])
Print ("estimated number of infections per 4 / 1 day", irmodle.predict (pd.fit_transform ([[20]])
The results are as follows:
On how to achieve nonlinear regression in python to share here, I hope that 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.