Fitting the Predator-Prey Model to Data (Python)

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

Mike Saint-Antoine

Mike Saint-Antoine

2 жыл бұрын

Hi everyone! This video is about how to estimate the parameters of the Lotka-Volterra Predator-Prey model by fitting it to data.
All the code from my videos is available on my Github:
github.com/mikesaint-antoine/...
Here is a video I made giving an introduction to the Predator-Prey model:
• Predator-Prey Model (L...
And here is a video I made about how to simulate the Predator-Prey model in Python:
• Python Code for Predat...
Thanks for watching and let me know if you have any questions!

Пікірлер: 20
@MikeSaintAntoine
@MikeSaintAntoine Жыл бұрын
Hi everyone, thanks for watching! Here's the link to the code on my Github in case you want to try it for yourself (also feel free to add me as a friend on Github if you want 🙂) : github.com/mikesaint-antoine/Comp_Bio_Tutorials/tree/main/parameter_estimation/predator_prey
@Adi28096
@Adi28096 6 ай бұрын
Hey Mike, any tips on how to make the estimated parameters more accurate? Doing a project looking at wolves and moose, but the parameters and the line is quite far from the scatter plot values. Do let me know, thanks.
@MikeSaintAntoine
@MikeSaintAntoine 6 ай бұрын
Hey Aditya, great question! Unfortunately it can be tough to get good parameter estimates with real-life datasets, just because parameter estimation is a pretty difficult problem. In these videos I purposely make up easy examples for the purpose of teaching the technique, but real datasets aren't always so simple and unfortunately it's difficult to improve the parameter estimates just by changing the code. What's really needed to get better estimates is more data -- as much data as possible really. But if you're not able to get more data to do the analysis, another possible thing to try is setting bounds for the parameters within a range that's considered reasonable, to narrow the search space that the code is trying. This might be difficult to, but maybe you can read in the ecological literature and try to find some reasonable bounds to set for the parameter estimates. But yeah, it can definitely be pretty tough to do this type of analysis with a real life dataset, and unfortunately sometimes it just doesn't really work. But if you need any further coding help, feel free to email me at mikest@udel.edu and I can try to help. Thanks for watching! 🙂
@anikamittal6721
@anikamittal6721 5 ай бұрын
Hey Mike, can you find parameters upon entering raw data to formulate the Lotka-Volterra system?
@MikeSaintAntoine
@MikeSaintAntoine 5 ай бұрын
Hey Anika, sorry I just saw this comment, but yes I got your email and responded!
@urpaljp
@urpaljp 2 жыл бұрын
Hey man thanks for the video. Currently doing something similar, but on matlab. Would you say it's essentially the same concept? I have a set of ODEs and want to fit them to a data set that we have.
@MikeSaintAntoine
@MikeSaintAntoine 2 жыл бұрын
Hey! Yeah, the basic concept is the same for any programming language you're using -- basically you just need to write some loss function to measure how far off the model is from the data, given a parameter set, and then find which parameter set minimizes the loss function. The only thing that will really be different in Matlab is the syntax. I haven't made any parameter estimation videos in Matlab yet, but I do have an introductory Matlab video on the Predator-Prey model, in case that helps: kzbin.info/www/bejne/fIGypamdgZiUpLM Thanks for watching!
@urpaljp
@urpaljp 2 жыл бұрын
​@@MikeSaintAntoine Thanks! Definitely helps a lot. Had another quick quesiton about the loss function here. I'm guessing to do that on matlab it's sort of just defining a function before the ODE function? For example function loss = loss_function (params, years, fish_pop, bears_pop) end I think I should be fine with the ODE model especially with your video on the pred-prey model. Thanks again!
@MikeSaintAntoine
@MikeSaintAntoine 2 жыл бұрын
@@urpaljp Yes, I think that should work! If run into any problems with it just let me know and I can also take a look at your code.
@user-ik7wt3om5e
@user-ik7wt3om5e 2 жыл бұрын
Good afternoon! I need your help. The topic of my graduation project is the study of the extended Lotka Volterra model from the point of view of dynamic systems analysis. I want to consider several participants, more than two. For example, the interaction of hares, foxes and wolves. I want to get a differential equation and see the dependencies. Can you recommend literature to understand this topic well ?
@MikeSaintAntoine
@MikeSaintAntoine 2 жыл бұрын
Hi! I'm not an expert on this topic (and really don't have very much ecology background) but I was able to find a couple good research papers that might point you in the right direction for this project: www.jstor.org/stable/1942114 esajournals.onlinelibrary.wiley.com/doi/full/10.1002/ecs2.2622 esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecm.1459 I wish I knew more about the actual ecology part of it. However if you need any help writing the simulations in Python just let me know, because that part I could help with! Thanks for watching and let me know if you have any more questions!
@sushilchhetri5531
@sushilchhetri5531 9 ай бұрын
Hello sir,your video was really helpful. I am trying to implent this technique to estimate the parameter for my coupled ode which consists of five equations and almost 19 parameters . similar to what you have done I guessed parameter values as 1 for all the para then ran the follwing code after that but the resulting curve is not passing through the data points. how do I handle this problem sir? Does this method work for a problem that has more parameter?
@MikeSaintAntoine
@MikeSaintAntoine 8 ай бұрын
Hi! Yeah it sounds like with 19 parameters that could be a pretty difficult problem if you need to estimate all of them. For these videos I've been making up easy example datasets just for the purposes of teaching, but often parameter fitting in real life can be difficult, and it doesn't always work. Anyway I cant try to help! If you email me your code I'll take a look. My email is mikest@udel.edu. Thanks for watching! 🙂
@Viewpoint314
@Viewpoint314 Жыл бұрын
Which GitHub file is your program in??????????????????????????
@MikeSaintAntoine
@MikeSaintAntoine Жыл бұрын
Hi Ray! Here is the link to the code on Github: github.com/mikesaint-antoine/Comp_Bio_Tutorials/blob/main/parameter_estimation/predator_prey/fit_model.py Let me know if you have any questions! 🙂
@zeeshanmouzam5831
@zeeshanmouzam5831 Жыл бұрын
Hi, really likede your video. I followed the code the same code (reference: maek_data.py file present in prey predator)for 4 differential ewuations model and I am stuck with how to choose initial values. Please help
@MikeSaintAntoine
@MikeSaintAntoine Жыл бұрын
Hi Zeeshan! To be honest I just picked the initial values arbitrarily. I don't have enough ecology knowledge to really know what makes sense for realistic population numbers. So for the purposes of learning how to fit a model, I'd recommend just picking any initial condition. But if you want it to be biologically realistic, I'd recommend reading some papers on whatever populations you're trying to model to get a sense of realistic population numbers. Does that make sense? If you're having any trouble with the code itself, you can always email me at mikest@udel.edu and I'll try to help! Thanks for watching! 🙂
@mirajmiraj8718
@mirajmiraj8718 Жыл бұрын
The data used in the model is created with the same parameters that are used to fit the model. It is obvious that he got the model fitted. If it is real data, it will be very difficult to fit the model. For example, if you choose a random parameter, e.g. [1.29337755, 0.46139313, 0.81580378, 0.20333608], which is reasonable, it will never fit. This is because the method is not realistic, it will only work if you know or have an idea of how the parameter look like. But the question is why search for a parameter you already know.
@MikeSaintAntoine
@MikeSaintAntoine Жыл бұрын
@@mirajmiraj8718 Hi Miraj, thank you for the feedback! You're correct that working with real data is always more messy and difficult, and that I purposely created an easy example here to demonstrate the fitting technique. In scenarios with real data, the fitting will not be as easy as in this video. However, it's not correct that the model fitting started off with the same parameters that were used to generate the data. The first guess for the model fitting was [1,1,1,1], and through the process of minimizing the loss function, it ended up with a result of [0.98, 0.38, 0.11,0.46] which was close to the true parameter values -- showing that the fitting method worked pretty well, even starting off with a guess that was different from the true values. I encourage you try to generate data with your suggested parameters of [1.29337755, 0.46139313, 0.81580378, 0.20333608], and then start with a guess of [1,1,1,1] or [0,0,0,0] and try to fit the model using the technique from this video. My guess is that it will work pretty well. Of course you won't get exactly 1.29337755, but you might get about 1.3 or 1.2 for that parameter. The goal is to estimate, since of course getting an exact answer like that is impossible. Thanks for watching! 🙂
@mirajmiraj8718
@mirajmiraj8718 Жыл бұрын
@@MikeSaintAntoine Thanks for your response. No, it will never fit. However, if you think it fits, please test your model with the same parameters I suggested to see if it fits.
Fitting Logistic Growth Model to Data
27:26
Mike Saint-Antoine
Рет қаралды 1,4 М.
Phase Space Plot for Predator-Prey Model (Python)
14:23
Mike Saint-Antoine
Рет қаралды 4,5 М.
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 35 МЛН
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 15 МЛН
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 111 МЛН
Mathematical Biology. 14: Predator Prey Model
47:07
UCI Open
Рет қаралды 45 М.
Predator-Prey Model (Lotka-Volterra)
9:01
Mike Saint-Antoine
Рет қаралды 5 М.
Python Videos 10a: Parameter Estimation with Python
14:23
Carroll Mathematics
Рет қаралды 6 М.
Euler's Method in Python: Predator-Prey Example
23:42
Mike Saint-Antoine
Рет қаралды 1,6 М.
Predator-Prey Population Models || Lotka-Volterra Equations
9:30
Exploring Maths
Рет қаралды 27 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 261 М.
Deterministic vs. Stochastic Modeling
3:24
Mike Saint-Antoine
Рет қаралды 3,3 М.
Cadiz smart lock official account unlocks the aesthetics of returning home
0:30
Main filter..
0:15
CikoYt
Рет қаралды 13 МЛН
Gizli Apple Watch Özelliği😱
0:14
Safak Novruz
Рет қаралды 4,8 МЛН