I was wondering what the correct way is to pass the columns in a fit function. For example, I have:
# Lin. regression
lin_reg = LinearRegression().fit(data[["X"]],
data[["Y"]])
#Poisson regression
log_reg = PoissonRegressor().fit(data[["X"]],
data.loc[:, "Y"])
So in the linear regression, the lines presented above just work, even though I pass the y-column as data[["Y"]]. If I were to do that in the poisson regression (e.g. see below).
log_reg = PoissonRegressor().fit(data[["X"]],
data[["Y"]])
It would give a warning "A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().".
Now, I would like to know what the proper way is to pass the y-value to scikit-learn and how it comes that the linear regression does not cause any problems.
I am fully aware that data[["Y"]] results in a dataframe, so I guess that is the difference, but I am not sure why the linear regression would accept a dataframe while the poisson regression does not.
Therefore, what is the proper way to pass an y-value to scikit learn.