Field biologists collecting morphometric data face a practical question: which measurements actually matter for species identification? You are standing in the field with calipers, measuring bill length, bill depth, flipper length, and body mass. Do you need all four? Can you drop body mass and save time per bird? Does a single measurement separate one species from the others?
Random forest feature importance is one way to answer these questions quantitatively. This guide explains how to read the main outputs of a morphometric classification: distributions by species, normalized profiles, feature importance, two-measurement scatter plots, and sexual dimorphism comparisons, and how to avoid over-reading them. The worked example below shows how to check a species model on held-out data and compare body traits.
Worked Example: Species from Body Traits, on Made-Up Data
Question: Can four body traits sort made-up penguin-like birds into three groups? Which traits help this model?
Inputs: made-up data, seed 23. Each row is one bird, with 120 birds in each of three groups called species A, B and C. The four traits are bill length, flipper length, bill depth and body mass. The script sets the average of each trait by species, and the spread within a species, by hand. The averages for species A, B and C are: bill length 38, 45 and 50 (spread 4.8); flipper length 190, 205 and 215 (spread 13); bill depth 3.6, 3.9 and 4.2 (spread 0.38); body mass 4300, 4700 and 5000 (spread 520). The values have no units because they are made up.
Method: the script splits the data into 270 birds to fit the model and 90 held-out birds kept for a check. It fits a random forest, a set of 300 decision trees, on the first set. It checks how many held-out birds it sorts right. It ranks traits by their role in tree splits (impurity importance). It also shuffles each trait in the held-out set, 20 times, and measures how much the held-out score drops.
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.inspection import permutation_importance
from sklearn.metrics import accuracy_score
# Simulated data, seed 23. Rows are birds; columns are body measurements.
rng = np.random.default_rng(23)
n_per_species = 120
species = np.repeat(np.array(["A", "B", "C"]), n_per_species)
centers = np.array([
[38.0, 190.0, 3.6, 4300.0],
[45.0, 205.0, 3.9, 4700.0],
[50.0, 215.0, 4.2, 5000.0],
])
scales = np.array([4.8, 13.0, 0.38, 520.0])
measurements = np.vstack([
rng.normal(loc=centers[i], scale=scales, size=(n_per_species, 4))
for i in range(3)
])
feature_names = ["bill length", "flipper length", "bill depth", "body mass"]
x_train, x_test, y_train, y_test = train_test_split(
measurements, species, test_size=0.25, random_state=23, stratify=species
)
model = RandomForestClassifier(
n_estimators=300, random_state=23, min_samples_leaf=2)
model.fit(x_train, y_train)
predicted = model.predict(x_test)
permutation = permutation_importance(
model, x_test, y_test, n_repeats=20, random_state=23, scoring="accuracy"
)
print("Simulated data, seed 23")
print(f"Birds: {len(species)} total; {len(np.unique(species))} species; "
f"{n_per_species} per species")
print(f"Features: {', '.join(feature_names)}")
print(f"Train/test split: {len(y_train)} train; {len(y_test)} held out")
print(f"Held-out accuracy: {accuracy_score(y_test, predicted):.3f}")
print("Impurity importance (within this fitted forest):")
for name, value in sorted(zip(feature_names, model.feature_importances_),
key=lambda item: -item[1]):
print(f" {name}: {value:.3f}")
print("Held-out permutation importance (accuracy drop):")
for name, value in sorted(zip(feature_names, permutation.importances_mean),
key=lambda item: -item[1]):
print(f" {name}: {value:.3f}")
Printed output:
Simulated data, seed 23
Birds: 360 total; 3 species; 120 per species
Features: bill length, flipper length, bill depth, body mass
Train/test split: 270 train; 90 held out
Held-out accuracy: 0.678
Impurity importance (within this fitted forest):
bill length: 0.326
bill depth: 0.267
flipper length: 0.254
body mass: 0.153
Held-out permutation importance (accuracy drop):
bill length: 0.159
flipper length: 0.023
bill depth: 0.019
body mass: 0.011
Result: the held-out accuracy was 0.678. Bill length ranked first on both measures, with an impurity importance of 0.326. Shuffling it caused the largest score drop, 0.159.
What the script builds in: every trait has a set gap between species. Measured in units of the within-species spread, the gap between species A and B is 1.46 for bill length, 1.15 for flipper length, 0.79 for bill depth and 0.77 for body mass. Bill length has the widest set gap, so ranking first is expected. Only the first rank is clear. The order of the other traits is not reliable on 90 held-out birds: the impurity ranking puts bill depth above flipper length although flipper length has the larger set gap, and the shuffle drops for the other three traits (0.011 to 0.023) are small. With 90 held-out birds, the accuracy of 0.678 is uncertain by about 5 points. The groups overlap, which is why accuracy is not higher.
Limit: these data are made up to show the method. The example has no sex variable, so it says nothing about sexual dimorphism, and it does not show how well the method sorts real birds.
Sources
- Breiman L (2001). Random Forests. Machine Learning. doi:10.1023/A:1010933404324. Covers: who published random forests and when.
The Classification Challenge: Several Species, Several Measurements
The design question is: can we build a field identification key from morphometric measurements?
Morphometric keys use quantitative measurements anyone can collect with calipers and a scale. The advantage: objective, reproducible, trainable. The disadvantage: measurements have variance, distributions overlap, and single thresholds rarely achieve perfect accuracy.
Random forest combines many weak decision rules into a strong classifier. Instead of one hard rule such as "if bill depth is below a cutoff then species A, else species B", you get probabilistic predictions based on patterns across all measurements. Suppose a model returns "87% species A, 10% species B, 3% species C" for one bird (made-up numbers, for illustration only). The model gives a score or chance for each group. Trust it only after checking how well scores match outcomes and results on data kept for a test.
Reading Morphometric Distributions by Species
Box plots grouped by species show the first-order patterns: where species separate cleanly and where distributions overlap. For each measurement, look at the medians, the interquartile ranges (IQR), and the amount of overlap.
- Non-overlapping IQRs indicate strong discrimination potential for that measurement.
- Overlapping IQRs but separated medians indicate moderate discrimination. The measurement adds information but is not diagnostic alone.
- Overlapping medians indicate weak discrimination.
Body mass deserves special care. It varies with sex, season, and individual condition, so it often shows high within-species variance and is usually less reliable for species identification than skeletal measurements such as bill or flipper dimensions.
Species Morphometric Profiles (Normalized)
Z-score normalization removes measurement units and scales, revealing relative species differences. A z-score tells you how many standard deviations a species' mean sits from the overall mean for that measurement. This is useful for comparing profiles rather than absolute sizes.
The profile shows whether species have alike or different relative proportions. Alike z-score patterns mean groups have alike relative means for the traits shown. This alone does not test if body size grows in the same way. If one species is, say, high on body size measurements but low on a bill measurement, that signals different proportions, which may point to ecological divergence worth testing.
Feature Importance for Species Discrimination
The forest split rank (impurity importance, MeanDecreaseGini) shows each trait's role in tree splits. It does not show how many birds are sorted right. Check the held-out set or shuffle results to judge how well the model sorts birds. This is not the same as "which measurement differs most between species". It answers "which measurement, when used in decision rules, most reduces classification uncertainty across the forest".
- A measurement that cleanly isolates one species with a single split can rank high even if it does not separate the other species from each other.
- A measurement that is only useful for one two-way split can rank lower overall while still being essential for complete classification. Do not read a low rank as "does not matter".
- Correlated measurements share importance, so rankings can shift when you add or drop a correlated variable.
Two-Measurement Scatter Plots and Decision Boundaries
A scatter plot of the two most useful measurements, colored by species, shows why a classifier works or fails. If the species form distinct clusters, you can draw nearly straight lines between them, and simple rules or linear discriminant analysis will perform close to a random forest. If the clusters overlap heavily or form curved shapes, you need nonlinear classifiers or additional measurements.
Sexual Dimorphism: Comparing Body Mass by Sex and Species
To quantify sexual dimorphism, group the measurement by species and sex, and compare the male and female medians or means within each species. Report both the absolute difference and the percentage difference, since a species with larger overall body size will show a larger absolute gap for the same percentage.
How to Interpret Your Results
If you are running this analysis on your own morphometric dataset, here is the interpretive framework:
1. Start with Distributions (Box Plots)
Box plots show where species differ and how much distributions overlap. Overlap in box plots for one trait at a time does not show if all traits sort birds when used together. Check the model on birds kept for a test first.
2. Check Normalized Profiles for Allometry
Z-score profiles reveal whether species differ in proportions versus scale. Alike z-score patterns mean groups have alike relative means for the traits shown. This alone does not test if body size grows in the same way. Different patterns show that the groups differ in relative proportions.
3. Use Feature Importance to Prioritize Measurements
Feature importance tells you which traits play a larger role in the model's splits. It is not a count of birds sorted right, so read it with the held-out accuracy and the shuffle results.
Importance scores are not statistical thresholds. Always confirm by refitting without a measurement and comparing held-out accuracy. In the worked example, only the first rank was clear.
4. Visualize Decision Boundaries (Scatter Plots)
Scatter plots of the top two features reveal whether species are linearly separable. If you can mentally draw lines between the clusters, simple decision rules will work. If not, use nonlinear classifiers or add measurements.
5. Quantify Sexual Dimorphism with Caution
- Body mass dimorphism is confounded by reproductive stage, season, and individual condition
- Skeletal measurement dimorphism (bill, flipper) is more stable but needs large samples to detect small differences
- Consistent dimorphism across species suggests shared selective pressures
- Species-specific dimorphism patterns suggest divergent reproductive ecology
When Species Boundaries Blur: Measurement Error and Variance
Before concluding that species are cleanly separated by morphometrics, consider the uncertainty that clean analysis reports tend to leave out.
Measurement error compounds at cluster boundaries. Calipers and scales have finite precision, and results depend on exact caliper placement and how firmly the jaws are closed. Suppose a bird measures right at a decision threshold, and the measurement error is about the same size as the gap to the threshold. Then a classification that looked confident is really close to a coin flip. Field protocols should use confidence zones around a threshold instead of a single hard cutoff, with a second measurement to settle borderline birds.
Intraspecific variance can swamp interspecific differences in some populations. If a model was fitted on birds pooled from several sites, and you sample only one site, local adaptation or genetic drift can shift the distributions and lower accuracy.
The solution is local calibration. Measure a set of individuals of known species (confirmed by DNA or expert visual identification) from your own study site, and recalculate decision thresholds using local distributions.
Sexual dimorphism creates within-species clusters that can mimic between-species differences. If you plot body mass without sex labels, you may see bimodal distributions that could be misread as two species. When classification accuracy is lower than the apparent cluster separation suggests, check for unlabeled sex dimorphism. If adding sex as a feature substantially improves accuracy, dimorphism was confounding the species classification.
From Observation to Experiment: Testing Ecological Hypotheses
A morphometric analysis describes patterns. It does not explain why a bill is shallow or why one sex is heavier. Those are ecological hypotheses requiring experiments, not just observation. The mindset: correlation identifies patterns; experiments test mechanisms.
Example hypothesis: a species' bill shape is adapted to its main prey. Experimental test: measure prey capture success for each species presented with prey of varying sizes under controlled conditions. If each species does best on a different prey size, that supports the hypothesis. If performance is equal across prey sizes, the bill difference is not about prey handling.
Example hypothesis: male-biased body mass is driven by male-male competition for nest sites. Experimental test: mark individual males, measure body mass pre-breeding, and record which males win territorial disputes. If heavier males win significantly more contests, that supports the hypothesis. If body mass does not predict outcomes, look to other mechanisms such as female choice or fasting endurance.
Your turn
Bring your own data and the question you actually need answered.
MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai
Frequently Asked Questions
Which body measurement best separates species?
There is no universal answer. In a random forest, the measurement with the highest feature importance (MeanDecreaseGini) is the one whose splits most reduce classification uncertainty on your data. Check box plots first: the measurement with the least overlap between species is usually the top candidate, and importance scores quantify that on your own dataset.
Is sexual dimorphism consistent across species?
Not necessarily. Compare the male-female difference within each species, in absolute units and as a percentage, with sample sizes large enough to detect it. Consistent percentage differences suggest shared biology; very different ones suggest species-specific patterns worth investigating. Body mass is confounded by season and breeding stage, so skeletal measurements are more stable.
Can you identify species from a few measurements alone?
Sometimes. If species form well-separated clusters in a scatter plot of two measurements, a simple two-step decision rule can work. Whether that holds depends on the species and the population, so test any rule on labeled specimens from your own site before relying on it.
What sample size do you need for reliable species classification?
It depends on class balance, how much the species overlap, and how many measurements you use. Hold out a test set, and check that feature importance rankings are stable across resamples.
How do you normalize morphometric measurements for comparison?
Z-score normalization (subtract the mean, divide by the standard deviation) puts measurements with different units on one scale. A z-score of +2.0 means two standard deviations above the mean. Plotting each species' mean z-score per measurement shows proportions rather than raw size.
The Experimental Design Lens: What This Kind of Data Can and Cannot Tell You
What a morphometric classification can support:
- Which measurements are most diagnostic for discriminating the species in your sample
- How accurate a classifier is on held-out data from the same population
- Whether sexual dimorphism is present and how large it is, given your sampling conditions
What it cannot support without experiments:
- That differences are adaptations to different niches (correlation is not adaptation without fitness data)
- That dimorphism is caused by a particular mechanism such as male-male competition
- That the patterns generalize to other populations (one site is not global sampling)
- That differences are genetically based rather than plastic responses to environment
Respect what your data can answer, recognize what it cannot, and design the next study to close the gap.