NASA ARSET Building Evaluating and Interpreting a SDM
The Story
Welcome to this highly analytical and ecologically vital episode of the NASA Live Video Podcast: "NASA ARSET: Building, Evaluating, and Interpreting a SDM."In this episode, we bridge the gap between spaceborne observations and biodiversity conservation to explore the end-to-end workflow of Species Distribution Modeling (SDM). As climate change and habitat loss accelerate global ecosystem shifts, knowing where vulnerable or invasive species are likely to survive is critical. Satellite remote sensing gives us the environmental layers needed to predict these ecological footprints across space and time.
Through the framework of NASA’s Applied Remote Sensing Training (ARSET) program, we break down the rigorous scientific steps required to build, evaluate, and interpret a robust SDM. We discuss how to prepare occurrence data, integrate NASA Earth observations—such as MODIS, Landsat, and GEDI terrain layers—as environmental predictors, and run predictive algorithms. Going beyond model creation, we dive deep into evaluation metrics like AUC and True Skill Statistic (TSS), and discuss how to accurately interpret the final probability maps to guide real-world wildlife management and policy decisions.
Whether you are an ecologist, a conservation biologist, a GIS developer, or a space enthusiast eager to see how satellite data maps the living world, this episode offers comprehensive, practical insights. Subscribe to the NASA Live Video Podcast to stay connected with the absolute frontier of space exploration, ecological modeling, and cutting-edge earth science!
Speaker 1: Hello. It is my pleasure to welcome you back to part two of our r set training on species distribution modeling with Google Earth Engine. Today's session is focused on building, evaluating, and interpreting species distribution models on Google Earth Engine. This training is brought to you in collaboration with the Smithsonians National Zoo and Conservation Biology Institute. My name is Sativa Cruz and I'm your host for this session. I'm an applied scientist with a Bay Area environmental Research Institute at NASA Ames Research Center.
Speaker 1: You heard from my colleague Justin Fein in part one, and pictured here is our full ecological conservation team. I'm grateful to them and the entire arset team not pictured here, who make these trainings possible.
Speaker 1: Your guest instructors are the same for this session, Ramiro Crego, Grant Connett, and Jared Stabach. Again, this is part two in our series, taking place on July fourteenth of twenty twenty six. Please note that there will be a homework assignment posted to the training page which needs to be completed in order to receive a certificate of completion. In the first session, Foundations of Species Distribution Modeling with Google Earth Engine our instructors provided an introduction to species distribution models, including an overview of core concepts, applications and considerations.
Speaker 1: Session two will focus on what it takes to build a machine learning model, providing a Google Earth Engine based workflow. Our instructors will take us through initial steps of species data uploads and pre processing, two model predictions, and all the steps that are in between. Our intention is that by the end of this training you will have achieved the learning objectives listed here and that we're reviewed in Part one. In addition to attending the first session, we encourage you to view Part two of the Land Cover Land Use Change with NASA Satellite Imagery training as a prerequisite to set yourself up for success.
Speaker 1: We also assume prior knowledge of GIS and some coding experience to participate fully. So as a reminder about how to ask questions, please put your questions in the questions box and we will address them at the end of the webinar. You can enter your questions as we go and we will try to get all through all of the questions during our Q and A session. All remaining questions will be answered in a document which will be posted to the training website. About a week after the training. Now passing the mic back to our instructors for part two.
Speaker 2: Welcome back everyone, and the idea for today is to finally get to feed a special instituition model is using Google Earth's engine. Now that we are all familiar with the basics of JavaScript and were hopefully used to the JavaScript code, we can start to try to understand this workflow. So later the idea and I show you the basics a very simple model, and then you can take it from there and start building your own models using your own data. So there are many things you can do, as we will see with this with this framework, we're presenting the idea here again is to show you the basic framework so from where you can build.
Speaker 2: So for the purpose of this class, now we're going to see how we upload our data. Remember last time we cover how you download it for example of fro GVF, I show you the predictles, what you got to do, examples exactly what we're going to use today. We're going to do some of those best practices preprocessing of the data, how we handle predictor variables, the important part of present and absence, so how we create cello absences or background points, and today we'll focus on present some solo absence we're going to fit.
Speaker 2: Finally, the models. Remember we're using machine learnings. We're going to use random forest in this particular case. And then the important aspect of how we evaluate how good our model is making predictions and visualizing those predictions. So let's start with the first step. We're getting our data into Google Earth Engine. The way we do that is uploading our data as an asset. Remember we downloaded CSB file from g Yeah, yes, you may have a SHAVE file or you may have your own data save as CSB filing.
Speaker 2: The important thing have you been you have your coordinates in geographic projection. So in W eighty four we're going to I give you here the steps. So for in this case, you will go to assets. You create a new asset, You get a CSB file. Then you creick select and select your file. You give a name and where your asset is going to be saved. And then make sure your the names of the lat longitude and latitude match the columns you have your CSB file, and also that you match the geographical coordinator system the geographical coordinate system.
Speaker 2: Then you click upload and now we'll go into your asset. So for example, seeing it from here here, we go to new we choose a CSB file, we select and I'm going to do it right now, but you can select and then you're choosing which project you want to save it. Again, make sure you have your longitude and latitude correctly named. By default, they are called longitude and latitude. It's not common to switch them around have them in the wrong place. So then your entire shifts and make sure you have your correct project Coordina reference system.
Speaker 2: Then you upload and that will become will go in one of your assets said here. Remember this taking space from your free quota of data your in Google, so be mindful of that. So this is the one we're going to be using. If you want this to be accessible by people, you have to make it publicly available. By clicking here, one can read, so any one of you can read this asset and replicate the stadium doing right now. One quick way to know the data has been uploaded correctly is that it shows here the points and it's where you are expecting it to be.
Speaker 2: So now that we are in the co editor here, I have the entire workflow that you can access through your links or through the paper link, and what I'm going to be doing is commenting out some parts. One of the things I really don't really like contrast critic is that you are running the entire codel once, not line by line like in another programs like software. But I'm going to do is go part by part. So here, if I run this code, I'm going to be reading our the data is the future collection. I'm going to get the size and printed on the console, so we know how many points we have, and I'm going to add it here to the map as with the map a liar.
Speaker 2: So if I run this, we know we have five hundred and seventy one points and these are our data. Remember I already clean this to remove wrong points and points on our cities with things we discuss in the previous lecture the previous week. So here you can have a quick look at how that looks like. Fantastic. So now we can move to the next step. That is also very important, and it's defining the spatial resolution of your analysis. What's that pixel size that you want to work with. Be careful with the ruler tangine when you are displaying imagery because on the what we call the on the fly display when you plot things here on the rasters weekly on on the on the viewer, on the map, depending the zon level you are is the pixel side you're going to be seen.
Speaker 2: But what we want to do for an analysis when we explore the raster or when we extra calculate pixel values is to define that pixel size. In our case, now we're going to use one thousand meters one kilometer resolution. Of course, the smaller that grain size, the more memory more data you're working with. So depending also who were see now at the extent and your goals, your objectives, your reserve question, a lot will depend on what kind of grainchise you're using and what type of predictor valuables you're using.
Speaker 2: Our grain size here, what I mean with this is like if we define in one thousand meters and one thousand meters every time we extract a pixel value. For example, here I have I displayed a modis MDBI with the two hundred and fifty pixel resolute. We have sixteen pixels to which we are going to get an average number for that site for that location. For this, let's say this is our presence data that will be a pixel size the same for our cell absence data, So that's the value we are extracting for analysis, so keep in mind that, and then we are going to use the same grain size for the entire workflow and when we export our final map, so we can save it as arrested and use it to display it or create maps in with another soware.
Speaker 2: The next step when we talk about some of the best practices is to kind of ratify that presence data so you're not using multiple points on the same pixel. So now we define our pixel size one square kilometer. Now we want to make sure that we don't have multiple presence points. This is very money if you're using citizen science data like in this case, without a load of these data from GVF. Again, so you may have multiple locations reported in certain areas, not necessarily because there are more animals there, but maybe because more people are reporting in that area.
Speaker 2: Now, if you use the full data set like this and you have ten presence points in the same pixel, then you are given them all the ten same values pixel values and kind of over emphasizing that pixel over other pixels. So avoid that problem, you can thin your data set. So then what we do. The solution I found when I was coding this workflow was to create a random raster with random values. So each pixel has a random value that is unique and distinct from any other pixel. So then we can extract that random value on that pixel for each point and then we just keep with this distinct function one random value, so we are ensuring we only have one final point per pixel.
Speaker 2: So that's why we kind of ratify our data set. So you can see that we go from five hundred and seventy one original points to three hundred and twenty three. So this will be what is next line of code and going to comment out with this forward slash double forward slash, So we have the grain size. This is the function to remove duplicate and we apply that functions our data and our final data that size is going to be exactly what's so there three hundred twenty three. Grant is going to talk to you about new developments and new ideas on whether this is the correct methodology or the correct thing to do with your data.
Speaker 2: You are losing data that is totally valid by removing those kind of duplicated pixel values, so some people consider that actually you're reducing data for no reason. Grant is going to explain that later on some new developments on STMs. Also, keep in mind and read the literature because a lot of these methods are different. People propose a lot of different things, so it's always good to keep in mind what is going to work best for you. But this is what we consider the time the best practice, and that's what we have implemented.
Speaker 2: You could completely ignore this function and use the entire data set if you want to. So that's the magic of having the ROW code. You can't really adapt it easily. Once you clearly, of course, understand what's going on, and that's the goal of this. We understand what's going on. The next very important thing to do is define your area of interest. So what's the area you're going to be working with. Remember we have we're working with presence only data, so we only know where the species are. We don't know where the species not or those absences we talked last week.
Speaker 2: So the idea now we have to define this of interest to work with which we will learn to create the random points to extract this background information or this creative seale to absence, to extract information environmental from environmental valuables to inform them model the algorithm where things are not present.
Speaker 2: There are many ways you could do this in ular engine, but you really have to think about this. It makes no sense if you are working with species and distributes maybe in Colombia or in the mountains, to use the entire planet to create all absences. That would be ridiculous. It makes no sense to include the ocean. If you're working with interrestrial species or vice versa, use the terrestrial ecosystems environmental environmental valuables from terrestrial ecosystems. You're trying to model species that live in the sea, So that would be a very grotesque example.
Speaker 2: Very that's very obvious example. But ideas, we want to compare what the species are where they can potentially be, so we can disentangle those areas that are the species preferred or more suitable for the for the species to exist to a cure. So that's what we're going to do, is create this area of interest geometry. You could use a lot of data cells already available in earthgia like countries, so you can get, for example, the countries Columbia with this first line of code here, or you can get the entire continent in South America.
Speaker 2: That's your goal for the workflow. We are using this where is a more simple way that is to generate the bounding box around your data set, meaning that this is where the data has been observed. So we are trying to restrain our model to areas enclosed by that bounding box. But we provide the buffer to that. In this case, we're not giving fifty kilometer buffer around in the most extreme presence locations in north south west east. So we create an outline. We can plot it, so we visualize it. So let me show you here in the call how that looks like.
Speaker 2: And when we created this workflow, the idea was to generate quickly accessed and generate these models and be able to visualize the outputs the predictions. And because we're going to have two predictions and we see later one is habitats with ability or the probability that a species is present at any pixel any sight. But also we can't have this binary maps is potential distribution. What is the potential distribution of the species. So we divided the map the map here in two by doing this little code here.
Speaker 2: So if I run this now, you will wish. You will see I haven't centered yet. You will first see plotting the data in both maps and then defining the study area here, generating the outline and plotting it in both maps as well.
Speaker 2: So now we have the points with the outline that's going to be our area of interest. Now that we are we have created right and left map, so instead of calling maps a layer where you're seeing right and left every time we want to plot something, and we're centering the map towards our area of interest. This number controls the zoom level, so you can experiment changing those things to visualize. But you can also change the zoom of course right here in the map with your mouse or with these two buttons.
Speaker 2: Fantastic. So at this point we now have our presence locations, we have, we have ratified those, we define our area of interest, and we define our pixel size that we want to work with. The next step is probably the one. As I mentioned before, we are making things in Earth Engine makes the most sense, and it is loading our and selecting our predictor valuables
Speaker 2: so we can take advantage of this massive catalog of craster imagery available in Cooler Engine, so you can inspect the catalog, and remember you go to the search and you can look for NDBI and normalize different vegetation index and you will have a lot of different ones. For example, the mode is sixteen day one kilometer research a composite could make sense to include it in our model as this would be surrogate for vegetation productivity that could inform habitat for this lot. As I mentioned before, I always highly recommend you looking into the Cooler Engine community catalog where there is a lot of more information available.
Speaker 2: Highly recommend you to go play. You always have a description of the data set, the paper where it was published, how you cited, if you use it, and generally you will have a sample code you can open or sometimes you even get the good at engine Eye to explore it. Not show you the data set that I have been using quite a bit lately. That this high resolution one meter global cannot be high from tolenal and I click on the I have it already run here, but it's quite amazing to have this kind of level of information, detailed information on forest cover you can swim in and see.
Speaker 2: Compare the high resolution imagery with cannot behave or if you transform that into keeping only pixels with more than one meter, you can get this kind of cannot pick cover one meter resolution, what is crazy? Just to give you an idea of the amount of really high resolution and and things that maybe your computer may not be able to handle. If you want to download stuff like this again, which break the variable you use will depend a lot on the type of question you're asking. But I just wanted to show you so you you know that these things exist and showcasing why Goular engine can be so powerful.
Speaker 2: I want you close this too now.
Speaker 2: And another thing I mentioned before is where I think Googler tension can also be very powerful is using the roads at data's predictor variable. So here I show you this before this paper these few papers I mentioned, but using the raw lands automatic mappers as predictors what makes sense. So instead of using a classification and carrying on all that error is already into that classification for different type of land uses, you just use a road satellite data to inform the model of this suitable habitat.
Speaker 2: We actually did this recently and this paper let's called validating Habitats with a bit accessment with potranslocation movement data. So suitable habit maps can be very valuable for translocation species, but it's very hard to get data to actually validated after the introduction happened the re introduction. So in this case we train them all that one hundred meters resolution you see landsat and other valuables. I will show you know the code you seeing data from giraffe in Namibia, and then we created a model of potential suitability in Angola in ur National Park where fourteen animals were re introduced.
Speaker 2: Actually it's brought back then called giraffe into Angola. Level was really extraordinary, but look at the predictions and where the giraffe moved a year after they were reintroduced, was quite quite incredible to see the capacity of the model to predict that. I'm going to talk more about these papers later on, but if if now this is this section of the workflow, what we bring our predicted variables. In our case, coming back to the radius, I'm loading the bioplematic variables. Then I'm loading a digital elevation model and get in the terrain algorithm just calculate also slope.
Speaker 2: I'm also bringing here a modest product on the estimated annual tree cover for each pixel as understanding that the lot is a special that requires trees, so that would be a good predictor for Habita suitability. And we are this is an annual product. So we retain all the images from two thousand and three twenty twenty two match presence located data, we select recover, and we estimate the median to finally have go from an image collection into one image. We combine all those different images as bands into one single variable called predictors.
Speaker 2: So now I can plot the print is and what you will see in this imag So first it is an image and not an image collection anymore. And now that we have all these bands here, so these are all our potential predictor variables that we're going to use that we could use now to predict to feed the machine learning model. There is a few more steps we want to do and we want to remove water. So one thing we want some of the If I plot some of these maps, some of these rafters, they may have in formation on the sea that we don't want to have.
Speaker 2: So we want to create a water mask. So we can use very simple get the terrain and select everything is above sea level, So then we will have a mask that is the only terrestrial have a lots of land on the continent. We get our predictor images and update that mask with a water mask we clip for our area of interest and we can plot that so we can visualize. Always a good idea to visualize. So here we have our elevation data, so now you see this doesn't have any data outside the land. We can also visualize the personality or annual precipitation across our area of interest.
Speaker 2: But if you look here, you have all these rivers, and we know that these are not going to be suitable habitats for slots. So what we're going to do is what we can do is get a little bit more fancy and get another product that is called global waters global surface water, and we're going to get any pixel that we know has has water and use that as a second mask. So when I run that, and if I assume me now into these areas with a lot of water, and I click bring my elevation here, bring it out, you see all those water areas having masks out and are not going to use in our final prediction.
Speaker 2: So we don't want to predict habit that's with ability on top of water. So yeah, let's say another nice trick and very easily done with the engine. To show you how powerful this can be. If we go back to our giraffe case. Now instead of having the biopligmatic variables elevation, we can bring an entire collection of lands at eight and we can apply our cloud masks et cetera, et cetera. Then we generate different vegetation industries and maybe good predictors and TBI and savvy. They are soil in dens, we can be really very good for giraffe as they will avoid that is with completely our soil, and we compile that into a composite.
Speaker 2: We can add things like standard deviation across all the image collections, how much variability in pixels can affect the suitability of that site. We can also elevation surface roughness. We also brought radar image what is really good for mapping woody vegetation, which giraffs are browsers, so they will prefer with the vegetation. So we compile all that as the variables at the resolution one hundred meters. So that's where Google Attention can be super powerful. So we're showing you here's a very simple workflow but just to show you that you can do things are more complex and quite powerful.
Speaker 2: Next, now that we have that dictor variable with all our bands, we don't want to use everything. We want to be selective hopefully. Like the way I like to approach these is what are the predict variables that makeological sense? So have an idea hypothesis behind why you want to introduce them. For this example, where you're seeing temperature seasonality, the maximum temperature of the worm, we want the minimum temperature of the coldest month, understanding that this extreme value are the ones that would restrict a range of species.
Speaker 2: Here we're going to try to get the continental wide habitat suitability model, whereas in precipitation, elevation and the person tricover. So now from all those predictors, we are going to select only these bands. So now we're going to work with the final six vans instead of the twenty three we originally have.
Speaker 2: So this is what you can see now here in the code. And next week and now that we have our predictor variables and our presence location, we move to this critical step of creating the severed absences to getting that information where the species is not that is required for our models we stopped before last week as a good practice. At minimum, you need to not create absences in the same pixels you have presence. So this is what this first mask is going to do. So we move now to section four on our workflow, and we want to run this first mask that's going to create a pixel of our chosen grain size at each present location, so that will impede creating cellar absences on the same sites, the same pixels where we have presence data.
Speaker 2: So what you will see here is like these are my presences. You will see these white spaces are areas where now you cannot create absences. So that's our first minimum thing we need to do to define this area to create absences.
Speaker 2: When we wrote this paper, this workflow, we provide three main methods. Keep in mind you can modify these and apply different methods if you want, but these are the three you have available. You can choose very quickly. One will be to just use the entire area of interest. The after, of course, you remove the oceans to generate cello absences. This would be a good practice if you are creating background points, like if you're trying to run maximum mode, but because we're going to be using machine learning model, we are going to be creating cell absences, so we don't want to just create random points and cross the entire region.
Speaker 2: So then we have two other options. This is one, I use a lot that is limiting that cell absence area, where the area where you can create cell absences to certain buffer from your presence locations that buffer. That distance in that buffer can be informed by movement that if you're working with animals or dispersal, that is known for the species how far they can move. So the ideas you are generating absences in areas where the species potentially could exist could occur and that will inform better your model, so you're not going extremely far away to gather that or generate that absence data.
Speaker 2: Another option will be to use this kind of environmental profiling technique, and this is actually the option we use in this in this case with the press example. So the idea is you do select a random amount of points just to reduce the amount of memory required, and then you generate profile from all those predictor variables to understand with habitats are more similar or this similar to your known locations, you will end up with two classes two categories. Here in pink is more dissimilar, ingred more similar, So then you can generate those cell absences in the pink area.
Speaker 2: So your final map or braster what you image to use the proper term when you can't generate sell absences will be this black area. Here in the code, you will see that option one the entire area, option two just only the the area buffer, or options three using the environmental profile. So let me run up to hear the code now and always is a good practice to try to visualize that at least I like to visualize the those areas, so we're always loaded in them here. So our area to create the absence will look like this, so we know it's working.
Speaker 2: We know where we are going to be creating seal obstances. Because once we define these things and we generate our final model to feed the random forest, you're going to be more hard to visualize things. So at this point you want to make sure everything is working fine. So we have our present data, our area of interest, and we have defined out our area to create seal absences. Also we have created our list of predictor violence. Now is when we get into the more complicated stuff and is we need to not just predict and create the model, but we somehow we need to know how good our model is.
Speaker 2: And we're going to use a special block cross validation technique. That means we're going to split our data in a training data set including presents and seal absences, and we're going to have another put another group of points of president absence to test our model. The problem is what you're seeing randomly spitting splitting these points, and they are where randomly selecting points that are very close to each other. The good chance that them is going to be really good at predicting a pixel next to where the mole got trained.
Speaker 2: Just natural thing that things are more similar, and when they are close by, elevation would be similar. Unless you earn a cliff, vegetation is probably similar on you and farther away. Certain people argued like roverts are like that that inflates your confidence and your moral predictive power.
Speaker 2: So what they proposed is generate blocks that you can do so instead of you are in the points, divide those blocks into areas for training an area for validation. So then if your model can predict different blocks are quite distant so now the data is quite distant from where the model was trained or the data was extracted to train the model. Then the predictive power is you can't trust that model. A little more gives you the more accurate picture of how good your model is performing. So that's what we implemented this kind of spatial block cross validation.
Speaker 2: So the idea is, if you have defined this greed, we're going to randomly select seventy percent of those blocks, and then we're going to extract if I plot everything here, all our presence point on our cell to absence points and we generated randomly in blue, so the presence in red, cell absence in blue everything that overlaps with the dis greed. Where we're randomly selected seventy percent of the blocks, that's going to be used for model training, and then the model has to be good to predict in areas where there is no quite far away from the the model was predicted.
Speaker 2: So that's the idea. Now, of course, if how big this block has to be, well, that's if you do it too small, then you end up in the same situation. That is no difference than separating the splitting these points randomly. If you do it too big, you run into the risk of randomly splitting your data and getting non data for training just by chance. So depending also how cluster your data set is, and this one is quite cluster towards Central America, you want to play with that cell size or block size, so not the definite answer, but you don't want to go too small, you don't want to go too big.
Speaker 2: So if we go to the code here, now this is the function to create agreed and this is why you can switch that distance here. We're using two hundred kilometers for that block and could always could to print it and visualize it. So we can visualize our greed now on how it's looking. Different areas maybe get difficult because the greed is being created, or we have land. We're trying to mask out all the water. But if you have little islands that will leave blocks, so that will you want to make sure that it's working right for you, or you're not having blocks that are not within your area of interest.
Speaker 2: So that's why it always could practice to visualize fantastic. So now we have our blocks data were ready to feed models. So now we get to the part of actually generating our random forest and feeding and then bury it in those random forests. How good that they are predicting, And this is a good time to premand ourselves that we are in good attention. We're using machine learning techniques, so in this gus random forest, that means we are going to the goal of this is to predict, yeah, not to understand what is driving the occurrence of any species, but getting really good predictions of suitable habitat.
Speaker 2: So the next thing now is to run our model and get our predictions. So this is where you visualize why I divided this map in two. So here we have our habitat suitability, but we can interpret as the probability of a species using that habitat from very low in blue to very high in kind of this yellow. Now we can have a binary map that is our potential distribution, so completely absent for where actually the actual species could potentially be present. So let's go to the code editor to see how we get there.
Speaker 2: So this is our section fine now fitting our SDM. This is a very big function, but if you understand this, you will be able to later modify it to twig ticks around and extract more information if you need. So that's why I want to walk you through this part. The first thing we want to do is get a seat number. That's going to be how our function runs on a set of seat numbers, and how many seat numbers we said, is how many iterations we're going to do. So instead of range just one model, what we're going to do is run several ones every time partition in our data for training validation differently, and we want to see that our model is always very good at predicting regardless of how we partition the data.
Speaker 2: So if the partitioning is if the mollis are always good, that means the mode is not depending on those they initial data sets. If we always get different results because depending on how randomly that data set was split, then we're having certain problems and we want to probably per more attention, we may need more data, et cetera. So how this function works. First, we have our greed. We assign a random number to every single of these sales, and we're going to filtered by that random number with the number that we split.
Speaker 2: So we're going to provide this parameter later we're going to be using here seventy percent zero point seven. That means we're going to use seventy percent of the blocks for training, lower than the split we're going to use it for training and greater than we're going to use it for testing, so we get thirty percent for testing seventy percent for training. The next thing is to bring our data presence data. We need to add a future. They are saying that this is a press, so we have one, and then we filter this based on whether they are within that training greed or within the testing reed, resulting in training points, presence point, and testing presence points.
Speaker 2: So far we have now our training presence points, our testing presence points. The next section is creating those cellar absences. Now we have our area for generated absence, so we generated that area to create the absence. We're going to use that image to generate to sample random points. We need to also provide a region and that region so we are limiting those points to the training reeds. So random points are going to be extracting through from this image only on top of that image. But first we want to get the training reed, the grain size we have defined, and how many pixels we want.
Speaker 2: What we are going to the best practice when you're using machine learning is to have a balanced data set that means the same number of presence and absences. So we're going to create just an extra three hundred because many times those by random chance, those points may randomly fall on water or pixels we masked, so we want to create some extra one to have a few extra justin case. Then we are going to limit all those random points to the same amount that we have presence points. The more points you are, the more more memory you will need, so you don't want to go too big, But then you want to ensure you ended up with too few points just because most of your points fall in the water.
Speaker 2: If you're working in Central America, big chance or your random points befall in the water, so you may want to increase the number that we have to do the same for our testing. The testing data sell to absense points and then we merge them. We merge our presence point where are the cells absence points. We have also provided zero as a press and absence, So that's how were machine learning. No where is an absence where it is a presence. We have our training and testing partitions. Now that we have the training and testing partition, we need to extract the pixel values.
Speaker 2: So for the training partition. We're going to extract that pixel value on all our predicted bands from our predictor image, so that we're going to keep that This is what this property is doing, keeping that present absence column. We're using the grain size that we define, so we are getting now all our pixel values for all our presence and cell absence locations. Once we have these, we're ready to train our classifier. We're going to use the E classifier small random forest. That is, this is the function in Earth gene to feed a random forest.
Speaker 2: Here are all the parameters that you can tweak around, and it may be a good practice to not just use the defaults. But in reality, when you are not too advanced, and because we don't have really easy ways to compare different models in our tention, you can do a lot of trader arror, or you can use other methodologies more advanced to kind of find two in your model, or you can use your validation metrics later on to find two in your models. But here are we provide those parameters. They are to so you can try to modify them and play around.
Speaker 2: This will be your number of trees in the random forests. So the larger the number you may more memory you need, but better the model will be a great capacity to the model. This is the number of variables you will get split in each tree. If you say no, will use the square root of the number of predictors you have. So if if you have nine bands, it will be three variables per split. This will be the how many points minimum you want in that split. So we set to ten to say, well, at least I want to have ten pixels to go into the random split in our random forest for suitable and suitable.
Speaker 2: This will give avoid the model from choosing very just simple pixels and or maybe overfitting. So this will give if you say ten, we'll try to find more general patterns in the in the distinction between good habitats and bad have it in our case the back fraction is the trig gets to see fifty percent of your of all the training data ta split. We're dividing that randomly at fifty so at itach split we're getting fifty percent of the data. What is quite a good practice. And then maximum nodes. We set it to no.
Speaker 2: Have here because we just set ten points where better split at least then we were this is a good good balance, so we are not allowing to spleed to to go into too many nodes and infinitive to grow to make the model the three. Then we have the seed that is the idea that we can't replicate and get exactly the same result every time we feed the same random forest. Not we all you can also comment out the random forest and feed the gradient three. I'm sorry, still going and you have free ingredient posting tree.
Speaker 2: At least different classifier that is available air tension, not that we are limited to whatever classifiers are available. If you want to use maccent MaxEnt is also available as a classifier. You can see all your classifiers if you go here, so you have accent and another ones that are available. But again for this example, we're going to use round the forest. Finally, we're going to now that we train our classifier, we're going to predict. So we train our classifier, we can set the output into probability or classification, meaning that what we have here the probability that me in that habitats with a probidity or binary map.
Speaker 2: There are different ways we can get the binary map, but one way to get and get it to plot on Earth Engine easily quickly something that we'll talk later is using the classification. So it gives you a binary map directly from the random forest. So we get two images, the classify image with presence proority and a classified binary image with press and absence. And then we all pack all that into a list. So then we have our classify image to our two images, our training partition and our testing partition.
Speaker 2: Our testing partition. We're going to use it later for validation. So that's our function right there. When we then can create a list of random numbers. You choose these numbers randomly. You can generate a random number generator, but we'll take more memory. So generally what I do is choose those numbers outside Earth Engine and then pasting here, and those amount of numbers should match how iterations you want to have. The good practice is, if you have more than one thousand points to train your your your random forest, you want to use five iterations, is okay.
Speaker 2: If you have less than one thousand points in our case, you want to use at least ten for the purpose. Now, so it runs, I want to run only five. At the end. You are going to see I'm going to run the whole thing now, and you're going to see you can print all those results. It's going to take a little bit of time for computing, and we are now printing a lot of objects. Here. This is where things can depending on the internet. How many people are using a retention where this is going to give your results on the fly or what This is going to hit the memory limit and it may not work.
Speaker 2: Sometimes by clicking it again works. If not, I will give you at the end different options. But here you can see our maps coming up. So we have our prediction for hav A the suitability, and our prediction here for the binary map.
Speaker 2: This is all the outputs we have. So we have if we run five iterations and we have five four outputs, we're going to end up with twenty elements. So this is how we can extract them all our results from all this list of objects. Fantastic. So that's how quickly in our attention you can get an specially distribution model. And I think that's the beauty of this. So there it is our special distribution model for radibus.
Speaker 3: You go.
Speaker 2: All right, last section validating our model. How do we know if this model is meaningful, if it's good or not. So those are the basic questions we need to ask, and if you're using maybe a general linar model, you may look into the devans explained by the model, or receival patterns or the goodness of fit test to see if you can trust that model or not. But here again we're using machine learning, so we're fitting a random forest. And the way we are going to validate our model to see how the predictive power of our model is using cross validation.
Speaker 2: So that's why we play that data in to training and testing. A few things about validating, and I like this definition from Arauco is a really good paper to read. And if you want to test, we can test the or quantify mode accuracy or the interpolation of our models is to test the predictive performance of the model within the same region and time frame of our training data. So how good is our model in predicting these thirty we set aside ever iteration, but we can also quantify more generality, and that's just different because that will be extrapolation.
Speaker 2: That means there's the capacity of our model to predict in a different region and a different time frame. That's what we're doing with the GRAF example I show you. So we're predicting a completely different region from what our training data is and at a different time, because when you're using lands of data, you can really select which extract month of the year you want to predict, or e or an average across an ear. Now, when we balidate our models, we have metrics that are threshold dependent, so they require a cut off in this zero two one gradient where we say okay, below certain value, we consider that an absence and above that we consider the presence.
Speaker 2: So that's what we call them threshold dependent. Example of that is the percentage of our accuracy sensitivity specificity Kapok statistics. But that can be a little bit challenging because it can be quite subjective of what threashold you choose completely change those metrics. So I'm going to show you in a second there are other metrics that threshold independent, and those are the area under the curve of the operating characteristic, area under the receiver operating correct the curve, and the area under the precision recall COURD.
Speaker 2: So the thresh caold depending ones come from these aeror metrics. So here we have our validation points where we know things points are positive or negative, and the ones that they'm all predictive. When they all break the positive or negative, they all can predict correctly that positive or can give you a false negative predicting negative when it true is positive. It can predict positive when in true is negative, that's a false positive or can't. What we want is predicted negative when it's true is negative.
Speaker 2: So these are one of the common metrics where you will report sensitivity or recall is the proportion of actual presence recorded by the model as a presence, so emphasizing the prevention of false negatives. So we want to decrease the false negative, so that's sensitivity specificity is the same but for negative values. So the ideas we are preventing false positives, so we want those true those negative absences to be actually predicted as absences as specificity and I having used in positive negative negative will be an absence positive.
Speaker 2: Is the presence precision. It can be quite useful when you're using only present data, when we're created absences when in reality we don't really know where the absences are. Where we can report precision because only it depends on the on those positives. So it's the proportion of predicted presence locations that are truly presents out of the total predicted presences. So from all the predicted presence of your model, how many are actually positive? So how much you really can trust those predictions, like your presence predictions, because you really don't know where the absences are.
Speaker 2: So here we have the Auero metrics as an example to visualize this problem of the threashold. So here, let's say these crosses are our known presence locations and then everything else known absence locations, and these are our with the mold predicted proyality, so that habitats with ability from zero to one. If we use a treashold of zero, everything will be predicted as a presence, so all the mapp will sound like potential habitat. As we increase a threashold, we start to decrease the number of pixels that were predicted at presence, and that will change of course our false positives and false negatives.
Speaker 2: So all these sensitivity and specifty metrics are going to be switching around depending on which threashold you use. And then of course if you go to a threshold that is too high, you end up with only one correctly one pixel predicted as present and everything has absence. So this describe give you an idea of how sensitive these metrics can be to which threashold you use. Generally everyone is using this across all itterations. The threshold that maximizes the sum of these two metrics sensitivity and specificity.
Speaker 2: So the thresholder will give you the best balance between true presence and true absences. That's why you probably will see threshold in the validation metrics being reported. More so, those are the area under the curves of these lines. So this one is the rock auc where you have in the Y access true positive rate and in the X access the force positive rate. And we're trying to do as you move your threshold across this line, is going to start plotting here and then we can calculate the area under the curb and this case is zero point eighty five and gives you, says, also quite good predictive capacity.
Speaker 2: So the mold. This is the capacity of the mould to distinguish between the true absences and the true presences. Here is really nice animation. You can actually visit the website highly recommended, but so you can be sure how it works. The idea what we're trying to do to maximize you get this area under the curve to one. That means our moral can correctly predict every single point so completely separates presence from absence correctly. So an AUC of one gives you a perfect discrimination. Now an I U S of zero point five is no better than random.
Speaker 2: So if you get the diagonal line here, that means this is a very bad model. It can really not tell apart presence from absence. It's just a random split. If you get something below zero point fund, then your mode is worse than random. So you are always trying to get something about zero point seven on the area and the corb. Now this one, whereas again we're using celluar absences, we really don't know where the absences are. So some people have proposed using the AUCPR because it depends on precision and recall, so it's not relying so much on your absences.
Speaker 2: And the idea is the same. It's a different line, but you are trying to maximize the area under this corb. As you will see, they correlate as you increase auc rock you increase AUCPR. Now, the problem is when you have very imbalanced data sets. So if you have let's say ten thousand absences and fifty presences, because your model will predict very well, at least a lot of the absences very well, but your fifty presences maybe not too much. Using the IUC rock will inflate, will give you a false impression that your model is very good at predicting, but actually predicting just the absences.
Speaker 2: You don't know what's happening with the presences. So the precision recall is a little bit better in giving you a true idea of how good your model is predicting your presences. That is what you really know. The data is what you really are, what speech are. So how you recommend reporting your aucpr in when you're reporting your metrics. So this is now we have is Here's why you probably don't want to touch too much, aside from if you're going to modify the list of objects you're extracting, as for example by variance importance, but otherwise you should not be changing too much of this part of the model.
Speaker 2: What we are showing here that you need to know is that because we run five iterations, where getting the average of those five iterations, and here because we have a pressing absence output we're getting the mode of each pixel. So's what the RUNDO for is digiteration predicted the most something you really want to check, and that's why we included this thing here. That is the number of if we owe to the section seven accuracy. So we extract from each list the training data sets. So we end up with five training data sets.
Speaker 2: And the first thing we want to know is how many points we got present and absence for testing in each iteration. Because when you're randomly split things, you and your data may be cluster. You may end up with no data for testing or training. So you always want to test here that you have enough. You have enough points for doing that validation. Then all these functions are going to be getting all these values for the metrics and we you can print them from this workflow and so you can see the auc rock for each iteration.
Speaker 2: This model is actually very good and getting that predicting well, the first iteration maybe not too good. What you can do is change your seeds. If there is something that is not giving you the random is split end not having enough data for for for validation. You want more points there. You can change that seed and see if you can get a better random split. This one is very decent. Of course, you shouldn't be just tweaking to maximize your thing that you want to these idea is how dependent the model output is from that initial set of values random split of values, and we can see here we are very good.
Speaker 2: Again we should be doing ten, not just five for these small amount of points. But it's a very decent output. Here we're getting the average of that of those values. This is our prs. So now we can see this one is still when you get the UCPR above eighty percent is generally considered very good. So this is again a very good prediction. We can report that in our purports of prepares. We also provide citivity in a specificity here on the fly, so the correctly predicted presences correctly predicted absences.
Speaker 2: Again aside from the first model, the first iteration is doing very well. And here is our threshold. We can use this threshold. So this is the average threshold that maximizes the sum of the sensitivity and specificity. So zero point forty five. So anything above forty zero point forty five in the suitability will be considered a presence or potential distribution. Everything below because of the an absence. So instead of getting this output from the random forest, you can export this map and transform in QGIS and another software are this map into binary by setting using this threshold, that will be the best practice than using just the output from the random forest, using the classification output instead of the predictive output in the species tribution functions so here.
Speaker 2: But if you try to do that on the fly, you generally are going to hit memory limits. So that's why to get a good first visualization and for many people that they will exactly what you want to do, this can be a good solution. So those are the metrics you get printed on the console and that's pretty much the end. So we can now talk a little bit about the importance of independent but having independent data for validation, true independent data for validation. It's not very often that you see papers reporting independent validations for species situation models, but I found it it's critical to have because it's quite hard to validate the model based to just the same data you are training.
Speaker 2: Even if you are doing these partitions, you're still using the same data you train them model to validate the model. Now, if you have a complete independent validation set of points to validated model. Now will give you a better, more honest idea of how good your model is. And this is what we did with the giraffe. I was showing you the capacity of these molesules differentiate the giff locations so they have ability where the graf actually use the place at one ndimeter solution compared to generating random points across this entire park.
Speaker 2: So that will leave you really a good metric. This independent data is important to prevent overfitting. Random forests can be problematic for overfitting, so always good to have this kind of complete independent data set to test how good your model is. Ensure this transfer transferability of your model, how good your model can be predicting outside a different region or a different time period, and yeah, access your true accuracy, not have like a false impression that your model is good when actually it's maybe just being very good at predicting the data you provide to fit that model, but actually then it's not really good at predicting outside that.
Speaker 2: The final thing I want to talk about is batch mode. So, as I mentioned before, if you increase the number of of iterations, if you have ten thousand points instead of three hundred, it's highly likely and as more people are using earth Engine and we have to share that memory capacity across everyone in the community, that Coogler is going to give you here a memory limited error. You requested more memory and allowed and you cannot visualize your outputs on the fly. The solution for that is using batch mode, and batch mode is basically import exporting exporting the model's outputs to your rule drive.
Speaker 2: So what you do is use the export image to drive to import export your male average. You can export every single run if you want to. You can export the distribution maps or I already build the function here to transform the mall average into a binary map using the mean threshold we calculated, so that will give you a different approach, a different way of getting that potential distribution map, so you can export that one as well. You can also export all your metrics using the export table to drive.
Speaker 2: So this is going to be exported to your whole drive. So if you go to tasks here, I run it. I run it before today and this is how long it took ten minutes to explore that. But every time you click run, it's going to give you this option. So if I want to export the metrics I can run this. I can special if I a folder where I want to save it, and then click run. That's going to take a little bit of time, depending again how much memory you need, and then you can go to your rule right and access that he have my habitat suitability raster.
Speaker 2: It's like fifty megabytes my metrics, so I can open and inspect my false negative, force positive, the face positive rate precision that's some species in sensitively specificity, the true negative, true negative rate, true positives through positive rates, the cut off that is a threshold. And this is why I'm showing you, to show you that how different that threshold can be at each specific run, and how like arbitrary that threashold can feel sometimes. And so I always prefer to provide habitats with ability output, not the binary maps, but of course that's always a personal choice.
Speaker 2: And if you to calculate potential how it's available, you always need the binary map. But the same here for your UCPR. So then you can build nice tables for your your paper reports, and this one you can download it and use your favorites offtware to create maps. Always be mindful that if you are doing a model that thirty meter resolution. It may be two gavites and that's taken away from your fifteen gaites allocated for free. So always to be mindful that if I do that now, I will hit my quote and then I will have to start paying.
Speaker 2: So always be mindful of those objects you create with that I will pass it to Grant. That's going to explain other parts of the of how to tweak this model further to get extra information and some of the most recent discussions on the best practices for species vision models. So thank you.
Speaker 4: All right, So, Ramiro has just led us through this SDM function that goes through the steps of partitioning your occurrence data into these training and testing data sets. Has shown us how to fit those species distribution models recover some accuracy metrics on the back end. And I think one of the concepts that we alluded to early on is that often with these machine learning approaches to species distribution modeling, we are often striving for high predictive power, the ability to interpolate between places where you have known presence data for your species.
Speaker 4: But these machine learning models often don't excel at understanding these causal relationships between underlying variables and your species occurrence. So one thing that we want to just introduce here is the concept of variable importance and how that can work with a random forest classifier in Google Earth Engine. So the idea with extracting variable importance with a random forest model is that we're really trying to figure out how effectively different environmental layerst presence points from absence points within our classifier.
Speaker 4: And so the goal here is not necessarily to understand causal relationships, but really to understand for that specific model, which predictor variables had the most influence in thwarting presence and absence points.
Speaker 5: And so the.
Speaker 4: Code for obtaining these variable importance scores within Google Earth Engine is fairly straightforward if you just have a single classifier. So in this example, we are creating a new variable that we call variable importance. We have a trained classifier which is our SDM model, So that's this classifier PR, and then the explain function is extracting some information from that fitted model in Google Earth Engine. And one of those pieces of information that's distracted by the explain function is the variable importance.
Speaker 4: And so this is really letting you see which variables were the most influential in sorting your presence and your absence points. So we can actually print this output from that classifier, and we can see down below that we have these different environmental variables that went into our SDM model. So we had DVII, a couple different bioclimatic variables, we had elevation, and just looking through this list of variables, we can see that these variables with the higher importance scores are the ones that had the most influence in that particular model run.
Speaker 4: And so here we can see that elevation as well as these bio five and bio six variables were the most influential, so those had the highest important scores. This gets a little tricky when we go to this framework that Ramiro has introduced where we have an SDM function and we're doing this spatial block cross validation approach where we are taking different spatial subsets of our training and validation data and refitting the model. And so when we create this SDM function, we're than running this model multiple times on different spatial blocks of training data.
Speaker 4: And so to modify the function that Ramiro has introduced previously, we just have to add a couple of lines here where within that SDM function. We're going to introduce this variable importance as a new object, and so later we're actually going to want to work with this variable importance from across all our different model runs. And so this starts to look a little bit complicated, but what we're going to do is take that same importance score that I show you how to extract in the previous slide.
Speaker 4: We're going to turn that into a We're going to define that as a dictionary and convert that into a feature, and that feature just has a null geometry. So the idea is that later we want to just take an average across importance scores for each variable across these different model runs. And to do that, we're going to basically package this importance score as a feature within this SDM function. And so we're also going to modify the list of objects that are returned by this SDM function at the end of the loop.
Speaker 4: So we still are going to have our probability image that comes from the classifier, our binary image. We can export our training and testing partitions as we did previously, but we're also going to add this variable importance, which is going to be that list we just looked at for each variable what was the importance score for that variable. So then when we're doing this spatial block cross validation, we're here, we're doing a fivefold repeat. We're basically taking a list of different seeds, so these are different random seeds, and we're going to map this SDM function, or we're going to basically rerun this SDM function, but just taking different random partitions of our original presence absence data set.
Speaker 4: And so the result of this is going to be a fairly complex list of lists. So we're going to have a single list, and within that list, we're going to have all five outputs for each of our five different model runs that we just executed above. And so when we flatten that list of lists, we just get a single long list with lots of different these different data objects. So we'll get these two images are two training and testing partitions and the variable importance for model one. Then we'll have it for model two, model three, four, and five.
Speaker 4: We repeat this run five times, and so this next step looks a little complicated, but the basic ideas that we need to extract from this list of lists the index positions of that variable importance that list of variable importance values, and so every fifth item in this flattened list is going to be our variable importance. As we discuss previously, index positions in Google Earth Engine begin with the index zero, So the first object in a list always gets assigned the index position zero. And so what we want to do is it stract index position four, and then we want to skip out to model run two and it'stracted index position nine and so on.
Speaker 4: So this looks a little complicated, but the basic ideas that from each model run, we're trying to pull out just that very importance, and we're extracting that by looking at the index positions of those variable importance scores.
Speaker 4: Once we've extracted that list of variable importance scores from each run, we can convert that into a feature collection, and then we can use the reduced columns function to basically get a mean important score for each band or each variable in our classifier, and then we can print those results. And so then here what we'll be seeing is just an average importance score for each of the variables in our model, averaged across the five model runs that we're fit with different training and testing partitions.
Speaker 4: So I know this is a little complicated. Some of the challenge in this is just understanding.
Speaker 5: The way that these.
Speaker 4: Lists of outputs are getting packaged by our SDM function and then making sure that we're extracting the variable importance by referencing the correct index positions. One important thing to keep in mind when you're looking at these random forest variable important scores is that these are these genie importance scores, and those values are really specific to that particular model run. So it's going to depend on the size of your study area, the strategy that you used for creating pseudo absence data, if you have a present pseudo absence model,
Speaker 4: and so those methodological decisions can actually flip flop those variable important scores. So, to give an example, if you had a massive study area where just a small portion of that represents the suitable occupied range of your species, you're likely going to see that at those broad scales, some of these regional climate variables, sometimes just simple predictors like forest non forest can look massively important because they're doing a lot of the heavy lifting of saying, well, a lot of these present these pseudo absence points are not suitable because they fall in these different climate spaces.
Speaker 4: But if you clip that same model down to just a small area, for instance, around a single national park, a single watershed, the climate variables become really uniform across those presence and pseudo absence points, and so those variables become less important to the model. They're less valuable for sorting your presence and absence points from each other. And so then you might start to see that these localized variables slope aspect, canopy structure, forest understory structures, so different things that are more small scale variables, those might then rise to the top of your importance ranking.
Speaker 4: So when you're looking at these variable importance values that you get from from a random forest, you really need to be thinking.
Speaker 5: Interpretation is key.
Speaker 4: So an appropriate interpretation would be to say something like, across this specific study area, and with our given presence absence data set, precipitation was the most effective tool for distinguishing presence locations from absence locations. So that is, you know, a lot of nuance, a lot of qualifiers, but that's really all you can say with these variable importance scores on an SDM model. You shouldn't jump to the conclusion that because of these importance scores you found that precipitation is the most important niche requirement for this species, or it's more important than this other variable, because those rankings are all going to depend on, or to a large extent, will depend on these different methodological decisions.
Speaker 4: So one of these additional considerations that I think is really important for us to bring up here is that we've illustrated this workflow for a spatial block cross validation. The ideas that you're really providing your classifier with a challenge. You're saying, I'm going to give you some portion of the spatial data to fit the model and ask you to predict for these left out spatial blocks. So that's an extrapolation challenge. And so there's actually a study that came out that was really a massive wake up call for a lot of the ecological mapping community.
Speaker 4: This Ploton at All paper demonstrated that if you just use a random cross validation where you're just leaving out individual presence and absence points, you have really strong auto correlation between your left out data points and nearby neighboring or adjacent points that were included in the model fitting. And so Ploton at All basically found that you could have a model that looks incredibly powerful on paper, so you can have a fairly high R squared value, But when you do spatial block cross validation, you find that your model accuracy is basically zero.
Speaker 4: So the model hasn't learned ecological relationships. It's not able to extrapolate and say the likelihood of presence for a species in this particular part of the map compared to another part of the map, so it basically just memorized a geographic pattern rather than learned important underlying relationships. However, there's also this counterpoint that wadeau at All then had a response where they argue that spatial cross validation really punishes the model for poor extrapolation rather than just measuring how good the underlying map is.
Speaker 4: And you're also sacrificing data when you do a training testing partition and you basically take out some of your data. You're trying to fit the model with say seventy percent of the data, and you're omitting key geographic regions. So I think a good analogy is that you could just think of this as a debate over what exam you're giving your model. So Ploton at All are worried that you're the model is cheating because it's looking at its neighbors test paper. So you have this spatial auto correlation, and that really can be a problem if your model is overfit to a species current distribution, and if your goal is to be able to do something like predict future ranges under different climate scenarios, or extrapolate two different geographies to understand invasive potential of a species, for instance.
Speaker 4: But Wado would all argue that requiring spatial block cross validation is like forcing a student who studied Virginia ecology in the US to take an exam on the ecology of the Sahara Desert and then claiming they're a bad student because they failed. So they're basically being asked to take a test that they hadn't trained for. And on top of that, you're assigning an open book test where you don't even allow them to reference certain pages in the book. So you're penalizing your model by sacrificing in fortion.
Speaker 5: And you have this.
Speaker 4: Problem where you're trying to test how well the model can extrapolate rather than just how good is that model or how good is that map. So I think the key conclusion there is just that you really want to think about what your objectives are when you're considering your model validation strategy. Another concept that you'll see a lot in the species distribution modeling literature is this idea of ensembling species distribution models, and so the ideas that there are all these different algorithms out there.
Speaker 5: You can even do what we've shown.
Speaker 4: Of having these ensembles of different random forests fit with different subsets.
Speaker 5: Of your data.
Speaker 4: And some of the benefits of ensembling or that you can smooth over prediction. So an individual model might over fit to the data set in a particular way, and if you average multiple models, you can actually get a result that is maybe more robust. You're smoothing out some of that variance among model runs, and you may have a better ability to predict or at strapolate those models. And so this is a cool example of some work we did in ME and MAR where we tried fitting three different models a random forest, a generalized boosted model, and a maxim model.
Speaker 4: And each of those models has particular areas where they performed well and performed poorly, and if you just look at the consensus region among those three models, you actually get a distribution model that looks really good for this particular species. Some of the criticisms that you see of ensembling are that you're inherently averaging out what we'd call peak performance. So you have a couple models that perform really well, other models perform poorly, and you average them, and you're basically diluting the strength of your best models by combining their predictions with those from your worst models.
Speaker 4: So there are studies out there that show that ensembles rarely beat the best single model for a specific landscape, but they can in certain cases be better at smoothing out these issues of overfitting and lead to more generalizable results. So that's also kind of an open debate in the species distribution modeling literature. And so finally, I just want to wrap up with a short summary of some key pitfalls and best practices. So I think one is just this principle garbage in, garbage out. So you want to avoid relying on cases where you really don't have robust representative spatial data for your species.
Speaker 4: So if you have heavily clustered, crowdsourced data, or if you're just blindly throwing environmental variables into the model, you're not likely to get a result that actually represents the distribution or the habitat suitability of that species. Another key point is just to think critically about what ecological predictor variables you're including in a model. If you have a species where it's distribution is really defined by a variable like soil type, if it's a species that requires sandy soils, for instance, then you're only going to get so far and your model is only going to be so good when you're trying to model the distribution of that species using only bioclimatic variables, for instance.
Speaker 4: So think critically about which variables are likely informative for mapping the distribution of your species. And it's also good practice to drop highly colinear variables. So sometimes you can have max temperature of the warmest month, max temperature of the warmest quarter, those two variables might be super correlated. Just pick one that you think makes the most biological sense there. Another key point is just being intentional about your background point selection. So if you have true absence data, then use it.
Speaker 4: I think this is really something that I hate to see is when there's a study where they basically collected presence absence data and then they fit a maccent model or a presence only distribution model that basically ignores the fact that they had absence data in the first place. That absence data is really useful for helping define and what your overall likelihood of a species occurring in a certain location is. And also going back to some of our background information, it's really important to remember these distinctions between true absence data pseudo absences, which are supposed to represent places where we don't have hard data but we expect the species is unlikely to occur.
Speaker 4: And then those background points, which are supposed to be a representative sample of your geographic and environmental space, also define those pseudo absences strategically, so you really want to think about areas that are potentially reachable by your study species. I mentioned earlier about these conflicting approaches for validation strategies, but really think about trying to match your validation strategy to your goal. So you can just use simple random sampling. Ideally you'd have independent random points that you're going to use to validate your map accuracy if you're interested in just simply how good is this map at representing the current distribution of this species?
Speaker 4: But if you really want to be thinking about regional transferability. So the giraffe example that Ramiro shared earlier, where you're taking spatial data from a subset of animals and you're trying to extrapolate to where else on the landscape you might have suitable habitat those are cases where you should probably consider a spatial block cross validation, where you're really testing the generalizability or extrapolation ability of your model. A few additional best practices are just to think about this one humble based prediction in cases where that might be really useful.
Speaker 4: So you likely want to avoid relying on just a single best cross validation fold So in our example, we did five different training testing data splits fit the model five times. We don't want to just rely on the best model rather than trying to generalize across those different data splits. And I think the same applies to algorithms, where sometimes by combining outputs from multiple algorithms, you can average out some of the variability among them and some of the overfitting and get a more robust result, even if the best model might still be a single individual algorithm.
Speaker 4: One thing that you'll see a lot, especially with climate forecasting, is that many of these algorithms, especially some of these machine learning approaches, aren't great at extrapolating outside their training range. So you can run what's called a multivariate environmental similarity surface analysis. And the idea here is that you want to look at the range of environmental conditions that you actually had data for in order to see whether some of your prediction space represent environmental conditions that are completely novel where you don't have any data that speaks to whether the species should occur in those types of places or not.
Speaker 4: So that's really important if your goal is to project into new geographic areas or future climate conditions, so that you can basically flag where your predictions may be unreliable.
Speaker 4: I think another key point here is just that you often see species distribution modeling where at the end you have this binary map which is presence and absence, and that really smooths over a lot of the meaningful ecological nuance that when you fit these sdms and you have a probability surface, that variation is meaningful. So having low suitability doesn't mean necessarily that the species isn't there. So I think it's really best practice to share these continuous probability surfaces and not just those binary maps.
Speaker 4: And finally, I want to go back to this point that we mentioned earlier about how habitat suitability doesn't necessarily equal presence. So when we're doing this environmental niche modeling or we're fitting these species distribution models, we are generating these suitability predictions. But you can have any number of reasons that a species might not occur in a place that is predicted to be suitable. So we mentioned several of these, but they could have been extre paid by humans. There could be some biogeographic variable that has prevented the species from reaching certain portions of their suitable habitat.
Speaker 4: So just remembering at the end of the day that this is predicted suitability based on a model, it doesn't necessarily equate to species presence. And finally, I just wanted to mention that there are a lot of these points we've gone through that you know, there's a lot of nuance to your model fitting options and workflows, So we wanted to give these examples. In Google Earth Engine, where you can see how to modify a basic workflow fit species distribution models. We show a few of these tweaks like how you incorporate that spatial block cross validation, how you quantify uncertainty.
Speaker 4: But I think a really good reference is this od MAP protocol, which is basically a published paper showing some of the key steps in a species distribution modeling pipeline. And so I think this is a really good reference for being able to go to the next level with your modeling. So thinking about how do I adapt these basic workflows and ensure that I'm following these best practices for distribution modeling, And so finally I just wanted to share these couple of resources. So we have the original manuscript that Ramiro had referenced where we published some of these workflows and several case study examples for implementing distribution modeling in Google earth Engine.
Speaker 4: And we also wanted to mention that the Earth Engine code and data for this workshop are also freely available, so we'll make that make those scripts available at this repository.
Speaker 5: And so the goal is.
Speaker 4: That you'd be able to take those use them, adapt them, and also be thinking about how you incorporate some.
Speaker 5: Of these best practices that.
Speaker 4: We've covered in this training and that you might find in other references, like in that od map pipeline.
Speaker 5: So thank you very much.
Speaker 1: Thank you Ramido, Jared and Grant for sharing your expertise with us over these past two sessions. We are sincerely grateful for your collaboration. So a lot was covered in today's session. In summary, this training introduced and demonstrated a workflow for building a machine learning model in Google Earth Engine. They highlighted the data preparation and spatial optimization processes, allowing us to review initial steps for uploading ag existing species data, essential preprocessing steps, spatial thinning techniques for presence data, and methods to define areas of interest.
Speaker 1: Our presenters discussed predictor variable selection and access data from the Google Earth Engine catalog. They reviewed an absence strategy, introducing us to concepts of true presence and absence, providing techniques to generate pseudo absence points. They contrasted model validation methods and illustrated variable importance of environmental layers. A key message I took away was how crucial it is to align model evaluation strategies directly with overarching project objectives. And lastly, they provided details about common pitfalls and best practices.
Speaker 1: As I mentioned, there will be one homework assignment which following this training that you can access on our web page. You must have attended both webinars and complete the homework assignment by the deadline in order to get this certificate. Here is our contact information. Should you have any additional questions, feel free to visit our website to browse past training sign up for new ones. Our YouTube channel is also linked here. We also encourage you to join our mailing list. All right, so we definitely want to hear your thoughts.
Speaker 1: Within a day or two, we will send you an invitation to complete a short online survey this information that we get the feedback is super important and helps us improve our our set program. Your participation is optional and your responses are confidential, so please keep an eye out. This is not spam. So with that, we thank you again for joining us, and we are going to move into the Q and A shortly. We had so many questions during this training, so many questions that we were able to take track of while you all were putting everything in the chat.
Speaker 1: So currently we are looking at about thirty three questions that the team has been watching very closely and doing their best to feel and responses as we went so in order to just spend some time and put some voice to those questions. We are gonna go ahead and show the document that contains all of the questions that will be posted to the website. So question one when you download data from JBEF, what is the analysis area extent? Can I do it for a location radius ten kilometers for instance? Can I analyze a much larger area?
Speaker 1: Also? Does it work in the whole world? So you can set the extent in GIEBEF, for instance, restrict the data to a bounding box or a specific country, and you can certainly download the data for the entire world too. You can also select points in Google Earth Engine with a filter. There's a lot of flexibility in getting the data set you actually need in your modeling exercise. Another question we had when uploading data where is it safe? Is it connected to my Google account or is the Earth Engine account separate?
Speaker 1: Thinking about safety for coordinates that should be kept secret for protected species and such. So the data that is saved as an asset and it takes storage from your Google account. It is all connected with your Google cloud. You can see all of your assets in the Assets tap. In terms of sharing, the data will be accessible only to you, unless you specify either specific person that you want to allow to access or by making the data publicly available. You can check again in the recording where it was shown that there was a place to make the data public.
Speaker 1: Question three. When defining spatial resolution, does Google earth Engine automatically upscale or downscale the collected data or must a custom script be written to process such dataset manually. Google earth Engine by default operates on a pool basis where it resamples your data and any other data you're working with from the catalog awesome Google earth Engine community data sets, etc. Only at the point that you request an output at a certain resolution. So it may be only at the export step that you define a specific spatial resolution for example thirty meters, and Google earth Engine will handle the resampling and reprojection automatically during the export process.
Speaker 1: You don't need to be constantly upscaling and downscaling or resampling every time you bring in a new data set into your st One thing to note is that when you add outputs to the map viewer the map viewer window, the resolution of the output will depend on your zoom level. You can force Google earth Engine to resample to just a given resolution or grid, but typically you would use the map viewer just to explore or problem solve, and then export your final outputs at your desired resolution as your last step.
Speaker 1: Another important note is that it is good to familiarize yourself with how Google Earth Engine handles this on the fly or final resampling. For instance, the default is that Google Earth Engine uses the nearest neighbor resampling, and this may not be what you want. All right, everyone, So that was us just getting through the first three questions, and I know we have been online for a long time, so I want to invite our guests who are here with us, Grant, Jared if Ramito, if any of you would like to share for some of the next few questions, I'm happy to read them.
Speaker 1: But you all have that expertise and want to give the credit for the hard work you put into answering all of these. And again, we have over thirty at this point.
Speaker 2: I'm happy to answer Annie or maybe select if you are super interesting.
Speaker 1: Okay, yeah, me too.
Speaker 5: We're all here, happy to help.
Speaker 2: And yeah, also take the opportunity to thank everyone for showing up and super good to see such a response.
Speaker 1: What if you each choose one that you want to share speak some life into and then that might be a good time to close out following so that way we can get people some time back.
Speaker 2: Okay, I can go with one question thirteen. Someone asks ultimately, especially tribution models will not be realistic with that accounting for human behavior data. Do you have some snippets that account for the daytawn human behaviors such as hunting, cattle grazing, and infrastructure such as roads. And this is a very important point, and this is what rule the engine is so good at. A common use product that's exactly for this is called these human modification index that actually incorporates rose line, infrastructure, different landcover types, so if you have a farm, it has more impact than in park livestock.
Speaker 2: A lot of that data is integrated and create this kind of index that there is a link there to that as that image that you can incorporate into your model. It's actually broadly use in special descution models. There are other other ones like people used, like the light pollution, so from satellites at night, you can use light pollution to use that as a coveriable continue with this answer basics looked through the data catalog or the awesome Googler tengient community data set to the term which layers are currently available.
Speaker 2: For instance, you can use road data Googler tangent from the Tiger Roads data for the US, or the Relower Road Inventory project data set from the asome Goglar community data set to calculate road density, or even import your own data sets into Googler Engine to meet their own project objectives. I passed to when a few runt or.
Speaker 6: Yeah, one second, just trying to get my camera to be working here. Yeah, I'll just do number twelve because it relates to collinearity, which is a common question I think, and I think it came up quite a few times.
Speaker 5: In the chat.
Speaker 6: So the question number twelve is could you run some sort of collinearity study, like a variance inflation factor to eliminate highly collinear variables in JavaScript before modeling. So yes, certainly, some SDM models are fairly robust to collinearity, like the models that we showed here that Maria on Graham were walking through the random forest, while others are not, like logistic aggression. So it's often a good idea to check for highly correlated covariates as a preliminary step. And it's worth noting that variable inform importance metrics can be influenced by culinary since having a bunch of correlated variables in a model tends to reduce important statistics for these variables.
Speaker 6: And the original code that we published in our manuscript, there is code that checks for corelinary correlation between predicted variables, so that is also included. So I would just refer you to that original manuscript that has all the code that was put together to run all the models that are published in that publication.
Speaker 4: Okay, thanks, and I was thinking I'll jump down to question number twenty. So yeah, there are a lot of great questions that people put in the Q and A and really appreciate the engagement that you all have shown with this. It's been a lot of action in the chat, so I know these Q and A documents will be sent out. So if you asked a question, that should be answered. But question twenty, I think is something that just is a good wrap up. I think, so the question was GEE facilitates large scale analysis, but its workflows often rely on temporal composites, collapsing pixel phonology into summary statistics like the median given the time first space later paradigm in the sites are package.
Speaker 4: How could incorporating pixel phonology improve species distribution models? Moreover, are the methods presented in this r set compatible with using full time series information predictors or do they inherently require temporally aggregated variables?
Speaker 4: So I just wanted to talk through what this the goal of this example workflow was. It's really we wanted to show you a workflow that you can take and modify for your own purposes, so it doesn't inherently require certain types of predictor variables. So you basically need three things. You need a current data, you need predictor variables that are raster data sets, and you need a model or algorithm like random forest for relating those two. So your predictors can really be anything that you feel is biologically meaningful and that you can represent as a raster data set.
Speaker 4: So you could do something like write some Google Earth Engine code that calculates the standard deviation in a vegetation metric like in DVII over time. Then you can use those pixel values as a measure of variability and phonology, So there are a lot of published studies and examples and code where people extract phenological metrics in Google Earth Engine. Any of those could really be used as predictors if you can basically specify them in raster format.
Speaker 5: So I think the goal is that we.
Speaker 4: Really want you to unleash your inner model or think about what really matters for your species, and then if you can find existing data sets where you can use those as predictors, or others where you can modify some existing code and get what you feel is important for your species to incorporate in the model, then that's really the goal, is that you'd be able to do that.
Speaker 1: Wonderful. Well, thank you so much. We're spending all this time with us for getting this entire series put together so that we could share with our our set community. We hope everyone has a beautiful rest of their day. And if you weren't in this session, there is is a duplicate session that will begin later this afternoon, So with that we will say goodbye.
Speaker 3: So everybody, thanks so much, and anyone who is still on and listening.
Speaker 1: There are optional exercises on the training page
Podbean