Author(s: Karthik Bhandary Originally published at , the World’s Most Popular AI and Technology News and Media Company. We invite you to become an AI sponsor if you’re working on an AI product or service. helps technology and AI startups scale. We can help you bring your technology to mass markets. Data Analysis Analysis of Biodiversity In National Parks Projects Photo: Tania Malrechauffe, Unsplash. This blog will analyze the Kaggle data set “Biodiversity In National Parks Projects”. To perform this analysis, we will be using statistics and visualizations. This is only a basic analysis. This analysis is not intended to apply any ML algorithms. My notebook is available in Kaggle. Don’t forget upvote it if you enjoy it. That’s it. Let’s now get to analysing this dataset. This project aims to analyse biodiversity data collected by the National Parks Service. It will focus on species that have been observed at different locations within national parks. The project will analyze, plan, prepare and plot the data. Finally, it will attempt to interpret the results. This project sought to answer the following questions: How does species conservation status vary? Is it more common for certain species to become endangered than others? Is it important to note the difference between species and conservation status? What is the most common animal and how is it distributed among parks? Project Goals This project will provide a perspective through the National Parks Service’s biodiversity analyst. To ensure that at-risk species survive, the National Park Service will work to preserve their biodiversity. As an analyst, your main goals will include understanding species characteristics and conservation status. Also, understand the relationships between species and national parks. These questions are: How do species’ conservation statuses compare? Is it more common for certain species to become endangered than others? Is it important to note the difference between species and conservation status? What is the most common animal and how is it distributed among parks? Two data sets were included with this package. One file contains information on each species, while the other has observations and park location data. These data will be used for analysis of project goals. Analyse This section will use descriptive statistics as well as data visualization techniques to better understand the data. To determine if observed values have statistical significance, statistical inferences will be applied. The key metrics to be calculated include the distributions, counts and relationship between species conservation status, species observations in parks. Final evaluation. It’s worth reviewing the goals to see if the results of the analysis match the first questions (in the goals section). The section also reflects on the learnings and any questions that were not answered. These could include any limitations, or alternative methods that could have been used to analyze the data. Importing Essential Modules pandas import as pdimport npimport matplotlib.pyplot pltimport seaborn as sns%matplotlib.inline Loading the Data The next step is Observations.csv. Species_info.csv. These DataFrames are called species and observations, respectively. To view the contents of newly-created DataFrames, use.head. species = pd.read_csv(“../input/biodiversity-in-national-parks-project/species_info.csv”)species.head Image by author It loads the following result observations = pd.read_csv(“../input/biodiversity-in-national-parks-project/observations.csv”)observations.head Image by author We get the following result Data Characteristics Next, there will be a check for the dimensions of the data sets, for species there are 5,824 rows and 4 columns while observations has 23,296 rows and 3 columns. print(f”Species Shape: species.shape”)print(f”Observations Shape: observations.shape”) #ResultSpecies Shape: (5824, 4)Observations Shape: (23296, 3) It is time to explore the species data a little more in-depth. First, find out how many species are present in the data. print(f”No of unique species: species.scientific_name.nunique”) #ResultNo of unique species: 5541 print(f”No of unique categories: species.category.nunique”)print(f”Categories: species.category.unique”) #ResultNo of unique categories: 7Categories: ['Mammal' 'Bird' 'Reptile' 'Amphibian' 'Fish' 'Vascular Plant' 'Nonvascular Plant'] species.groupby(“category”).size #ResultcategoryAmphibian 80Bird 521Fish 127Mammal 214Nonvascular Plant 333Reptile 79Vascular Plant 4470dtype: int64 From the above observations made, Vascular plants are by far the largest share of species with 4,470 in the data with reptiles being the fewest with 79. print(f”No of unique status: species.conservation_status.nunique”)print(f”Conservation Status: species.conservation_status.unique”) #ResultNo of unique status: 4Conservation Status: [nan 'Species of Concern' 'Endangered' 'Threatened' 'In Recovery'] Next, a count of the number of observations in the breakdown of the categories in conservation_status is done. There are 5,633 nan values which means that they are species without concerns. On the other hand, there are 161 species of concern, 16 endangered, 10 threatened, and 4 in recovery. print(f”na Values: species.conservation_status.isna.sum”)print(species.groupby('conservation_status').size) #Resultna Values: 5633conservation_statusEndangered 16In Recovery 4Species of Concern 161Threatened 10dtype: int64 observations The next section looks at the observations data. First, we need to verify the total number of national parks in our dataset. There are just four. print(f”No. of Parks: observations.park_name.nunique”)print(f”Parks: observations.park_name.unique”) #ResultNo. of Parks: 4Parks: ['Great Smoky Mountains National Park' 'Yosemite National Park' 'Bryce National Park' 'Yellowstone National Park'] Here are the total number of observations logged in the parks, there are 3,314,739 sightings in the last 7 days… that’s a lot of observations! print(f”observations: observations.observations.sum”) #Resultobservations: 3314739 Analysis The first task will be to clean and explore the conservation_status column in species. There are several values that can be assigned to the column conservation_status. These numbers will be converted into No Intervention. species.conservation_status.fillna(“No Intervention”, inplace=True)species.groupby(“conservation_status”).size #Result conservation_statusEndangered 16In Recovery 4No Intervention 5633Species of Concern 161Threatened 10dtype: int64 Next is to check out the different categories that are nested in the conservation_status column except for the ones that do not require an intervention. Below is the chart and table. There were 7 mammals in Endangered and 4 birds. In Recovery, 3 were birds, and 1 was a mammal. This could indicate that birds are recovering more quickly than mammals. conservationCategory = species[species.conservation_status != 'No Intervention'].groupby([“conservation_status”, “category”])[“scientific_name”].count.unstackconservationCategory Image by author ax = conservationCategory.plot(kind=”bar”, figsize=(8,6), stacked=True)ax.set_xlabel(“Conservation Status”)ax.set_ylabel(“Number of Species”); Image by author In conservation The next question is if certain types of species are more likely to be endangered? You can answer this question by adding a column named is_protected to include all species with a value of less than zero. species['is_protected'] = species.conservation_status != 'No Intervention' category_counts = species.groupby(['category', 'is_protected']) .scientific_name.nunique .reset_index .pivot(columns='is_protected', index='category', values='scientific_name') .reset_indexcategory_counts.columns = ['category', 'not_protected', 'protected']category_counts Image by author category_counts['percent_protected'] = category_counts.protected / (category_counts.protected + category_counts.not_protected) 100category_counts Image by author Statistical Significance This section will run some chi-squared tests to see if different species have statistically significant differences in conservation status rates. A contingency table is required to run the chi-squared tests. This is the contingency table. Image by author. The first test, contingency1, will be required.
Analyse on Biodiversity Projects in National Parks

