I am doing a Poisson regression of sample_df["vaccination_count"] over sample_df["Uninsured"] here and need to understand how would I use the sample_df["population"] column as an offset to the regression. Where could I add the sample_df['population'] as an offset to the PoissonRegressor()
import numpy as np
import matplotlib.pyplot as plt # To visualize
import pandas as pd
from sklearn.linear_model import PoissonRegressor
import matplotlib.pyplot as plt
sample_df=pd.read_csv('test.csv')
sample_df['vaccination_count'].fillna(sample_df['vaccination_count'].mean(), inplace=True)
Y=(sample_df['vaccination_count'].values.reshape(-1,1))
X=sample_df['Uninsured'].values.reshape(-1,1)
X.reshape(46,1)
Y.reshape(46,1)
regr=PoissonRegressor()
regr.fit(X, Y)
plt.figure()
fig = plt.gcf()
fig.set_size_inches(5,5)
plt.plot(X, regr.predict(X), color='blue', linewidth=1)