Fitting COVID-19 data to the logistic function [2/2]

  Рет қаралды 2,573

Greg Winther

Greg Winther

4 жыл бұрын

I build a toolbox for easily fitting COVID-19 data to a logistic function. The same principles can easily be applied to any function and data.
The python script and data can be found here:
github.com/gregwinther/youtube
Sorry for a weird aspect ratio in this video. I blame my quarantine setup.

Пікірлер: 20
@user-nn1cm6lx2c
@user-nn1cm6lx2c 4 жыл бұрын
i also enjoy and learn a lot from your channel, thank you sir!!
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
Glad to hear that!
@atriarian
@atriarian 4 жыл бұрын
now, this is what I expect youtube algorithm to suggest. keep up!
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
Thanks, will do!
@p.t.g.b.8785
@p.t.g.b.8785 4 жыл бұрын
Please more python videos. I really enjoy them.
@basic-games621
@basic-games621 4 жыл бұрын
how to code and change states from S to E and E to I and I to R ? in python
@fun3s
@fun3s 4 жыл бұрын
Hey Greg, enjoying your videos. I followed what you did, and using the json file from your github, I got pretty much (considering time-lapse) same results as in the video. However, trying for Norway, the fitted curve seems to be a constant (x = constant). Why do you think that is? Also for spain data, I get an overflow warning for np.exp in the logistic_function. Aaaaanyway, stay safe and keep up the good work!
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
Hi! The first one of your problems is because curve_fit is unable to compute covariances. I fixed this with a (slightly) better initial guess. See updated code on my github. I think the overflow warning comes from putting a very large or a very small number as an argument in the exponential function. Hopefully numpy handles this. Thanks! Stay safe.
@aleksandarjevtic9578
@aleksandarjevtic9578 4 жыл бұрын
Hi :) I tried your code with the current data from data.europa.eu/euodp/de/data/dataset/covid-19-coronavirus-data but the curve_fit function doesn't seem to work here with the data from Italy. it says parameters could not be estimated. I wanted to expand my little script which sends me daily new numbers of the coronavirus cases with the graph but it doesn't seem to work. When I removed the 0's it was better but the end of the graph indicated a large discrepancy between the observation and the fitted curve🙈. Is there any way to fix this? otherwise I'll just leave it as it is. Big thanks for the video!
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
You probably need to supply a good initial guess for the a parameter. See github.com/gregwinther/youtube/blob/master/covid19/covid_analysis.py where I give the latest number of registered cases as a guess. If curve_fit manages to fit the data, then it would be the best fit, i.e. it minimises the squares of the residuals. You could probably weight the latest observations more, but I am not sure how to do this as of now.
@aleksandarjevtic9578
@aleksandarjevtic9578 4 жыл бұрын
@@GregWintherArtist ok thank you very much :)
@kentonjones5394
@kentonjones5394 4 жыл бұрын
Great fits. If you have time, try the "Richard's Curve" ( generalized logistic in wikipedia) to tighten the logistic corner bends... y = A + (K-A) / [ (C+Q×exp(-B×X ) ^ (1/V) ]... I've been getting good fit. Kenton in California, take care in Norway!
@tahahuraibb5833
@tahahuraibb5833 4 жыл бұрын
hello, thanks for the great video. just a question, shouldn't the a value in the logistic function be the total number of susceptible people, so in new york's case that would be the population of the city, also how does the model mathematically predict the a value? thanks in advance.
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
The parameter a represents the total number of infected (reported cases) that we’re asymptotically moving towards. curve_fit finds the best fit function by minimising the square of the residuals. Starting with a guess for the parameters, it computes the errors (residuals) compared to the true values from the data. The model then varies the parameters in order to minimise the square of the errors. More specifically, curve_fit uses the Levenberg-Marquardt algorithm aka damped-least-squares: en.m.wikipedia.org/wiki/Levenberg-Marquardt_algorithm
@user-nn1cm6lx2c
@user-nn1cm6lx2c 4 жыл бұрын
Hello Greg! this comment is irrelative to this video but i hope you could help.. i am a computational physics student (i think i am what you call in America an undergraduate) and i am trying to graduate through a world pandemic - lol- anyway.. i am really struggling with my senior project. unfortunately, the department assigned me to a supervisor who doesn't have any experience in computational physics .... i am trying to model (using MatLab) a 1D photothermal experiments on Layered Samples with Mirage-Effect Signal Detection... i used the pdepe tool but the results don't seem to match the analytical nor the experimental results. I am confused and I dont know wither the problem is that i didn't assume the boundary condition and initial condition correctly or the whole discretization method doesn't work here (and maybe i should use discrete Fourier transform) or something else... I will be very grateful to you for any advice from you.. or any resource you think would help... thanks in advance.
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
I am not sure that I will be able to answer this question. I will try to look into it a bit further and see if I can give you any advice, but I cannot promise anything.
@HorukAI
@HorukAI 4 жыл бұрын
Didn't you basically repeat the previous video on covid19 logistic progression? btw you have GitHub repo for retrieving data per country which is updated every 12 hours just be sure to escape days bunch of days with zero confirmed: pomber.github.io/covid19/timeseries.json
@GregWintherArtist
@GregWintherArtist 4 жыл бұрын
Regrettably, yes. I actually did some other stuff as well, but it didn't turn out very well so I cut it out. Nevertheless, I felt it was OK to have a natural follow-up to the previous video. Thanks for the link!
Infections and Recoveries [2/3]
21:29
Greg Winther
Рет қаралды 2,3 М.
Collecting Stats and Initiating Quarantine [3/3]
13:47
Greg Winther
Рет қаралды 1,7 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 105 МЛН
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 24 МЛН
Understanding Epidemics: The IHME Model and Curve Fitting
11:06
Intel's CPUs Are Failing, ft. Wendell of Level1 Techs
23:59
Gamers Nexus
Рет қаралды 25 М.
Research Visit to MSU
11:05
Greg Winther
Рет қаралды 447
Intro to the logistic function with Python 🐍  [1/2]
9:58
Greg Winther
Рет қаралды 1 М.
The Sigmoid Function Clearly Explained
6:57
Power H
Рет қаралды 98 М.
Newton's Second Law + Programming = 🤯
16:47
Greg Winther
Рет қаралды 3,6 М.
The Intertwined History of Physics and Finance
17:33
Greg Winther
Рет қаралды 4 М.
My first year as a PhD student (2020)
15:01
Greg Winther
Рет қаралды 2,7 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 105 МЛН