Last active
February 6, 2020 20:37
-
-
Save HenkPoley/0efe9d17187730217158de6901f93140 to your computer and use it in GitHub Desktop.
2019-nCoV prediction
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
#!/usr/bin/env python | |
# Not meant to teach proper Python, or statistics, but it works | |
import warnings | |
import numpy | |
import scipy.stats | |
x = numpy.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]) | |
y = numpy.array([4515.0, 5974.0, 7711.0, 9692.0, 11791.0, 14380.0, 17205.0, 20438.0, 24324.0, 28018.0]) | |
z = numpy.polyfit(x,y,2) | |
print("ax^2 + bx + c: " + str(z[0]) + " * x^2 + "+ str(z[1]) + " * x + " + str(z[2])) | |
p = numpy.poly1d(z) | |
# p(1) | |
# p(2) | |
predictions = numpy.array([p(1), p(2), p(3), p(4), p(5), p(6), p(7), p(8), p(9), p(10)]) | |
slope, intercept, r_value, p_value, std_err = regres_result = scipy.stats.linregress(y, predictions) | |
print(regres_result) | |
# Nonsense | |
# adjusted_r_squared = (1-(1-r_value) * ((10-1)/(10-3-1))) | |
# print("Adjusted R squared: " + str(adjusted_r_squared)) | |
# print("Remaining unexplained variance: " + str((1 - adjusted_r_squared) * 100) + "%") | |
print("") | |
print("Predictions:") | |
print("Feb 7: " + str(p(11))) | |
print("Feb 8: " + str(p(12))) | |
print("Feb 9: " + str(p(13))) |
Made the script because of these tweets: https://twitter.com/evdefender/status/1225408294585393153
Just from playing with my script a bit, I don't think these statistical methods are appropriate for this limited dataset.
Easy to make a higher order polyfit with an R^2 that approaches 1, and super low p values, but get silly predictions.
But, ehh, I had limited stats edu.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current output of this script: