Last active
December 8, 2020 17:56
-
-
Save clayh53/88136e3661fe6c18c3b9d431c4386b64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import r2_score | |
# create columns of 14 day smoothed data | |
start_R_calc = 192 # index value for Aug 1 2020 | |
end_R_calc = 316 # index for last 'real' data day at time of writing | |
df['deathIncrease-14daysmoothed'] = df['deathIncrease'].rolling(window=rolling_avg).mean() | |
df['predicted_Death-14daysmoothed'] = df['predicted_death'].rolling(window=rolling_avg).mean() | |
model = df[start_R_calc:end_R_calc]['deathIncrease-14daysmoothed'] | |
prediction = df[start_R_calc:end_R_calc]['predicted_Death-14daysmoothed'] | |
R2 = r2_score(model,prediction) | |
print(f"R^2 Analysis start date is {df.loc[start_R_calc,'date']:%m %d %Y}") | |
print(f"R^2 value is {R2:.2f}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment