I am trying to build a GLM model (poisson family) using python statsmodels package on train data. The data I have contains categorical values as exogenous variables and numerical values for my target (endegenous variable). I did standardization for numeric values and one-hot-encoding on categorical values (drop the first level). When I fit the data into the model, I got the following exceptions :
ValueError: NaN, inf or invalid value detected in endog,
The error comes when creating this model :
poisson_model = sm.GLM(endog=y_train, exog=X_train_std,
offset = np.log(X_train_std.EXPOSITION))
The problem comes from np.log(X_train_std.EXPOSITION) since I can not apply log function on zero values. But I don't know how to correct the error. I need to take into consideration the offset and when changing its link function to identy I get EXPOSITION in the GLM output.
Any help please ? How to deal with offset that takes 0 values with a log link function ?