当前位置:网站首页>Analysis of regression problem, modeling and prediction
Analysis of regression problem, modeling and prediction
2022-07-25 18:19:00 【Tomorrowave】
List of articles
What is regression analysis
Give you a series of related data , There is such an internal relationship between independent variables and dependent variables , Then by processing these data , Use mathematical methods to model linear equations , Then finally through the model you build , Predict independent variables that are not provided to
So what is prediction ?
Prediction , Is to use a trained model , According to the input arguments Get the corresponding output . In the prediction task , If the model Can accurately provide forecasts , that It doesn't matter what form it is , And if the The form of is very complex and difficult to explain , We can call it black box model (Black Box).
For example , hypothesis Xi It is the blood sample characteristics of a patient , The risk of serious adverse reactions after drug use was measured , So if there is a model that can pass well Xi To predict Yi , That's naturally the best thing . here , Form of model 、 The relationship between variables is not so important in the face of correct prediction .
What is inference ?
In many cases , We are right when X How does the change of affect Y More interested in , here , We estimate the model The purpose of is not to predict , But to understand the relationship between the two
linear regression model
y = x + u y=x+u y=x+u
further
y = a 0 + ∑ i = 1 n a i x i y=a_0+\sum^{n}_{i=1}a_ix_i y=a0+i=1∑naixi
One dimensional linear model
y = a 0 + a 1 x 1 + u y=a_0+a_1x_1+u y=a0+a1x1+u
a 0 Is the intercept term , It can be understood as x = 0 When y The expectations of the , a 1 It can be understood as x Every additional unit , y Average increase a 1 A unit of a_0 Is the intercept term , It can be understood as x=0 When y The expectations of the ,a_1 It can be understood as x Every additional unit ,y Average increase a_1 A unit of a0 Is the intercept term , It can be understood as x=0 When y The expectations of the ,a1 It can be understood as x Every additional unit ,y Average increase a1 A unit of
Least square method
import statsmodels.api as sm
model = sm.OLS(endog, exog=None, missing='none', hasconst=None, **kwargs)
''' Parameters endog: array_like A one-dimensional dependent variable . exog: array_like By default , Intercept is not included , It should be added by the user . Use statsmodels.tools.add_constant add to . missing: str The available options are 'none'、'drop' and 'raise'. If 'none', Do not carry out nan Check . If 'drop', Then discard any use nan The observations . If 'raise', Throw an error . The default is 'none'. hasconst: None or bool instructions RHS Whether to include constants provided by users . If True, Then the constant is not checked ,k_constant Set to 1, And calculate all the result statistics , Just like there is a constant . If False, Then the constant is not checked , And will k_constant Set to 0. **kwargs Additional parameters used to set model properties when using the formula interface . '''
Normal distribution
from scipy.stats import norm
import numpy as np
# Generate an average of 1, The variance of 2 Is a normal distribution
distribution=norm(loc=1.0, scale=2.0)
# Show mean and variance
print(distribution.stats())
# sampling
samples=distribution.rvs(size=1000)
# The mean value of the sample and the difference between the labels
print(np.mean(samples), np.std(samples))
# Fit the data
print(norm.fit(samples))
边栏推荐
- Why the future of digitalization depends on 3D real-time rendering
- PHP memory management mechanism and garbage collection mechanism
- 网易严选库存中心设计实践
- Cve-2022-33891 Apache spark shell command injection vulnerability recurrence
- STM32F105RBT6 内部flash调试
- SQL things
- 专访即构科技李凯:音视频的有趣、行业前沿一直吸引着我
- Landmark buildings around the world
- 使用sqldeveloper连接mysql
- C语言 整数与字符串的相互转换
猜你喜欢

超全Mavan标签详解

想要做好软件测试,可以先了解AST、SCA和渗透测试

Wu Enda's machine learning programming operation cannot be suspended pause problem solved

结合GHS MULTI使用瑞萨E1仿真器实现对瑞萨RH850单片机的仿真调试

Cloud VR: the next step of virtual reality specialization

Why the future of digitalization depends on 3D real-time rendering

Today's sleep quality record is 84 points

Oracle导入出错:IMP-00038: 无法转换为环境字符集句柄

CVE-2022-33891 Apache spark shell 命令注入漏洞复现
SQL optimizer parsing | youth training camp notes
随机推荐
Drawing PDF form (II) drawing excel form style in PDF through iText, setting Chinese font, watermark, logo, header and page number
11.1-CM24 最近公共祖先
testng执行顺序的3中控制方法
Which real-time gold trading platform is reliable and safe?
7. 依赖注入
php内存管理机制与垃圾回收机制
如何创建一个有效的帮助文档?
Three control methods of TestNG execution sequence
CVE-2022-33891 Apache spark shell 命令注入漏洞复现
Use of stm8s003f3 UART
uniapp滚动条置顶效果、自定义页面滚动条的位置(整理)
C语言 整数与字符串的相互转换
Oracle uses impdp import to report an error: ora-39001: invalid parameter value ora-39000: dump file description error ora-39088: file name cannot contain path description
Chapter 5 Basic Scripting: Shell Variables
遍历数组的方法有哪些?for循环 forEach for/in for/of map的性能又有什么差别 该如何选择?
OV7725 yuv 640* [email protected] Profile
What is the relationship between cloud fluidization and cloud desktop
TESTNG中的并发测试invocationCount, threadPoolSize, timeOut的使用
Stm8s003f3 internal flash debugging
Thales launches solutions to help SAP customers control cloud data