[英]separating dependent and independent variables
I have built a linear regression model but don't know what is the need to separate dependent and independent variables我已经建立了一个线性回归 model 但不知道需要分离因变量和自变量
can someone explain the code??有人可以解释代码吗?
x = data.iloc[:, 0:1].values
y = data.iloc[:, 1]
A machine learning model simply works this way: you give it a bunch of inputs and outputs.机器学习 model 就是这样工作的:你给它一堆输入和输出。 Then, when a model is trained, when you give it an input, you expect an output.
然后,当训练 model 时,当你给它一个输入时,你期望得到一个 output。
So in the code you gave, x
is input, and y
is output, to train the model.因此,在您给出的代码中,
x
是输入, y
是 output,以训练 model。 AFAIK, most machine learning frameworks expect inputs and outputs seperately (eg: Keras' fit method ). AFAIK,大多数机器学习框架都期望输入和输出是分开的(例如: Keras 的拟合方法)。 Thus you seperate them before feed into the model.
因此,您在输入 model 之前将它们分开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.